2021-07-07 14:19:58 +00:00
|
|
|
// * 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.
|
2016-08-11 07:37:39 +00:00
|
|
|
|
2021-05-30 05:10:54 +00:00
|
|
|
// spell-checker:ignore (flags) runlevel mesg
|
|
|
|
|
2021-07-07 14:19:58 +00:00
|
|
|
use crate::common::util::*;
|
|
|
|
|
|
|
|
#[cfg(unix)]
|
2016-08-11 07:37:39 +00:00
|
|
|
#[test]
|
2022-03-06 22:46:52 +00:00
|
|
|
#[ignore = "issue #3219"]
|
2016-08-11 07:37:39 +00:00
|
|
|
fn test_count() {
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
2022-04-02 08:47:37 +00:00
|
|
|
for opt in ["-q", "--count", "--c"] {
|
2021-07-07 20:46:16 +00:00
|
|
|
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
|
|
|
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
2016-08-11 07:37:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-07 14:19:58 +00:00
|
|
|
#[cfg(unix)]
|
2016-08-11 07:37:39 +00:00
|
|
|
#[test]
|
|
|
|
fn test_boot() {
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
2022-04-02 08:47:37 +00:00
|
|
|
for opt in ["-b", "--boot", "--b"] {
|
2021-07-07 20:46:16 +00:00
|
|
|
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
|
|
|
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
2016-08-11 07:37:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-07 14:19:58 +00:00
|
|
|
#[cfg(unix)]
|
2016-08-11 07:37:39 +00:00
|
|
|
#[test]
|
2022-03-06 22:46:52 +00:00
|
|
|
#[ignore = "issue #3219"]
|
2016-08-11 07:37:39 +00:00
|
|
|
fn test_heading() {
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
2022-04-02 08:47:37 +00:00
|
|
|
for opt in ["-H", "--heading", "--head"] {
|
2020-01-01 23:07:25 +00:00
|
|
|
// allow whitespace variation
|
2021-04-28 20:58:28 +00:00
|
|
|
// * minor whitespace differences occur between platform built-in outputs;
|
|
|
|
// specifically number of TABs between "TIME" and "COMMENT" may be variant
|
2021-07-07 20:46:16 +00:00
|
|
|
let actual = ts.ucmd().arg(opt).succeeds().stdout_move_str();
|
|
|
|
let expect = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
2020-01-01 23:07:25 +00:00
|
|
|
println!("actual: {:?}", actual);
|
|
|
|
println!("expect: {:?}", expect);
|
|
|
|
let v_actual: Vec<&str> = actual.split_whitespace().collect();
|
|
|
|
let v_expect: Vec<&str> = expect.split_whitespace().collect();
|
|
|
|
assert_eq!(v_actual, v_expect);
|
2016-08-11 07:37:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-07 14:19:58 +00:00
|
|
|
#[cfg(unix)]
|
2016-08-11 07:37:39 +00:00
|
|
|
#[test]
|
2022-03-06 22:46:52 +00:00
|
|
|
#[ignore = "issue #3219"]
|
2016-08-11 07:37:39 +00:00
|
|
|
fn test_short() {
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
2022-04-02 08:47:37 +00:00
|
|
|
for opt in ["-s", "--short", "--s"] {
|
2021-07-07 20:46:16 +00:00
|
|
|
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
|
|
|
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
2016-08-11 07:37:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-07 14:19:58 +00:00
|
|
|
#[cfg(unix)]
|
2016-08-11 07:37:39 +00:00
|
|
|
#[test]
|
|
|
|
fn test_login() {
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
2022-04-02 08:47:37 +00:00
|
|
|
for opt in ["-l", "--login", "--log"] {
|
2021-07-07 20:46:16 +00:00
|
|
|
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
|
|
|
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
2016-08-11 07:37:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-07 14:19:58 +00:00
|
|
|
#[cfg(unix)]
|
2016-08-11 07:37:39 +00:00
|
|
|
#[test]
|
|
|
|
fn test_m() {
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
2022-03-11 03:31:21 +00:00
|
|
|
let expected_stdout = unwrap_or_return!(expected_result(&ts, &["-m"])).stdout_move_str();
|
|
|
|
ts.ucmd().arg("-m").succeeds().stdout_is(expected_stdout);
|
2021-04-28 20:58:28 +00:00
|
|
|
}
|
|
|
|
|
2021-07-07 14:19:58 +00:00
|
|
|
#[cfg(unix)]
|
2021-04-28 20:58:28 +00:00
|
|
|
#[test]
|
|
|
|
fn test_process() {
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
2022-04-02 08:47:37 +00:00
|
|
|
for opt in ["-p", "--process", "--p"] {
|
2021-07-07 20:46:16 +00:00
|
|
|
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
|
|
|
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
2021-04-28 20:58:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-07 14:19:58 +00:00
|
|
|
#[cfg(unix)]
|
2021-04-28 20:58:28 +00:00
|
|
|
#[test]
|
|
|
|
fn test_runlevel() {
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
2022-04-02 08:47:37 +00:00
|
|
|
for opt in ["-r", "--runlevel", "--r"] {
|
2021-07-07 20:46:16 +00:00
|
|
|
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
|
|
|
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
2021-04-28 20:58:28 +00:00
|
|
|
|
2021-05-23 00:07:32 +00:00
|
|
|
#[cfg(not(target_os = "linux"))]
|
2021-07-07 20:46:16 +00:00
|
|
|
ts.ucmd().arg(opt).succeeds().stdout_is("");
|
2021-05-20 19:09:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-07 14:19:58 +00:00
|
|
|
#[cfg(unix)]
|
2021-04-28 20:58:28 +00:00
|
|
|
#[test]
|
|
|
|
fn test_time() {
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
2022-04-02 08:47:37 +00:00
|
|
|
for opt in ["-t", "--time", "--t"] {
|
2021-07-07 20:46:16 +00:00
|
|
|
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
|
|
|
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
2021-04-28 20:58:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-07 14:19:58 +00:00
|
|
|
#[cfg(unix)]
|
2021-04-28 20:58:28 +00:00
|
|
|
#[test]
|
2022-03-06 22:46:52 +00:00
|
|
|
#[ignore = "issue #3219"]
|
2021-04-28 20:58:28 +00:00
|
|
|
fn test_mesg() {
|
who/stat/pinky: adjust tests to be compatible with running on macOS
A lot of tests depend on GNU's coreutils to be installed in order
to obtain reference values during testing.
In these cases testing is limited to `target_os = linux`.
This PR installs GNU's coreutils on "github actions" and adjusts the
tests for `who`, `stat` and `pinky` in order to be compatible with macOS.
* `brew install coreutils` (prefix is 'g', e.g. `gwho`, `gstat`, etc.
* switch paths for testing to something that's available on both OSs,
e.g. `/boot` -> `/bin`, etc.
* switch paths for testing to the macOS equivalent,
e.g. `/dev/pts/ptmx` -> `/dev/ptmx`, etc.
* exclude paths when no equivalent is available,
e.g. `/proc`, `/etc/fstab`, etc.
* refactor tests to make better use of the testing API
* fix a warning in utmpx.rs to print to stderr instead of stdout
* fix long_usage text in `who`
* fix minor output formatting in `stat`
* the `expected_result` function should be refactored
to reduce duplicate code
* more tests should be adjusted to not only run on `target_os = linux`
2021-05-20 21:11:40 +00:00
|
|
|
// -T, -w, --mesg
|
|
|
|
// add user's message status as +, - or ?
|
|
|
|
// --message
|
|
|
|
// same as -T
|
|
|
|
// --writable
|
|
|
|
// same as -T
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
2022-04-02 08:47:37 +00:00
|
|
|
for opt in [
|
2022-01-29 00:03:28 +00:00
|
|
|
"-T",
|
|
|
|
"-w",
|
|
|
|
"--mesg",
|
|
|
|
"--m",
|
|
|
|
"--message",
|
|
|
|
"--writable",
|
|
|
|
"--w",
|
|
|
|
] {
|
2021-07-07 20:46:16 +00:00
|
|
|
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
|
|
|
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
2021-04-28 20:58:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-07 14:19:58 +00:00
|
|
|
#[cfg(unix)]
|
2021-04-28 20:58:28 +00:00
|
|
|
#[test]
|
|
|
|
fn test_arg1_arg2() {
|
who/stat/pinky: adjust tests to be compatible with running on macOS
A lot of tests depend on GNU's coreutils to be installed in order
to obtain reference values during testing.
In these cases testing is limited to `target_os = linux`.
This PR installs GNU's coreutils on "github actions" and adjusts the
tests for `who`, `stat` and `pinky` in order to be compatible with macOS.
* `brew install coreutils` (prefix is 'g', e.g. `gwho`, `gstat`, etc.
* switch paths for testing to something that's available on both OSs,
e.g. `/boot` -> `/bin`, etc.
* switch paths for testing to the macOS equivalent,
e.g. `/dev/pts/ptmx` -> `/dev/ptmx`, etc.
* exclude paths when no equivalent is available,
e.g. `/proc`, `/etc/fstab`, etc.
* refactor tests to make better use of the testing API
* fix a warning in utmpx.rs to print to stderr instead of stdout
* fix long_usage text in `who`
* fix minor output formatting in `stat`
* the `expected_result` function should be refactored
to reduce duplicate code
* more tests should be adjusted to not only run on `target_os = linux`
2021-05-20 21:11:40 +00:00
|
|
|
let args = ["am", "i"];
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
|
|
|
let expected_stdout = unwrap_or_return!(expected_result(&ts, &args)).stdout_move_str();
|
|
|
|
ts.ucmd().args(&args).succeeds().stdout_is(expected_stdout);
|
2021-04-28 20:58:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_too_many_args() {
|
who/stat/pinky: adjust tests to be compatible with running on macOS
A lot of tests depend on GNU's coreutils to be installed in order
to obtain reference values during testing.
In these cases testing is limited to `target_os = linux`.
This PR installs GNU's coreutils on "github actions" and adjusts the
tests for `who`, `stat` and `pinky` in order to be compatible with macOS.
* `brew install coreutils` (prefix is 'g', e.g. `gwho`, `gstat`, etc.
* switch paths for testing to something that's available on both OSs,
e.g. `/boot` -> `/bin`, etc.
* switch paths for testing to the macOS equivalent,
e.g. `/dev/pts/ptmx` -> `/dev/ptmx`, etc.
* exclude paths when no equivalent is available,
e.g. `/proc`, `/etc/fstab`, etc.
* refactor tests to make better use of the testing API
* fix a warning in utmpx.rs to print to stderr instead of stdout
* fix long_usage text in `who`
* fix minor output formatting in `stat`
* the `expected_result` function should be refactored
to reduce duplicate code
* more tests should be adjusted to not only run on `target_os = linux`
2021-05-20 21:11:40 +00:00
|
|
|
const EXPECTED: &str =
|
2022-01-11 14:22:12 +00:00
|
|
|
"error: The value 'u' was provided to '<FILE>...' but it wasn't expecting any more values";
|
2021-04-28 20:58:28 +00:00
|
|
|
|
who/stat/pinky: adjust tests to be compatible with running on macOS
A lot of tests depend on GNU's coreutils to be installed in order
to obtain reference values during testing.
In these cases testing is limited to `target_os = linux`.
This PR installs GNU's coreutils on "github actions" and adjusts the
tests for `who`, `stat` and `pinky` in order to be compatible with macOS.
* `brew install coreutils` (prefix is 'g', e.g. `gwho`, `gstat`, etc.
* switch paths for testing to something that's available on both OSs,
e.g. `/boot` -> `/bin`, etc.
* switch paths for testing to the macOS equivalent,
e.g. `/dev/pts/ptmx` -> `/dev/ptmx`, etc.
* exclude paths when no equivalent is available,
e.g. `/proc`, `/etc/fstab`, etc.
* refactor tests to make better use of the testing API
* fix a warning in utmpx.rs to print to stderr instead of stdout
* fix long_usage text in `who`
* fix minor output formatting in `stat`
* the `expected_result` function should be refactored
to reduce duplicate code
* more tests should be adjusted to not only run on `target_os = linux`
2021-05-20 21:11:40 +00:00
|
|
|
let args = ["am", "i", "u"];
|
|
|
|
new_ucmd!().args(&args).fails().stderr_contains(EXPECTED);
|
2021-04-28 20:58:28 +00:00
|
|
|
}
|
|
|
|
|
2021-07-07 14:19:58 +00:00
|
|
|
#[cfg(unix)]
|
2021-04-28 20:58:28 +00:00
|
|
|
#[test]
|
2022-03-06 22:46:52 +00:00
|
|
|
#[ignore = "issue #3219"]
|
2021-04-28 20:58:28 +00:00
|
|
|
fn test_users() {
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
2022-04-02 08:47:37 +00:00
|
|
|
for opt in ["-u", "--users", "--us"] {
|
2021-07-07 20:46:16 +00:00
|
|
|
let actual = ts.ucmd().arg(opt).succeeds().stdout_move_str();
|
|
|
|
let expect = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
who/stat/pinky: adjust tests to be compatible with running on macOS
A lot of tests depend on GNU's coreutils to be installed in order
to obtain reference values during testing.
In these cases testing is limited to `target_os = linux`.
This PR installs GNU's coreutils on "github actions" and adjusts the
tests for `who`, `stat` and `pinky` in order to be compatible with macOS.
* `brew install coreutils` (prefix is 'g', e.g. `gwho`, `gstat`, etc.
* switch paths for testing to something that's available on both OSs,
e.g. `/boot` -> `/bin`, etc.
* switch paths for testing to the macOS equivalent,
e.g. `/dev/pts/ptmx` -> `/dev/ptmx`, etc.
* exclude paths when no equivalent is available,
e.g. `/proc`, `/etc/fstab`, etc.
* refactor tests to make better use of the testing API
* fix a warning in utmpx.rs to print to stderr instead of stdout
* fix long_usage text in `who`
* fix minor output formatting in `stat`
* the `expected_result` function should be refactored
to reduce duplicate code
* more tests should be adjusted to not only run on `target_os = linux`
2021-05-20 21:11:40 +00:00
|
|
|
println!("actual: {:?}", actual);
|
|
|
|
println!("expect: {:?}", expect);
|
|
|
|
|
|
|
|
let mut v_actual: Vec<&str> = actual.split_whitespace().collect();
|
|
|
|
let mut v_expect: Vec<&str> = expect.split_whitespace().collect();
|
|
|
|
|
2021-06-21 22:22:30 +00:00
|
|
|
// TODO: `--users` sometimes differs from GNU's output on macOS (race condition?)
|
|
|
|
// actual: "runner console Jun 23 06:37 00:34 196\n"
|
|
|
|
// expect: "runner console Jun 23 06:37 old 196\n"
|
2021-05-23 00:07:32 +00:00
|
|
|
if cfg!(target_os = "macos") {
|
2021-06-21 22:22:30 +00:00
|
|
|
v_actual.remove(5);
|
|
|
|
v_expect.remove(5);
|
who/stat/pinky: adjust tests to be compatible with running on macOS
A lot of tests depend on GNU's coreutils to be installed in order
to obtain reference values during testing.
In these cases testing is limited to `target_os = linux`.
This PR installs GNU's coreutils on "github actions" and adjusts the
tests for `who`, `stat` and `pinky` in order to be compatible with macOS.
* `brew install coreutils` (prefix is 'g', e.g. `gwho`, `gstat`, etc.
* switch paths for testing to something that's available on both OSs,
e.g. `/boot` -> `/bin`, etc.
* switch paths for testing to the macOS equivalent,
e.g. `/dev/pts/ptmx` -> `/dev/ptmx`, etc.
* exclude paths when no equivalent is available,
e.g. `/proc`, `/etc/fstab`, etc.
* refactor tests to make better use of the testing API
* fix a warning in utmpx.rs to print to stderr instead of stdout
* fix long_usage text in `who`
* fix minor output formatting in `stat`
* the `expected_result` function should be refactored
to reduce duplicate code
* more tests should be adjusted to not only run on `target_os = linux`
2021-05-20 21:11:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
assert_eq!(v_actual, v_expect);
|
2021-04-28 20:58:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-07 14:19:58 +00:00
|
|
|
#[cfg(unix)]
|
2021-04-28 20:58:28 +00:00
|
|
|
#[test]
|
2022-03-06 22:46:52 +00:00
|
|
|
#[ignore = "issue #3219"]
|
2021-04-28 20:58:28 +00:00
|
|
|
fn test_lookup() {
|
2021-05-29 12:32:35 +00:00
|
|
|
let opt = "--lookup";
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
|
|
|
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
|
|
|
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
2016-08-11 07:37:39 +00:00
|
|
|
}
|
|
|
|
|
2021-07-07 14:19:58 +00:00
|
|
|
#[cfg(unix)]
|
2016-08-11 07:37:39 +00:00
|
|
|
#[test]
|
|
|
|
fn test_dead() {
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
2022-04-02 08:47:37 +00:00
|
|
|
for opt in ["-d", "--dead", "--de"] {
|
2021-07-07 20:46:16 +00:00
|
|
|
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
|
|
|
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
2016-08-11 07:37:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-07 14:19:58 +00:00
|
|
|
#[cfg(unix)]
|
2021-04-28 20:58:28 +00:00
|
|
|
#[test]
|
2022-03-06 22:46:52 +00:00
|
|
|
#[ignore = "issue #3219"]
|
2021-04-28 20:58:28 +00:00
|
|
|
fn test_all_separately() {
|
2021-05-23 00:07:32 +00:00
|
|
|
if cfg!(target_os = "macos") {
|
who/stat/pinky: adjust tests to be compatible with running on macOS
A lot of tests depend on GNU's coreutils to be installed in order
to obtain reference values during testing.
In these cases testing is limited to `target_os = linux`.
This PR installs GNU's coreutils on "github actions" and adjusts the
tests for `who`, `stat` and `pinky` in order to be compatible with macOS.
* `brew install coreutils` (prefix is 'g', e.g. `gwho`, `gstat`, etc.
* switch paths for testing to something that's available on both OSs,
e.g. `/boot` -> `/bin`, etc.
* switch paths for testing to the macOS equivalent,
e.g. `/dev/pts/ptmx` -> `/dev/ptmx`, etc.
* exclude paths when no equivalent is available,
e.g. `/proc`, `/etc/fstab`, etc.
* refactor tests to make better use of the testing API
* fix a warning in utmpx.rs to print to stderr instead of stdout
* fix long_usage text in `who`
* fix minor output formatting in `stat`
* the `expected_result` function should be refactored
to reduce duplicate code
* more tests should be adjusted to not only run on `target_os = linux`
2021-05-20 21:11:40 +00:00
|
|
|
// TODO: fix `-u`, see: test_users
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-04-28 20:58:28 +00:00
|
|
|
// -a, --all same as -b -d --login -p -r -t -T -u
|
who/stat/pinky: adjust tests to be compatible with running on macOS
A lot of tests depend on GNU's coreutils to be installed in order
to obtain reference values during testing.
In these cases testing is limited to `target_os = linux`.
This PR installs GNU's coreutils on "github actions" and adjusts the
tests for `who`, `stat` and `pinky` in order to be compatible with macOS.
* `brew install coreutils` (prefix is 'g', e.g. `gwho`, `gstat`, etc.
* switch paths for testing to something that's available on both OSs,
e.g. `/boot` -> `/bin`, etc.
* switch paths for testing to the macOS equivalent,
e.g. `/dev/pts/ptmx` -> `/dev/ptmx`, etc.
* exclude paths when no equivalent is available,
e.g. `/proc`, `/etc/fstab`, etc.
* refactor tests to make better use of the testing API
* fix a warning in utmpx.rs to print to stderr instead of stdout
* fix long_usage text in `who`
* fix minor output formatting in `stat`
* the `expected_result` function should be refactored
to reduce duplicate code
* more tests should be adjusted to not only run on `target_os = linux`
2021-05-20 21:11:40 +00:00
|
|
|
let args = ["-b", "-d", "--login", "-p", "-r", "-t", "-T", "-u"];
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
|
|
|
let expected_stdout = unwrap_or_return!(expected_result(&ts, &args)).stdout_move_str();
|
|
|
|
ts.ucmd().args(&args).succeeds().stdout_is(expected_stdout);
|
|
|
|
let expected_stdout = unwrap_or_return!(expected_result(&ts, &["--all"])).stdout_move_str();
|
|
|
|
ts.ucmd().arg("--all").succeeds().stdout_is(expected_stdout);
|
2021-04-28 20:58:28 +00:00
|
|
|
}
|
|
|
|
|
2021-07-07 14:19:58 +00:00
|
|
|
#[cfg(unix)]
|
2016-08-11 07:37:39 +00:00
|
|
|
#[test]
|
2022-03-06 22:46:52 +00:00
|
|
|
#[ignore = "issue #3219"]
|
2016-08-11 07:37:39 +00:00
|
|
|
fn test_all() {
|
2021-05-23 00:07:32 +00:00
|
|
|
if cfg!(target_os = "macos") {
|
who/stat/pinky: adjust tests to be compatible with running on macOS
A lot of tests depend on GNU's coreutils to be installed in order
to obtain reference values during testing.
In these cases testing is limited to `target_os = linux`.
This PR installs GNU's coreutils on "github actions" and adjusts the
tests for `who`, `stat` and `pinky` in order to be compatible with macOS.
* `brew install coreutils` (prefix is 'g', e.g. `gwho`, `gstat`, etc.
* switch paths for testing to something that's available on both OSs,
e.g. `/boot` -> `/bin`, etc.
* switch paths for testing to the macOS equivalent,
e.g. `/dev/pts/ptmx` -> `/dev/ptmx`, etc.
* exclude paths when no equivalent is available,
e.g. `/proc`, `/etc/fstab`, etc.
* refactor tests to make better use of the testing API
* fix a warning in utmpx.rs to print to stderr instead of stdout
* fix long_usage text in `who`
* fix minor output formatting in `stat`
* the `expected_result` function should be refactored
to reduce duplicate code
* more tests should be adjusted to not only run on `target_os = linux`
2021-05-20 21:11:40 +00:00
|
|
|
// TODO: fix `-u`, see: test_users
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
2022-04-02 08:47:37 +00:00
|
|
|
for opt in ["-a", "--all", "--a"] {
|
2021-07-07 20:46:16 +00:00
|
|
|
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
|
|
|
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
2016-08-11 07:37:39 +00:00
|
|
|
}
|
|
|
|
}
|