Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/more: run all tests with terminal_simulation #6121

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 123 additions & 19 deletions tests/by-util/test_more.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
#[test]
fn test_more_no_arg() {
if std::io::stdout().is_terminal() {
new_ucmd!().fails().stderr_contains("more: bad usage");
new_ucmd!()

Check warning on line 11 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L11

Added line #L11 was not covered by tests
.terminal_simulation(true)
.fails()
.stderr_contains("more: bad usage");

Check warning on line 14 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L14

Added line #L14 was not covered by tests
}
}

Expand All @@ -21,44 +24,136 @@
let file = "test_file";
at.touch(file);

scene.ucmd().arg(file).arg("-c").succeeds();
scene.ucmd().arg(file).arg("--print-over").succeeds();
scene

Check warning on line 27 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L27

Added line #L27 was not covered by tests
.ucmd()
.terminal_simulation(true)
.arg(file)
.arg("-c")
.succeeds();
scene

Check warning on line 33 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L32-L33

Added lines #L32 - L33 were not covered by tests
.ucmd()
.terminal_simulation(true)
.arg(file)
.arg("--print-over")
.succeeds();

Check warning on line 38 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L38

Added line #L38 was not covered by tests

scene.ucmd().arg(file).arg("-p").succeeds();
scene.ucmd().arg(file).arg("--clean-print").succeeds();
scene

Check warning on line 40 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L40

Added line #L40 was not covered by tests
.ucmd()
.terminal_simulation(true)
.arg(file)
.arg("-p")
.succeeds();
scene

Check warning on line 46 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L45-L46

Added lines #L45 - L46 were not covered by tests
.ucmd()
.terminal_simulation(true)
.arg(file)
.arg("--clean-print")
.succeeds();

Check warning on line 51 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L51

Added line #L51 was not covered by tests

scene.ucmd().arg(file).arg("-s").succeeds();
scene.ucmd().arg(file).arg("--squeeze").succeeds();
scene

Check warning on line 53 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L53

Added line #L53 was not covered by tests
.ucmd()
.terminal_simulation(true)
.arg(file)
.arg("-s")
.succeeds();
scene

Check warning on line 59 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L58-L59

Added lines #L58 - L59 were not covered by tests
.ucmd()
.terminal_simulation(true)
.arg(file)
.arg("--squeeze")
.succeeds();

Check warning on line 64 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L64

Added line #L64 was not covered by tests

scene.ucmd().arg(file).arg("-u").succeeds();
scene.ucmd().arg(file).arg("--plain").succeeds();
scene

Check warning on line 66 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L66

Added line #L66 was not covered by tests
.ucmd()
.terminal_simulation(true)
.arg(file)
.arg("-u")
.succeeds();
scene

Check warning on line 72 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L71-L72

Added lines #L71 - L72 were not covered by tests
.ucmd()
.terminal_simulation(true)
.arg(file)

Check warning on line 75 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L75

Added line #L75 was not covered by tests
.arg("--plain")
.succeeds();

Check warning on line 77 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L77

Added line #L77 was not covered by tests

scene.ucmd().arg(file).arg("-n").arg("10").succeeds();
scene.ucmd().arg(file).arg("--lines").arg("0").succeeds();
scene.ucmd().arg(file).arg("--number").arg("0").succeeds();
scene

Check warning on line 79 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L79

Added line #L79 was not covered by tests
.ucmd()
.terminal_simulation(true)
.arg(file)
.arg("-n")
.arg("10")
.succeeds();
scene

Check warning on line 86 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L85-L86

Added lines #L85 - L86 were not covered by tests
.ucmd()
.terminal_simulation(true)
.arg(file)
.arg("--lines")
.arg("0")
.succeeds();
scene

Check warning on line 93 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L92-L93

Added lines #L92 - L93 were not covered by tests
.ucmd()
.terminal_simulation(true)
.arg(file)
.arg("--number")
.arg("0")
.succeeds();

Check warning on line 99 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L99

Added line #L99 was not covered by tests

scene.ucmd().arg(file).arg("-F").arg("10").succeeds();
scene
.ucmd()
.terminal_simulation(true)
.arg(file)
.arg("-F")
.arg("10")
.succeeds();
scene

