Skip to content

Commit

Permalink
tests/tail: Adjust tests for warnings of tail to use stderr_to_stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
Joining7943 committed Dec 3, 2022
1 parent 8055f32 commit fc0cf03
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions tests/by-util/test_tail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3921,50 +3921,65 @@ fn test_args_when_settings_check_warnings_then_shows_warnings() {
let scene = TestScenario::new(util_name!());
let fixtures = &scene.fixtures;

// TODO: mix stdout and stderr
let expected_stdout = "file data\n";
fixtures.write("data", expected_stdout);
let file_data = "file data\n";
fixtures.write("data", file_data);

let expected_stderr = "tail: warning: --retry ignored; --retry is useful only when following";
let expected_stdout = format!(
"tail: warning: --retry ignored; --retry is useful only when following\n\
{}",
file_data
);
scene
.ucmd()
.args(&["--retry", "data"])
.stderr_to_stdout()
.run()
.stderr_is(expected_stderr)
.stdout_is(expected_stdout)
.stdout_only(expected_stdout)
.success();

let expected_stderr = "tail: warning: --retry only effective for the initial open\n";
let expected_stdout = format!(
"tail: warning: --retry only effective for the initial open\n\
{}",
file_data
);
let mut child = scene
.ucmd()
.args(&["--follow=descriptor", "--retry", "data"])
.stderr_to_stdout()
.run_no_wait();

child
.delay(500)
.kill()
.make_assertion()
.with_current_output()
.stderr_is(expected_stderr)
.stdout_is(expected_stdout);
.stdout_only(expected_stdout);

let expected_stderr = "tail: warning: PID ignored; --pid=PID is useful only when following";
let expected_stdout = format!(
"tail: warning: PID ignored; --pid=PID is useful only when following\n\
{}",
file_data
);
scene
.ucmd()
.args(&["--pid=1000", "data"])
.stderr_to_stdout()
.run()
.stderr_is(expected_stderr)
.stdout_is(expected_stdout)
.stdout_only(expected_stdout)
.success();

let expected_stderr = "tail: warning: --retry ignored; --retry is useful only when following\n\
tail: warning: PID ignored; --pid=PID is useful only when following";
let expected_stdout = format!(
"tail: warning: --retry ignored; --retry is useful only when following\n\
tail: warning: PID ignored; --pid=PID is useful only when following\n\
{}",
file_data
);
scene
.ucmd()
.args(&["--pid=1000", "--retry", "data"])
.stderr_to_stdout()
.run()
.stderr_is(expected_stderr)
.stdout_is(expected_stdout)
.stdout_only(expected_stdout)
.success();
}

Expand Down

0 comments on commit fc0cf03

Please sign in to comment.