mirror of
https://github.com/uutils/coreutils.git
synced 2025-12-23 08:47:37 +00:00
more: tests: cleanup processes in test_valid_arg
Added cleanup in test_alive to ensure all spawned processes are terminated on successful test execution. This also fixes a race condition that could occur: the check for process is_alive might be executing while more is still parsing the arguments.
This commit is contained in:
parent
45457cf718
commit
ff001139ea
1 changed files with 15 additions and 7 deletions
|
|
@ -46,14 +46,22 @@ fn test_valid_arg() {
|
|||
|
||||
fn test_alive(args: &[&str]) {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let file = "test_file";
|
||||
at.touch(file);
|
||||
|
||||
ucmd.args(args)
|
||||
.arg(file)
|
||||
.run_no_wait()
|
||||
.make_assertion()
|
||||
.is_alive();
|
||||
let content = "test content";
|
||||
let file = "test_file";
|
||||
at.write(file, content);
|
||||
|
||||
let mut cmd = ucmd.args(args).arg(file).run_no_wait();
|
||||
|
||||
// wait for more to start and display the file
|
||||
while cmd.is_alive() && !cmd.stdout_all().contains(content) {
|
||||
cmd.delay(50);
|
||||
}
|
||||
|
||||
assert!(cmd.is_alive(), "Command should still be alive");
|
||||
|
||||
// cleanup
|
||||
cmd.kill();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue