-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Tail macos stdin ran from script fix #7844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
GNU testsuite comparison:
|
4e4bee7
to
1880010
Compare
GNU testsuite comparison:
|
ed4659c
to
abf730b
Compare
GNU testsuite comparison:
|
6864d8d
to
4eb15ca
Compare
- introduce macOS-specific config guard - added test for testing tail stdin when redirected (`>`) from file and when through a pipe (`|`)
added drop line
4eb15ca
to
3c2e83a
Compare
the comment above the // On macOS path.is_dir() can be false for directories if it was a redirect,
// e.g. `$ tail < DIR. The library feature to detect the
// std::io::ErrorKind::IsADirectory isn't stable so we currently show the a wrong
// error message.
// FIXME: If `std::io::ErrorKind::IsADirectory` becomes stable or macos handles
// redirected directories like linux show the correct message like in
// `test_stdin_redirect_dir` and is testing: $ mkdir dir
$ tail < dir, $ tail - < dir
tail: error reading 'standard input': Is a directory the differences between the error messages on what i see on my mac-m1 using GNU's tail and uutil's can be shown in the following changes to ts.ucmd()
...
// .stderr_is("tail: stdin: Is a directory\n"); expected message macOS shows with GNU
.stderr_is("tail: Is a directory\n"); // actual message we show
ts.ucmd()
...
// .stderr_is("tail: -: No such file or directory\n"); expected message macOS shows with GNU
.stderr_is("tail: Is a directory\n"); // actual message we show which should be handled but since functionality when running from a script is failing, this test should be ignored for now. |
GNU testsuite comparison:
|
GNU testsuite comparison:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses issue #7763 by disabling a failing test on macOS and adding an additional test to validate tail’s behavior when reading from a script via redirection and piping on Unix systems. It also adjusts the input handling logic in tail’s source to resolve discrepancies in behavior between macOS and other Unix platforms.
- Disabled the test_stdin_redirect_dir_when_target_os_is_macos on macOS.
- Added a new test, test_stdin_via_script_redirection_and_pipe, to cover script redirection and piping.
- Updated the Input handling in paths.rs to return None on macOS and to canonicalize fd0 on non-macOS systems.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
tests/by-util/test_tail.rs | Ignores a failing macOS test and adds a new test for script redirection. |
src/uu/tail/src/paths.rs | Modifies Input handling to differentiate between macOS and other Unix. |
Comments suppressed due to low confidence (2)
tests/by-util/test_tail.rs:352
- The new test is enabled under #[cfg(unix)] and may execute on macOS, where the behavior of tail for script redirection differs. Consider adding a more specific configuration guard (e.g., #[cfg(not(target_vendor = "apple"))]) if the expected output on macOS is different.
fn test_stdin_via_script_redirection_and_pipe() {
src/uu/tail/src/paths.rs:81
- The macOS-specific branch returns None for Input handling. Verify that this change consistently supports both redirection and piping scenarios on macOS, or consider documenting the rationale to avoid future confusion.
#[cfg(target_os = "macos")]
@@ -324,6 +324,7 @@ fn test_stdin_redirect_dir() { | |||
// `test_stdin_redirect_dir` | |||
#[test] | |||
#[cfg(target_vendor = "apple")] | |||
#[ignore = "disabled until fixed"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer you fix that before we merge this PR :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in latest commit!
… a check to handle error message
GNU testsuite comparison:
|
@@ -346,6 +346,54 @@ fn test_stdin_redirect_dir_when_target_os_is_macos() { | |||
.stderr_is("tail: cannot open 'standard input' for reading: No such file or directory\n"); | |||
} | |||
|
|||
#[test] | |||
#[cfg(unix)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems that it is failing on freebsd:
──── TRY 1 STDOUT: coreutils::tests test_tail::test_stdin_via_script_redirection_and_pipe
running 1 test
bin: "/home/runner/work/coreutils/coreutils/target/debug/coreutils"
write(default): /tmp/.tmpqaoG0W/file.txt
run: sh -c ./test.sh < file.txt
test test_tail::test_stdin_via_script_redirection_and_pipe ... FAILED
failures:
failures:
test_tail::test_stdin_via_script_redirection_and_pipe
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 3718 filtered out; finished in 0.04s
──── TRY 1 STDERR: coreutils::tests test_tail::test_stdin_via_script_redirection_and_pipe
thread 'test_tail::test_stdin_via_script_redirection_and_pipe' panicked at tests/by-util/test_tail.rs:385:10:
Command was expected to succeed. code: 127
stdout =
stderr = sh: ./test.sh: not found
stack backtrace:
0: rust_begin_unwind
at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library/std/src/panicking.rs:695:5
1: core::panicking::panic_fmt
at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library/core/src/panicking.rs:75:14
2: uutests::util::CmdResult::success
at ./tests/uutests/src/lib/util.rs:442:9
3: uutests::util::UCommand::succeeds
at ./tests/uutests/src/lib/util.rs:1929:9
4: tests::test_tail::test_stdin_via_script_redirection_and_pipe
at ./tests/by-util/test_tail.rs:381:5
5: tests::test_tail::test_stdin_via_script_redirection_and_pipe::{{closure}}
at ./tests/by-util/test_tail.rs:351:48
6: core::ops::function::FnOnce::call_once
at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library/core/src/ops/function.rs:250:5
7: core::ops::function::FnOnce::call_once
at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for pointing this out, subtleties in FreeBSD
GNU testsuite comparison:
|
fixes #7763
causes
test_stdin_redirect_dir_when_target_os_is_macos
to fail, though may need more context on what this was testing.