Skip to content

link: add tests for zero args and existing destination#11119

Open
anihal wants to merge 5 commits intouutils:mainfrom
anihal:link-edge-case-tests
Open

link: add tests for zero args and existing destination#11119
anihal wants to merge 5 commits intouutils:mainfrom
anihal:link-edge-case-tests

Conversation

@anihal
Copy link
Contributor

@anihal anihal commented Feb 25, 2026

Adds two edge-case tests for link:

  • test_link_no_arguments: verifies that calling link with no arguments fails with the expected usage error
  • test_link_dest_exists: verifies that attempting to hard-link when the destination already exists fails with "File exists"

The existing tests cover nonexistent source, circular links, and wrong argument counts (1 or 3), but these two cases were missing.

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tty/tty-eof (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/misc/sleep is no longer failing!
Congrats! The gnu test tests/rm/many-dir-entries-vs-OOM is now passing!
Congrats! The gnu test tests/tail/tail-n0f is now passing!
Skip an intermittent issue tests/pr/bounded-memory (was skipped on 'main', now failing)

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/csplit/csplit-heap is now passing!
Congrats! The gnu test tests/printf/printf-surprise is now passing!
Congrats! The gnu test tests/tail/pipe-f is now passing!

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/cut/bounded-memory. tests/cut/bounded-memory is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/date/resolution. tests/date/resolution is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/pr/bounded-memory (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/misc/io-errors is no longer failing!

Copy link
Contributor

@sylvestre sylvestre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for these tests but they are failing for now

Split the chained method call onto separate lines to match rustfmt's
expected formatting.
The EEXIST error message varies by OS: Linux/macOS reports "File exists"
while OpenBSD reports "Already exists". Broaden the match to "exists"
to cover all platforms.
- test_link_no_arguments: clap emits "the following required arguments
  were not provided" (not "2 values required") when zero args are
  given; drop the stderr assertion and keep only .fails().
- test_link_dest_exists: collapse the method chain to one line to
  satisfy rustfmt.
@anihal anihal force-pushed the link-edge-case-tests branch from 08564aa to bf20278 Compare February 26, 2026 16:29
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
Note: The gnu test tests/rm/many-dir-entries-vs-OOM is now being skipped but was previously passing.
Congrats! The gnu test tests/expand/bounded-memory is now passing!
Congrats! The gnu test tests/tail/pipe-f is now passing!

@anihal
Copy link
Contributor Author

anihal commented Feb 26, 2026

Hi @sylvestre, the failing tests have been fixed:

  • test_link_dest_exists — broadened stderr_contains("File exists") to "exists" since OpenBSD reports "Already exists" for EEXIST
  • test_link_no_arguments — removed the stderr_contains assertion since clap emits a different message for 0 args vs 1 arg across platforms
  • Rustfmt — collapsed the method chain to one line

All 8 link tests now pass across platforms. The 3 currently failing CI jobs (test_mkfifo, test_stdbuf, test_timeout) are pre-existing flaky failures unrelated to this PR.

Could you take another look? Thanks!

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/cut/bounded-memory. tests/cut/bounded-memory is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/tty/tty-eof (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/misc/io-errors is no longer failing!
Congrats! The gnu test tests/basenc/bounded-memory is now passing!
Congrats! The gnu test tests/dd/no-allocate is now passing!

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