1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2026-01-17 18:51:05 +00:00
uutils-coreutils/tests/by-util/test_stty.rs
Sylvestre Ledru 18cb7dcf9e Use the new function fails_with_code
Done with
```
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)[ \t]*\n[ \t]+\.no_stdout\(\)[ \t]*\n[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\2)\n\1.no_stdout();/gs' *rs
$ sed -i -e "s|.fails()(.*).code_is(|.fails_with_code(|g" *rs
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)[ \t]*\n[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\2);/gs' *rs
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)(.*?)[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\3)\2;/gs' *rs
...
```
2025-03-01 17:26:20 +01:00

64 lines
1.6 KiB
Rust

// This file is part of the uutils coreutils package.
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
// spell-checker:ignore parenb parmrk ixany iuclc onlcr ofdel icanon noflsh
use crate::common::util::TestScenario;
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
}
#[test]
#[ignore = "Fails because cargo test does not run in a tty"]
fn runs() {
new_ucmd!().succeeds();
}
#[test]
#[ignore = "Fails because cargo test does not run in a tty"]
fn print_all() {
let res = new_ucmd!().succeeds();
// Random selection of flags to check for
for flag in [
"parenb", "parmrk", "ixany", "iuclc", "onlcr", "ofdel", "icanon", "noflsh",
] {
res.stdout_contains(flag);
}
}
#[test]
fn save_and_setting() {
new_ucmd!()
.args(&["--save", "nl0"])
.fails()
.stderr_contains("when specifying an output style, modes may not be set");
}
#[test]
fn all_and_setting() {
new_ucmd!()
.args(&["--all", "nl0"])
.fails()
.stderr_contains("when specifying an output style, modes may not be set");
}
#[test]
fn save_and_all() {
new_ucmd!()
.args(&["--save", "--all"])
.fails()
.stderr_contains(
"the options for verbose and stty-readable output styles are mutually exclusive",
);
new_ucmd!()
.args(&["--all", "--save"])
.fails()
.stderr_contains(
"the options for verbose and stty-readable output styles are mutually exclusive",
);
}