Skip to content

sync: return after checking all inputs#10742

Merged
ChrisDryden merged 9 commits intouutils:mainfrom
reubenwong97:patch/sync-check-all
Feb 10, 2026
Merged

sync: return after checking all inputs#10742
ChrisDryden merged 9 commits intouutils:mainfrom
reubenwong97:patch/sync-check-all

Conversation

@reubenwong97
Copy link
Copy Markdown
Contributor

Closes #10735 .

Instead of returning early, shows the errors as they are encountered and sets the error flag.

If the error flag is present, return a USimpleError with an empty message to match the GNU stderr.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 5, 2026

GNU testsuite comparison:

GNU test failed: tests/misc/sync. tests/misc/sync is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/shuf/shuf-reservoir (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/sort/sort-stale-thread-mem (fails in this run but passes in the 'main' branch)

@reubenwong97
Copy link
Copy Markdown
Contributor Author

Hi @ChrisDryden , would you mind taking a look at this change? Testing locally, I get the desired output:

❯ cargo run -q -- --data bad1 bad2
sync: error opening 'bad1': No such file or directory
sync: error opening 'bad2': No such file or directory

I added a test case to cover this as well. Some of the tests in the CI are failing, but are unrelated to my change.
Thank you!

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 5, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/misc/usage_vs_getopt (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/shuf/shuf-reservoir (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/sort/sort-stale-thread-mem (fails in this run but passes in the 'main' branch)

@sylvestre sylvestre force-pushed the patch/sync-check-all branch from abb9966 to c0fd338 Compare February 5, 2026 20:19
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 5, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/tty/tty-eof (passes in this run but fails in the 'main' branch)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 6, 2026

GNU testsuite comparison:

GNU test failed: tests/tail/symlink. tests/tail/symlink is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/misc/usage_vs_getopt (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/shuf/shuf-reservoir (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/sort/sort-stale-thread-mem (passes in this run but fails in the 'main' branch)

));
}

let mut has_error = false;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

instead of using this boolean, we have the helper utility set_error_code that we can use to make it more idiomatic. You can just call that function after the show error and then you dont need to have the tracking variable and if statement at the end

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, getting rid of the tracking variable is great. However, I think we still need the if condition for an early exit. If we just set the flag, the sync will attempt to run then exit on the first error, and we would end up with something like:

sync: error opening 'bad1': No such file or directory
sync: error opening 'bad2': No such file or directory
sync: bad1: No such file or directory

I was trying to follow the GNU output as closely as possible, and the early exit will prevent the last line from appearing.

)?;
);
if let Err(err) = err {
show_error!("{}", err.to_string());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You can simplify all of the map_err_context with the error code:

                  show!(SyncError::OpeningFile(f.clone(), e.into()));
                  set_exit_code(1);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have tried to follow your suggestions, but found myself needing to update the translation templates to also allow passing in of the error. I hope that is ok. Otherwise, the error would be the following instead:

sync: error opening 'bad1'
sync: error opening 'bad2'

and would also differ from the GNU stderr.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 6, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/usage_vs_getopt (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/shuf/shuf-reservoir (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/sort/sort-stale-thread-mem (passes in this run but fails in the 'main' branch)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 6, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/usage_vs_getopt (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/shuf/shuf-reservoir (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/sort/sort-stale-thread-mem (passes in this run but fails in the 'main' branch)

@reubenwong97
Copy link
Copy Markdown
Contributor Author

Hi @ChrisDryden ,
Appreciate the review. I had some clarifications in the thread, but have otherwise attempted to follow your directions. Could you help to check again? Thanks!

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 7, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/shuf/shuf-reservoir (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/sort/sort-stale-thread-mem (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/follow-name (fails in this run but passes in the 'main' branch)

@reubenwong97
Copy link
Copy Markdown
Contributor Author

Hi @ChrisDryden ,
Could you take a look to see if the changes are acceptable? Thanks!

@ChrisDryden
Copy link
Copy Markdown
Collaborator

I need to investigate this more, this should be passing the updated sync gnu tests but it does not appear to be passing in the ci

@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/cksum/cksum-a is no longer failing!
Congrats! The gnu test tests/cksum/cksum-c is no longer failing!
Congrats! The gnu test tests/date/date-locale-hour is no longer failing!
Congrats! The gnu test tests/env/env-S is no longer failing!
Congrats! The gnu test tests/env/env-signal-handler is no longer failing!
Congrats! The gnu test tests/install/basic-1 is no longer failing!
Congrats! The gnu test tests/ls/recursive is no longer failing!
Congrats! The gnu test tests/misc/kill is no longer failing!
Congrats! The gnu test tests/misc/read-errors is no longer failing!
Congrats! The gnu test tests/misc/sync is no longer failing!
Congrats! The gnu test tests/mv/mv-special-1 is no longer failing!
Congrats! The gnu test tests/ptx/ptx is no longer failing!
Congrats! The gnu test tests/pwd/pwd-long is no longer failing!
Congrats! The gnu test tests/tac/tac is no longer failing!
Note: The gnu test tests/tail/tail-n0f is now being skipped but was previously passing.
Congrats! The gnu test tests/env/env is now passing!
Congrats! The gnu test tests/env/env-S-script is now passing!

@ChrisDryden
Copy link
Copy Markdown
Collaborator

It needed to be rebased but if it passes the sync gnu test I think it should be good to go

@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/misc/sync is no longer failing!
Congrats! The gnu test tests/pr/bounded-memory is no longer failing!
Note: The gnu test tests/tail/tail-n0f is now being skipped but was previously passing.

@ChrisDryden ChrisDryden merged commit 7b0e7e4 into uutils:main Feb 10, 2026
155 of 156 checks passed
@ChrisDryden
Copy link
Copy Markdown
Collaborator

Thanks! You've fixed one of the gnu tests

cerdelen pushed a commit to cerdelen/coreutils that referenced this pull request Feb 12, 2026
* sync: return after checking all inputs

* fix missing error context

* use set_exit_code and update translation templates to show errors

* remove thiserror dependency

* fix typo

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
Co-authored-by: Chris Dryden <christopher.paul.dryden@gmail.com>
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.

sync: GNU only returns after checking all inputs

3 participants