From c4c3a354f84ff9786453b1d7ae5cda2e328ddcf4 Mon Sep 17 00:00:00 2001 From: Ideflop <94184575+Ideflop@users.noreply.github.com> Date: Tue, 6 Jun 2023 22:03:44 +0200 Subject: [PATCH] tests/more: test argument --from-line --- tests/by-util/test_more.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/by-util/test_more.rs b/tests/by-util/test_more.rs index 15388bbf6..d94a92185 100644 --- a/tests/by-util/test_more.rs +++ b/tests/by-util/test_more.rs @@ -45,6 +45,40 @@ fn test_invalid_arg() { } } +#[test] +fn test_argument_from_file() { + if std::io::stdout().is_terminal() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + + let file = "test_file"; + + at.write(file, "1\n2"); + + // output all lines + scene + .ucmd() + .arg("-F") + .arg("0") + .arg(file) + .succeeds() + .no_stderr() + .stdout_contains("1") + .stdout_contains("2"); + + // output only the second line + scene + .ucmd() + .arg("-F") + .arg("2") + .arg(file) + .succeeds() + .no_stderr() + .stdout_contains("2") + .stdout_does_not_contain("1"); + } +} + #[test] fn test_more_dir_arg() { // Run the test only if there's a valid terminal, else do nothing