diff --git a/tests/by-util/test_more.rs b/tests/by-util/test_more.rs index bdfc564c09c..4cd984d7cef 100644 --- a/tests/by-util/test_more.rs +++ b/tests/by-util/test_more.rs @@ -46,14 +46,22 @@ fn test_valid_arg() { fn test_alive(args: &[&str]) { let (at, mut ucmd) = at_and_ucmd!(); + + let content = "test content"; let file = "test_file"; - at.touch(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"); - ucmd.args(args) - .arg(file) - .run_no_wait() - .make_assertion() - .is_alive(); + // cleanup + cmd.kill(); } #[test]