|
2 | 2 | // |
3 | 3 | // For the full copyright and license information, please view the LICENSE |
4 | 4 | // file that was distributed with this source code. |
5 | | -// spell-checker:ignore parenb parmrk ixany iuclc onlcr ofdel icanon noflsh econl igpar ispeed ospeed |
| 5 | +// spell-checker:ignore parenb parmrk ixany iuclc onlcr icanon noflsh econl igpar ispeed ospeed |
6 | 6 |
|
7 | 7 | use uutests::new_ucmd; |
| 8 | +use uutests::util::pty_path; |
8 | 9 |
|
9 | 10 | #[test] |
10 | 11 | fn test_invalid_arg() { |
11 | 12 | new_ucmd!().arg("--definitely-invalid").fails_with_code(1); |
12 | 13 | } |
13 | 14 |
|
14 | 15 | #[test] |
15 | | -#[ignore = "Fails because cargo test does not run in a tty"] |
16 | | -fn runs() { |
17 | | - new_ucmd!().succeeds(); |
| 16 | +#[cfg(unix)] |
| 17 | +fn test_basic() { |
| 18 | + let (path, _controller, _replica) = pty_path(); |
| 19 | + new_ucmd!() |
| 20 | + .args(&["--file", &path]) |
| 21 | + .succeeds() |
| 22 | + .stdout_contains("speed"); |
18 | 23 | } |
19 | 24 |
|
20 | 25 | #[test] |
21 | | -#[ignore = "Fails because cargo test does not run in a tty"] |
22 | | -fn print_all() { |
23 | | - let res = new_ucmd!().args(&["--all"]).succeeds(); |
24 | | - |
25 | | - // Random selection of flags to check for |
26 | | - for flag in [ |
27 | | - "parenb", "parmrk", "ixany", "onlcr", "ofdel", "icanon", "noflsh", |
28 | | - ] { |
29 | | - res.stdout_contains(flag); |
| 26 | +#[cfg(unix)] |
| 27 | +fn test_all_flag() { |
| 28 | + let (path, _controller, _replica) = pty_path(); |
| 29 | + let result = new_ucmd!().args(&["--all", "--file", &path]).succeeds(); |
| 30 | + |
| 31 | + for flag in ["parenb", "parmrk", "ixany", "onlcr", "icanon", "noflsh"] { |
| 32 | + result.stdout_contains(flag); |
30 | 33 | } |
31 | 34 | } |
32 | 35 |
|
33 | 36 | #[test] |
34 | | -#[ignore = "Fails because cargo test does not run in a tty"] |
35 | | -fn sane_settings() { |
36 | | - new_ucmd!().args(&["intr", "^A"]).succeeds(); |
37 | | - new_ucmd!().succeeds().stdout_contains("intr = ^A"); |
| 37 | +#[cfg(unix)] |
| 38 | +fn test_sane() { |
| 39 | + let (path, _controller, _replica) = pty_path(); |
| 40 | + |
| 41 | + new_ucmd!() |
| 42 | + .args(&["--file", &path, "intr", "^A"]) |
| 43 | + .succeeds(); |
| 44 | + new_ucmd!() |
| 45 | + .args(&["--file", &path]) |
| 46 | + .succeeds() |
| 47 | + .stdout_contains("intr = ^A"); |
| 48 | + new_ucmd!().args(&["--file", &path, "sane"]).succeeds(); |
38 | 49 | new_ucmd!() |
39 | | - .args(&["sane"]) |
| 50 | + .args(&["--file", &path]) |
40 | 51 | .succeeds() |
41 | 52 | .stdout_str_check(|s| !s.contains("intr = ^A")); |
42 | 53 | } |
|
0 commit comments