Check warning on line 108 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L107-L108

Added lines #L107 - L108 were not covered by tests
.ucmd()
.terminal_simulation(true)
.arg(file)
.arg("--from-line")
.arg("0")
.succeeds();

scene.ucmd().arg(file).arg("-P").arg("something").succeeds();
scene.ucmd().arg(file).arg("--pattern").arg("-1").succeeds();
scene

Check warning on line 116 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L116

Added line #L116 was not covered by tests
.ucmd()
.terminal_simulation(true)
.arg(file)
.arg("-P")
.arg("something")
.succeeds();
scene

Check warning on line 123 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L122-L123

Added lines #L122 - L123 were not covered by tests
.ucmd()
.terminal_simulation(true)
.arg(file)
.arg("--pattern")
.arg("-1")
.succeeds();

Check warning on line 129 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L129

Added line #L129 was not covered by tests
}
}

#[test]
fn test_invalid_arg() {
if std::io::stdout().is_terminal() {
new_ucmd!().arg("--invalid").fails();
new_ucmd!()

Check warning on line 136 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L136

Added line #L136 was not covered by tests
.terminal_simulation(true)
.arg("--invalid")
.fails();

Check warning on line 139 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L139

Added line #L139 was not covered by tests

new_ucmd!().arg("--lines").arg("-10").fails();
new_ucmd!().arg("--number").arg("-10").fails();
new_ucmd!()

Check warning on line 141 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L141

Added line #L141 was not covered by tests
.terminal_simulation(true)
.arg("--lines")
.arg("-10")
.fails();
new_ucmd!()

Check warning on line 146 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L145-L146

Added lines #L145 - L146 were not covered by tests
.terminal_simulation(true)
.arg("--number")
.arg("-10")
.fails();

Check warning on line 150 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L150

Added line #L150 was not covered by tests

new_ucmd!().arg("--from-line").arg("-10").fails();
new_ucmd!()

Check warning on line 152 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L152

Added line #L152 was not covered by tests
.terminal_simulation(true)
.arg("--from-line")
.arg("-10")
.fails();

Check warning on line 156 in tests/by-util/test_more.rs

View check run for this annotation

Codecov / codecov/patch

tests/by-util/test_more.rs#L156

Added line #L156 was not covered by tests
}
}

Expand All @@ -75,6 +170,7 @@
// output all lines
scene
.ucmd()
.terminal_simulation(true)
.arg("-F")
.arg("0")
.arg(file)
Expand All @@ -86,6 +182,7 @@
// output only the second line
scene
.ucmd()
.terminal_simulation(true)
.arg("-F")
.arg("2")
.arg(file)
Expand All @@ -103,6 +200,7 @@
// but I am leaving this for later
if std::io::stdout().is_terminal() {
new_ucmd!()
.terminal_simulation(true)
.arg(".")
.succeeds()
.stderr_contains("'.' is a directory.");
Expand All @@ -121,6 +219,7 @@
at.make_file("invalid-perms.txt");
set_permissions(at.plus("invalid-perms.txt"), permissions).unwrap();
ucmd.arg("invalid-perms.txt")
.terminal_simulation(true)
.succeeds()
.stderr_contains("permission denied");
}
Expand All @@ -132,10 +231,12 @@
let ts = TestScenario::new("more");
ts.fixtures.mkdir_all("folder");
ts.ucmd()
.terminal_simulation(true)
.arg("folder")
.succeeds()
.stderr_contains("is a directory");
ts.ucmd()
.terminal_simulation(true)
.arg("file1")
.succeeds()
.stderr_contains("No such file or directory");
Expand All @@ -149,6 +250,7 @@
ts.fixtures.mkdir_all("folder");
ts.fixtures.make_file("file1");
ts.ucmd()
.terminal_simulation(true)
.arg("folder")
.arg("file2")
.arg("file1")
Expand Down Expand Up @@ -178,6 +280,7 @@
// output only the second line "line2"
scene
.ucmd()
.terminal_simulation(true)
.arg("-P")
.arg("line2")
.arg(file)
Expand All @@ -201,6 +304,7 @@

scene
.ucmd()
.terminal_simulation(true)
.arg("-P")
.arg("something")
.arg(file)
Expand Down
Loading