Skip to content

xargs: strip (os error N) from --arg-file open failure - #822

Merged
sylvestre merged 2 commits into
uutils:mainfrom
MsfPablo:xargs-strip-errno-argfile
Aug 9, 2026
Merged

sylvestre merged 2 commits into
uutils:mainfrom
MsfPablo:xargs-strip-errno-argfile

Conversation

@MsfPablo

@MsfPablo MsfPablo commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

When --arg-file points at a missing path, xargs used to surface the raw io::Error display, which appends (os error N) for OS errors:

$ xargs --arg-file sdf echo
Error: Failed to open sdf: No such file or directory (os error 2)

GNU xargs omits that detail. This reuses uucore::error::strip_errno — the same helper updatedb already uses for the identical "strip the trailing (os error N) so the message reads cleanly" goal — so the output becomes:

Error: Failed to open sdf: No such file or directory

This is a one-line change at the arg-file open site plus the existing helper; no new abstraction.

Closes #811.

Test plan

  • Added xargs_arg_file_missing_strips_errno integration test asserting: exit code 1, stderr contains Failed to open, contains No such file or directory, and does not contain (os error.
  • cargo test — full workspace suite green (find, locate, updatedb, xargs: 28/28 + doctests).
  • cargo fmt --check clean.
  • cargo clippy --bin xargs clean.
  • Manually reproduced the issue transcript and confirmed the (os error N) suffix is gone.

Context

I went with strip_errno rather than a custom regex because updatedb/mod.rs already established it as the codebase pattern for exactly this (strip the trailing "(os error N)" ...). Happy to change the wording (e.g. GNU-style xargs: sdf: No such file or directory) if maintainers prefer a closer GNU message match — kept it minimal here since #811 only asks to drop the (os error N).

This contribution was developed with AI assistance (Claude). I have reviewed and understand every line of the diff.

When --arg-file points at a missing path, xargs used to surface the raw
io::Error display, which appends " (os error N)" for OS errors:

    Error: Failed to open sdf: No such file or directory (os error 2)

GNU xargs omits that detail. Reuse uucore::error::strip_errno (already
used by updatedb) so the message reads:

    Error: Failed to open sdf: No such file or directory

Closes uutils#811
@codecov

codecov Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.93%. Comparing base (1f19cdd) to head (b8fd422).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #822   +/-   ##
=======================================
  Coverage   91.93%   91.93%           
=======================================
  Files          35       35           
  Lines        7251     7253    +2     
  Branches      378      378           
=======================================
+ Hits         6666     6668    +2     
  Misses        443      443           
  Partials      142      142           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

Commit 6fdc755 has test result changes:

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 314 / PASSED: 267 / FAILED: 41 / SKIPPED: 6
  Reference: TOTAL: 312 / PASSED: 266 / FAILED: 40 / SKIPPED: 6

Changes from main branch:
  TOTAL: +2
  PASSED: +1
  FAILED: +1

New test failures (1):
  - gnu/files0_from_ok

@codspeed

codspeed Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 20 untouched benchmarks


Comparing MsfPablo:xargs-strip-errno-argfile (b8fd422) with main (1f19cdd)

Open in CodSpeed

@sylvestre

Copy link
Copy Markdown
Contributor

Fails on windows:



---- xargs_arg_file_missing_strips_errno stdout ----
bin: "D:\\a\\findutils\\findutils\\target\\debug\\find.exe"
run: D:\a\findutils\findutils\target\debug\xargs.exe --arg-file /no/such/findutils-test-path echo

thread 'xargs_arg_file_missing_strips_errno' (7324) panicked at tests\test_xargs.rs:569:10:
'Error: Failed to open /no/such/findutils-test-path: The system cannot find the path specified.
' does not contain 'No such file or directory'
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


The assertion hardcoded the Unix errno wording ("No such file or
directory"), so the test failed on Windows where the OS reports
"The system cannot find the path specified." (reported by @sylvestre).

The contract this test guards is only that the trailing "(os error N)"
suffix is stripped — the OS wording is out of our control. Assert the
portable parts instead: our "Failed to open <path>:" wrapper names the
path and no "(os error" suffix leaks.
@MsfPablo

MsfPablo commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @sylvestre — good catch. Pushed a fix (b8fd422): the test hardcoded the Unix errno wording "No such file or directory", which fails on Windows where the OS reports "The system cannot find the path specified.". Since the contract this test guards is only that the trailing (os error N) suffix is stripped (the OS wording is out of our control), it now asserts the portable parts — our Failed to open <path>: wrapper names the path and no (os error suffix leaks. Local cargo test --test test_xargs is green (28/28), cargo clippy --bin xargs -D warnings and cargo fmt --check clean.

Separately, the compat (BFS) job flags gnu/files0_from_ok as a new failure, but that one is pre-existing on main independent of this PR — the latest main External-testsuites run (30980036584, 2026-08-05, before this PR) also reports [FAIL] gnu/files0_from_ok in its BFS log. The "new" label comes from diffing against an older baseline artifact; the only change here is a one-line xargs --arg-file error-message string, which cannot touch find -files0-from.

@sylvestre

Copy link
Copy Markdown
Contributor

@MsfPablo please answering through your llm

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

Commit b8fd422 has test result changes:

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 315 / PASSED: 267 / FAILED: 42 / SKIPPED: 6
  Reference: TOTAL: 312 / PASSED: 266 / FAILED: 40 / SKIPPED: 6

Changes from main branch:
  TOTAL: +3
  PASSED: +1
  FAILED: +2

New test failures (2):
  - gnu/files0_from_ok
  - gnu/okdir_path_relative

@sylvestre
sylvestre merged commit 065320c into uutils:main Aug 9, 2026
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants