-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Test failure on NixOS #10756
Copy link
Copy link
Closed
Description
The bug
Currently the test suite (cargo test) fails because all environment variables (inlcuding PATH) get cleared in the build() method of UCommand:
command.env_clear();Then, /bin/sh looks for commandline tools such as sed, cat, head, ... in default locations (/bin or /usr/bin), but those are not present there on NixOS.
Possible Fix
preserve PATH when running tests
if let Some(path) = env::var_os("PATH") {
command.env("PATH", path);
}Log
failures:
---- test_env::test_simulation_of_terminal_for_stdin_only stdout ----
bin: "/home/emilia/Coding/coreutils/target/debug/coreutils"
run: /home/emilia/Coding/coreutils/target/debug/coreutils env sh is_a_tty.sh
thread 'test_env::test_simulation_of_terminal_for_stdin_only' (112587) panicked at tests/by-util/test_env.rs:1715:5:
assertion `left == right` failed
left: "stdin is a tty\nterminal size: \nstdout is not a tty\nstderr is not a tty\n"
right: "stdin is a tty\nterminal size: 30 80\nstdout is not a tty\nstderr is not a tty\n"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- test_env::test_simulation_of_terminal_size_information stdout ----
bin: "/home/emilia/Coding/coreutils/target/debug/coreutils"
run: /home/emilia/Coding/coreutils/target/debug/coreutils env sh is_a_tty.sh
thread 'test_env::test_simulation_of_terminal_size_information' (112618) panicked at tests/by-util/test_env.rs:1798:5:
assertion `left == right` failed
left: "stdin is a tty\r\nterminal size: \r\nstdout is a tty\r\nstderr is a tty\r\n"
right: "stdin is a tty\r\nterminal size: 10 40\r\nstdout is a tty\r\nstderr is a tty\r\n"
---- test_env::test_simulation_of_terminal_true stdout ----
bin: "/home/emilia/Coding/coreutils/target/debug/coreutils"
run: /home/emilia/Coding/coreutils/target/debug/coreutils env sh is_a_tty.sh
thread 'test_env::test_simulation_of_terminal_true' (112628) panicked at tests/by-util/test_env.rs:1689:5:
assertion `left == right` failed
left: "stdin is a tty\r\nterminal size: \r\nstdout is a tty\r\nstderr is a tty\r\n"
right: "stdin is a tty\r\nterminal size: 30 80\r\nstdout is a tty\r\nstderr is a tty\r\n"
---- test_seq::test_sigpipe_ignored_reports_write_error stdout ----
bin: "/home/emilia/Coding/coreutils/target/debug/coreutils"
run: /bin/sh -c trap '' PIPE; { "$SEQ_BIN" seq inf 2>err; echo $? >code; } | head -n1
thread 'test_seq::test_sigpipe_ignored_reports_write_error' (121646) panicked at tests/by-util/test_seq.rs:196:67:
Command was expected to succeed. code: 127
stdout =
stderr = /bin/sh: line 1: head: command not found
---- test_split::test_filter stdout ----
bin: "/home/emilia/Coding/coreutils/target/debug/coreutils"
run: /home/emilia/Coding/coreutils/target/debug/coreutils split --filter=sed s/./i/g > $FILE filtered
thread 'test_split::test_filter' (124983) panicked at tests/by-util/test_split.rs:311:10:
Command was expected to succeed. code: 1
stdout =
stderr = /bin/sh: line 1: sed: command not found
split: Shell process returned 127
---- test_split::test_filter_with_env_var_set stdout ----
bin: "/home/emilia/Coding/coreutils/target/debug/coreutils"
run: /home/emilia/Coding/coreutils/target/debug/coreutils split --filter=cat > $FILE filtered
thread 'test_split::test_filter_with_env_var_set' (124990) panicked at tests/by-util/test_split.rs:340:10:
Command was expected to succeed. code: 1
stdout =
stderr = /bin/sh: line 1: cat: command not found
split: Shell process returned 127
---- test_split::test_filter_broken_pipe stdout ----
bin: "/home/emilia/Coding/coreutils/target/debug/coreutils"
run: /home/emilia/Coding/coreutils/target/debug/coreutils split --filter=head -c1 > /dev/null -n r/1 filter-big-input
thread 'test_split::test_filter_broken_pipe' (124984) panicked at tests/by-util/test_split.rs:370:10:
Command was expected to succeed. code: 1
stdout =
stderr = /bin/sh: line 1: head: command not found
split: Shell process returned 127
---- test_tail::test_stdin_via_script_redirection_and_pipe stdout ----
bin: "/home/emilia/Coding/coreutils/target/debug/coreutils"
write(default): /tmp/.tmpOPc5WP/file.txt
run: sh -c ./test.sh < file.txt
thread 'test_tail::test_stdin_via_script_redirection_and_pipe' (126675) panicked at tests/by-util/test_tail.rs:418:10:
Command was expected to succeed. code: 127
stdout =
stderr = ./test.sh: line 2: tail: command not found
---- test_test::test_file_N stdout ----
bin: "/home/emilia/Coding/coreutils/target/debug/coreutils"
run: /bin/sh -c stat file
thread 'test_test::test_file_N' (126893) panicked at tests/by-util/test_test.rs:968:49:
Command was expected to succeed. code: 127
stdout =
stderr = /bin/sh: line 1: stat: command not found
failures:
test_env::test_simulation_of_terminal_for_stdin_only
test_env::test_simulation_of_terminal_size_information
test_env::test_simulation_of_terminal_true
test_seq::test_sigpipe_ignored_reports_write_error
test_split::test_filter
test_split::test_filter_broken_pipe
test_split::test_filter_with_env_var_set
test_tail::test_stdin_via_script_redirection_and_pipe
test_test::test_file_N
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels