2020-05-25 17:05:26 +00:00
|
|
|
use crate::common::util::*;
|
2016-08-11 07:37:39 +00:00
|
|
|
|
2021-05-30 05:10:54 +00:00
|
|
|
// spell-checker:ignore (flags) runlevel 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
|
|
|
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
2016-08-11 07:37:39 +00:00
|
|
|
#[test]
|
|
|
|
fn test_count() {
|
2021-05-29 12:32:35 +00:00
|
|
|
for opt in &["-q", "--count"] {
|
2021-04-28 20:58:28 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.arg(opt)
|
|
|
|
.succeeds()
|
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
|
|
|
.stdout_is(expected_result(&[opt]));
|
2016-08-11 07:37:39 +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
|
|
|
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
2016-08-11 07:37:39 +00:00
|
|
|
#[test]
|
|
|
|
fn test_boot() {
|
2021-05-29 12:32:35 +00:00
|
|
|
for opt in &["-b", "--boot"] {
|
2021-04-28 20:58:28 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.arg(opt)
|
|
|
|
.succeeds()
|
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
|
|
|
.stdout_is(expected_result(&[opt]));
|
2016-08-11 07:37:39 +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
|
|
|
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
2016-08-11 07:37:39 +00:00
|
|
|
#[test]
|
|
|
|
fn test_heading() {
|
2021-05-29 12:32:35 +00:00
|
|
|
for opt in &["-H", "--heading"] {
|
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
|
|
|
|
let actual = new_ucmd!().arg(opt).succeeds().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
|
|
|
let expect = expected_result(&[opt]);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
2016-08-11 07:37:39 +00:00
|
|
|
#[test]
|
|
|
|
fn test_short() {
|
2021-05-29 12:32:35 +00:00
|
|
|
for opt in &["-s", "--short"] {
|
2021-04-28 20:58:28 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.arg(opt)
|
|
|
|
.succeeds()
|
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
|
|
|
.stdout_is(expected_result(&[opt]));
|
2016-08-11 07:37:39 +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
|
|
|
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
2016-08-11 07:37:39 +00:00
|
|
|
#[test]
|
|
|
|
fn test_login() {
|
2021-05-29 12:32:35 +00:00
|
|
|
for opt in &["-l", "--login"] {
|
2021-04-28 20:58:28 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.arg(opt)
|
|
|
|
.succeeds()
|
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
|
|
|
.stdout_is(expected_result(&[opt]));
|
2016-08-11 07:37:39 +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
|
|
|
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
2016-08-11 07:37:39 +00:00
|
|
|
#[test]
|
|
|
|
fn test_m() {
|
2021-05-29 12:32:35 +00:00
|
|
|
for opt in &["-m"] {
|
2021-04-28 20:58:28 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.arg(opt)
|
|
|
|
.succeeds()
|
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
|
|
|
.stdout_is(expected_result(&[opt]));
|
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
|
|
|
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
2021-04-28 20:58:28 +00:00
|
|
|
#[test]
|
|
|
|
fn test_process() {
|
2021-05-29 12:32:35 +00:00
|
|
|
for opt in &["-p", "--process"] {
|
2021-04-28 20:58:28 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.arg(opt)
|
|
|
|
.succeeds()
|
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
|
|
|
.stdout_is(expected_result(&[opt]));
|
2021-04-28 20:58:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_runlevel() {
|
2021-05-29 12:32:35 +00:00
|
|
|
for opt in &["-r", "--runlevel"] {
|
2021-05-23 00:07:32 +00:00
|
|
|
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
2021-04-28 20:58:28 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.arg(opt)
|
|
|
|
.succeeds()
|
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
|
|
|
.stdout_is(expected_result(&[opt]));
|
2021-04-28 20:58:28 +00:00
|
|
|
|
2021-05-23 00:07:32 +00:00
|
|
|
#[cfg(not(target_os = "linux"))]
|
|
|
|
new_ucmd!().arg(opt).succeeds().stdout_is("");
|
2021-05-20 19:09:41 +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
|
|
|
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
2021-04-28 20:58:28 +00:00
|
|
|
#[test]
|
|
|
|
fn test_time() {
|
2021-05-29 12:32:35 +00:00
|
|
|
for opt in &["-t", "--time"] {
|
2021-04-28 20:58:28 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.arg(opt)
|
|
|
|
.succeeds()
|
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
|
|
|
.stdout_is(expected_result(&[opt]));
|
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
|
|
|
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
2021-04-28 20:58:28 +00:00
|
|
|
#[test]
|
|
|
|
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-05-29 12:32:35 +00:00
|
|
|
for opt in &["-T", "-w", "--mesg", "--message", "--writable"] {
|
2021-04-28 20:58:28 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.arg(opt)
|
|
|
|
.succeeds()
|
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
|
|
|
.stdout_is(expected_result(&[opt]));
|
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-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
|
|
|
new_ucmd!()
|
|
|
|
.args(&args)
|
2021-04-28 20:58:28 +00:00
|
|
|
.succeeds()
|
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
|
|
|
.stdout_is(expected_result(&args));
|
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 =
|
2021-04-28 22:11:21 +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
|
|
|
}
|
|
|
|
|
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
|
|
|
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
2021-04-28 20:58:28 +00:00
|
|
|
#[test]
|
|
|
|
fn test_users() {
|
2021-05-29 12:32:35 +00:00
|
|
|
for opt in &["-u", "--users"] {
|
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 actual = new_ucmd!().arg(opt).succeeds().stdout_move_str();
|
|
|
|
let expect = expected_result(&[opt]);
|
|
|
|
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-05-23 00:07:32 +00:00
|
|
|
// TODO: `--users` differs from GNU's output on 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
|
|
|
// Diff < left / right > :
|
|
|
|
// <"runner console 2021-05-20 22:03 00:08 196\n"
|
|
|
|
// >"runner console 2021-05-20 22:03 old 196\n"
|
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
|
|
|
v_actual.remove(4);
|
|
|
|
v_expect.remove(4);
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_eq!(v_actual, v_expect);
|
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
|
|
|
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
2021-04-28 20:58:28 +00:00
|
|
|
#[test]
|
|
|
|
fn test_lookup() {
|
2021-05-29 12:32:35 +00:00
|
|
|
let opt = "--lookup";
|
|
|
|
new_ucmd!()
|
|
|
|
.arg(opt)
|
|
|
|
.succeeds()
|
|
|
|
.stdout_is(expected_result(&[opt]));
|
2016-08-11 07:37:39 +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
|
|
|
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
2016-08-11 07:37:39 +00:00
|
|
|
#[test]
|
|
|
|
fn test_dead() {
|
2021-05-29 12:32:35 +00:00
|
|
|
for opt in &["-d", "--dead"] {
|
2021-04-28 20:58:28 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.arg(opt)
|
|
|
|
.succeeds()
|
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
|
|
|
.stdout_is(expected_result(&[opt]));
|
2016-08-11 07:37:39 +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
|
|
|
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
2021-04-28 20:58:28 +00:00
|
|
|
#[test]
|
|
|
|
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-04-28 20:58:28 +00:00
|
|
|
let scene = TestScenario::new(util_name!());
|
|
|
|
scene
|
|
|
|
.ucmd()
|
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
|
|
|
.args(&args)
|
2021-04-28 20:58:28 +00:00
|
|
|
.succeeds()
|
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
|
|
|
.stdout_is(expected_result(&args));
|
2021-04-28 20:58:28 +00:00
|
|
|
scene
|
|
|
|
.ucmd()
|
|
|
|
.arg("--all")
|
|
|
|
.succeeds()
|
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
|
|
|
.stdout_is(expected_result(&args));
|
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
|
|
|
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
2016-08-11 07:37:39 +00:00
|
|
|
#[test]
|
|
|
|
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-05-29 12:32:35 +00:00
|
|
|
for opt in &["-a", "--all"] {
|
2021-04-28 20:58:28 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.arg(opt)
|
|
|
|
.succeeds()
|
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
|
|
|
.stdout_is(expected_result(&[opt]));
|
2016-08-11 07:37:39 +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
|
|
|
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
|
|
|
fn expected_result(args: &[&str]) -> String {
|
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
let util_name = util_name!();
|
|
|
|
#[cfg(target_vendor = "apple")]
|
|
|
|
let util_name = format!("g{}", util_name!());
|
|
|
|
|
|
|
|
TestScenario::new(&util_name)
|
|
|
|
.cmd_keepenv(util_name)
|
2020-04-13 18:36:03 +00:00
|
|
|
.env("LANGUAGE", "C")
|
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
|
|
|
.args(args)
|
2021-04-28 20:58:28 +00:00
|
|
|
.succeeds()
|
2021-04-22 20:37:44 +00:00
|
|
|
.stdout_move_str()
|
2016-08-11 07:37:39 +00:00
|
|
|
}
|