mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
pinky: improve tests
This commit is contained in:
parent
9430a9f355
commit
f52f655934
2 changed files with 38 additions and 12 deletions
41
.github/workflows/CICD.yml
vendored
41
.github/workflows/CICD.yml
vendored
|
@ -600,17 +600,6 @@ jobs:
|
|||
*-pc-windows-msvc) STRIP="" ;;
|
||||
esac;
|
||||
outputs STRIP
|
||||
- name: Install/setup prerequisites
|
||||
shell: bash
|
||||
run: |
|
||||
## Install/setup prerequisites
|
||||
case '${{ matrix.job.target }}' in
|
||||
arm-unknown-linux-gnueabihf) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
|
||||
aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
|
||||
esac
|
||||
case '${{ matrix.job.os }}' in
|
||||
macos-latest) brew install coreutils ;; # needed for testing
|
||||
esac
|
||||
- name: Create all needed build/work directories
|
||||
shell: bash
|
||||
run: |
|
||||
|
@ -629,6 +618,21 @@ jobs:
|
|||
case '${{ matrix.job.os }}' in
|
||||
macos-latest) brew install coreutils ;; # needed for testing
|
||||
esac
|
||||
case '${{ matrix.job.os }}' in
|
||||
ubuntu-*)
|
||||
# pinky is a tool to show logged-in users from utmp, and gecos fields from /etc/passwd.
|
||||
# In GitHub Action *nix VMs, no accounts log in, even the "runner" account that runs the commands. The account also has empty gecos fields.
|
||||
# To work around this for pinky tests, we create a fake login entry for the GH runner account...
|
||||
FAKE_UTMP='[7] [999999] [tty2] [runner] [tty2] [] [0.0.0.0] [2022-02-22T22:22:22,222222+00:00]'
|
||||
# ... by dumping the login records, adding our fake line, then reverse dumping ...
|
||||
(utmpdump /var/run/utmp ; echo $FAKE_UTMP) | sudo utmpdump -r -o /var/run/utmp
|
||||
# ... and add a full name to each account with a gecos field but no full name.
|
||||
sudo sed -i 's/:,/:runner name,/' /etc/passwd
|
||||
# We also create a couple optional files pinky looks for
|
||||
touch /home/runner/.project
|
||||
echo "foo" > /home/runner/.plan
|
||||
;;
|
||||
esac
|
||||
- name: rust toolchain ~ install
|
||||
uses: actions-rs/toolchain@v1
|
||||
# env:
|
||||
|
@ -899,6 +903,21 @@ jobs:
|
|||
case '${{ matrix.job.os }}' in
|
||||
macos-latest) brew install coreutils ;; # needed for testing
|
||||
esac
|
||||
case '${{ matrix.job.os }}' in
|
||||
ubuntu-latest)
|
||||
# pinky is a tool to show logged-in users from utmp, and gecos fields from /etc/passwd.
|
||||
# In GitHub Action *nix VMs, no accounts log in, even the "runner" account that runs the commands. The account also has empty gecos fields.
|
||||
# To work around this for pinky tests, we create a fake login entry for the GH runner account...
|
||||
FAKE_UTMP='[7] [999999] [tty2] [runner] [tty2] [] [0.0.0.0] [2022-02-22T22:22:22,222222+00:00]'
|
||||
# ... by dumping the login records, adding our fake line, then reverse dumping ...
|
||||
(utmpdump /var/run/utmp ; echo $FAKE_UTMP) | sudo utmpdump -r -o /var/run/utmp
|
||||
# ... and add a full name to each account with a gecos field but no full name.
|
||||
sudo sed -i 's/:,/:runner name,/' /etc/passwd
|
||||
# We also create a couple optional files pinky looks for
|
||||
touch /home/runner/.project
|
||||
echo "foo" > /home/runner/.plan
|
||||
;;
|
||||
esac
|
||||
- name: rust toolchain ~ install
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
|
|
|
@ -44,7 +44,14 @@ fn test_long_format() {
|
|||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn test_long_format_multiple_users() {
|
||||
let args = ["-l", "root", "root", "root"];
|
||||
// multiple instances of one account we know exists,
|
||||
// the account of the test runner,
|
||||
// and an account that (probably) doesn't exist
|
||||
let runner = match std::env::var("USER") {
|
||||
Ok(user) => user,
|
||||
Err(_) => "".to_string(),
|
||||
};
|
||||
let args = ["-l", "root", "root", "root", &runner, "no_such_user"];
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let expect = unwrap_or_return!(expected_result(&ts, &args));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue