Commit Graph
72 Commits
Author SHA1 Message Date
✿ Fleur de BlueandGitHub 2a2cafdbd4 Re-enable unused_qualifications lint (#10571) 2026-02-03 21:55:21 +01:00
799de29ec1 fix: properly handle write errors for --version and --help output (#10223)
- Modified ClapErrorWrapper to detect and report when printing --version/--help fails
- Added test_version_help_dev_full to verify error handling
- Fixes issue where cat --version > /dev/full silently succeeded instead of failing

Addresses feedback from commit 9cc2e096d8

Co-authored-by: Cả thế giới là Rust <naoNao89@users.noreply.github.com>
2026-01-18 00:02:57 +01:00
Cả thế giới là Rust 9cc2e096d8 fix: handle write errors gracefully instead of panicking
Fixes #9769

Changed error.print().unwrap() to let _ = error.print() to prevent
panic when writing to /dev/full. Added regression test in test_cat.rs.
2026-01-05 09:00:36 +00:00
Sylvestre LedruandGitHub 103777b766 Merge pull request #8798 from naoNao89/test/cat-stdbuf-broken-pipe
tests(cat,stdbuf): Add broken-pipe robustness tests (#4627)
2025-12-26 00:25:52 +01:00
Mahdi Ali-RaihanandGitHub 7da2a2dd8b cat: do not connect to unix domain socket and instead return an error (#9755)
* cat: do not connect to unix domain socket and instead return an error. fixed #9751

* added empty line to fr-FR.ftl

* made NoSuchDeviceOrAddress error unix specific
2025-12-21 14:54:38 +01:00
Cả thế giới là RustandGitHub fd83181ac2 Fix EINTR handling in cat, od, and comm (#8946)
* fix: handle EINTR (signal interruptions) in cat, od, and comm

Add proper retry loops for ErrorKind::Interrupted in I/O operations
to handle signals like SIGUSR1 that can interrupt read/write calls.

This pattern is proven in production - identical to PR #6025 (merged
March 2024) which fixed dd's EINTR handling for GNU test dd/stats.sh.
The same pattern is already used in 9+ utilities (head, tail, tee, wc,
sort, sum, tr, shuf, dd) without issues.

Changes:
- cat: Fix write_fast() and write_lines() to retry on EINTR
- od: Fix PartialReader::read() in all three read paths
- comm: Fix are_files_identical() for both file readers
- tests: Add InterruptingReader/Writer test utilities

Historical context:
- Pattern validated by cre4ture's PR #6025 (dd EINTR fix)
- Matches existing implementations in dd/dd.rs:450,881
- POSIX best practice for signal-interrupted I/O

Fixes #1275

* fix: handle EINTR (signal interruptions) in cat, od, and comm

Add proper retry loops for ErrorKind::Interrupted in I/O operations to handle signals like SIGUSR1 that can interrupt read/write calls.

Pattern matches PR #6025 (dd EINTR fix) and is already used in 9+ utilities. Changes:
- cat: Fix write_fast() and write_lines() to retry on EINTR
- od: Fix PartialReader::read() in all three read paths
- comm: Fix are_files_identical() for both file readers
- tests: Add visible EINTR integration tests for CI

Addresses sylvestre's review feedback on code documentation and CI test visibility.

* style: apply cargo fmt formatting to EINTR changes

* test: fix EINTR integration test failures

- Fix comm test: use stdout_contains instead of stdout_only for tabbed output
- Fix od test: create new command instance to avoid 'already run this UCommand' error
- Remove unused imports and dead code to eliminate compiler warnings
- Both tests now pass without warnings or errors

* style: fix formatting and remove duplicate comment in od test

* ci: add EINTR and related technical terms to appropriate cspell dictionaries

- Add EINTR, eintr, nextest to jargon.wordlist.txt (technical/systems programming terms)
- Add SIGUSR, SIGINT, etc. to shell.wordlist.txt (POSIX signals)
- Add uutils, coreutils, ucmd, etc. to workspace.wordlist.txt (project-specific terms)
- Fixes CI cspell warnings for legitimate technical terminology
- Proper categorization follows existing dictionary structure
2025-10-26 13:59:47 +01:00
naoNao89 130893a19a tests(cat,stdbuf): Add broken-pipe robustness tests (#4627)
Add test coverage for cat and stdbuf broken pipe handling:

**cat tests:**
- test_cat_broken_pipe_nonzero_and_message: Verify cat handles SIGPIPE
  without hanging or crashing and exits with nonzero status

**stdbuf tests:**
- test_permission_external_missing_lib: Handle missing external libstdbuf
- test_no_such_external_missing_lib: Error handling in external lib mode
- Guard existing tests with #[cfg(not(feature = "feat_external_libstdbuf"))]

These tests address write-errors.sh from GNU test suite (#4627) and improve
cross-platform robustness for stdbuf feat_external_libstdbuf builds.
2025-10-03 16:39:55 +07:00
Sylvestre Ledru f15dac138e chmod/readlink/du: improve non-UTF-8 filename handling and code style 2025-08-14 10:52:24 +02:00
Sylvestre Ledru a3ebaaa730 cat: fix handling of non-UTF-8 filenames 2025-08-14 10:52:24 +02:00
Tomasz Guz 6a6ee59c63 cat: fix race condition in broken pipe handling test 2025-07-14 18:25:15 +02:00
Tomasz Guz 4406b403b2 cat: handle broken pipe gracefully 2025-07-14 18:25:15 +02:00
Luv-RayandGitHub fb2399f56b fix clippy (#8275)
* fix clippy

* update

* update
2025-06-27 09:15:24 +02:00
Yuankun ZhangandGitHub e1f40ff601 cat: add error handling in write_fast function (#8091) 2025-06-13 11:02:03 +02:00
Teemu PätsiandGitHub 4d40671d79 cat: Fix reporting "input file is output file" error when outputting to an input file (#8025)
* cat: Check if a file can be overwritten safely in Unix

* cat: Check if a file can be overwritten safely in Windows

* cat: Test writing read-write file that is input and output

* cat: Unit test `is_appending` function

* cat: Unit test `is_unsafe_overwrite` function

* cat: Comment why a few function calls could return Err

* cat: Remove obvious comments from test
2025-06-06 12:01:31 +02:00
Karl McDowall a4b621ad8a cat: bugfix when running with -T option
Fixes an crash seen when running with -T option if no newline
is found in a buffer.
Added unit test to validate.
2025-04-02 18:59:27 -06:00
Sylvestre Ledru a0179ea239 uutests: adjust the tests to use them 2025-03-28 21:40:31 +01:00
Sylvestre Ledru a85539f530 Run cargo fmt on the tree 2025-03-24 21:33:12 +01:00
Nicolas Boichat b142b9e748 test_*: Disable tests that require setting rlimit on Android
See #7542, it's not totally clear where the problem comes from,
but blanking LD_PRELOAD set by termux seems to fix the problem
(but introduces other issues.

Let's just disable these tests for now.
2025-03-23 20:24:17 +01:00
Daniel Hofstetter df4dfea852 tests: replace run() with succeeds() or fails() 2025-03-09 16:53:56 +01:00
Sylvestre Ledru 18cb7dcf9e Use the new function fails_with_code
Done with
```
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)[ \t]*\n[ \t]+\.no_stdout\(\)[ \t]*\n[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\2)\n\1.no_stdout();/gs' *rs
$ sed -i -e "s|.fails()(.*).code_is(|.fails_with_code(|g" *rs
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)[ \t]*\n[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\2);/gs' *rs
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)(.*?)[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\3)\2;/gs' *rs
...
```
2025-03-01 17:26:20 +01:00
Dorian PéronandJeffrey Finkelstein 9a88526867 test(cat): add test for output appending to input file 2025-02-07 07:45:21 -05:00
d8eb4e2214 cat: fix #5186 by adding explicit flush. (#5256)
* fix #5186 by adding explicit flush.
* make test machine-independent

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2024-10-06 11:31:31 +02:00
Peng ZijunandGitHub 382e787d1c cat: handle CRLF delimiters correctly (#6763)
* fix issue #6248

* add test to cat for the case of issue #6248
2024-10-02 15:15:06 +02:00
Laurent Cheylus b69070fdff tests: disable failed tests for cat on OpenBSD
Signed-off-by: Laurent Cheylus <foxy@free.fr>
2024-07-06 22:29:12 +02:00
n4n5 ab67947321 fix clippy tests 2024-06-30 16:27:08 +02:00