Replace yes
command by while-echo
The `yes` command is not available on all platforms.
This commit is contained in:
parent
df61fcaec1
commit
3970793579
1 changed files with 7 additions and 3 deletions
|
@ -8,14 +8,14 @@
|
||||||
// libstd ignores SIGPIPE, and other libraries may set signal masks.
|
// libstd ignores SIGPIPE, and other libraries may set signal masks.
|
||||||
// Make sure that these behaviors don't get inherited to children
|
// Make sure that these behaviors don't get inherited to children
|
||||||
// spawned via std::process, since they're needed for traditional UNIX
|
// spawned via std::process, since they're needed for traditional UNIX
|
||||||
// filter behavior. This test checks that `yes | head` terminates
|
// filter behavior.
|
||||||
|
// This test checks that `while echo y ; do : ; done | head` terminates
|
||||||
// (instead of running forever), and that it does not print an error
|
// (instead of running forever), and that it does not print an error
|
||||||
// message about a broken pipe.
|
// message about a broken pipe.
|
||||||
|
|
||||||
// ignore-emscripten no threads support
|
// ignore-emscripten no threads support
|
||||||
// ignore-vxworks no 'sh'
|
// ignore-vxworks no 'sh'
|
||||||
// ignore-fuchsia no 'sh'
|
// ignore-fuchsia no 'sh'
|
||||||
// ignore-nto no 'yes'
|
|
||||||
|
|
||||||
use std::process;
|
use std::process;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
@ -27,7 +27,11 @@ fn main() {
|
||||||
thread::sleep_ms(5000);
|
thread::sleep_ms(5000);
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
});
|
});
|
||||||
let output = process::Command::new("sh").arg("-c").arg("yes | head").output().unwrap();
|
let output = process::Command::new("sh")
|
||||||
|
.arg("-c")
|
||||||
|
.arg("while echo y ; do : ; done | head")
|
||||||
|
.output()
|
||||||
|
.unwrap();
|
||||||
assert!(output.status.success());
|
assert!(output.status.success());
|
||||||
assert!(output.stderr.len() == 0);
|
assert!(output.stderr.len() == 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue