Skip to content

find: Changed exit code when an error is encountered in process_dir(). - #352

Merged
cakebaker merged 5 commits into
uutils:mainfrom
hanbings:main
Apr 8, 2024
Merged

cakebaker merged 5 commits into
uutils:mainfrom
hanbings:main

Conversation

@hanbings

@hanbings hanbings commented Apr 6, 2024

Copy link
Copy Markdown
Collaborator

fix: #27

@codecov

codecov Bot commented Apr 6, 2024 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.52%. Comparing base (d94a8e9) to head (4d05816).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #352      +/-   ##
==========================================
+ Coverage   59.33%   59.52%   +0.18%     
==========================================
  Files          30       30              
  Lines        3819     3822       +3     
  Branches      869      869              
==========================================
+ Hits         2266     2275       +9     
+ Misses       1221     1218       -3     
+ Partials      332      329       -3     

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

@cakebaker

Copy link
Copy Markdown
Contributor

Can you please add a test to ensure we don't regress in the future?

@hanbings

hanbings commented Apr 6, 2024

Copy link
Copy Markdown
Collaborator Author

Can you please add a test to ensure we don't regress in the future?

OK, I've added a test for this fix.

Comment thread src/find/mod.rs Outdated
// WalkDirIterator::skip_current_dir for explanation.
let mut it = walkdir.into_iter();
while let Some(result) = it.next() {
let mut matcher_io = matchers::MatcherIO::new(deps);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the reason to move this here from the Ok case?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, I forgot to move it back into Ok().
My initial writing method was to write the error flag in matcher_io (which means matcher_io needs to be used in Err). Later, I found that it was designed as an immutable structure and then passed it as a parameter to the process_dir() function.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Changes have been committed in the latest. Thank you.

Comment thread src/find/mod.rs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree with your comment that using has_some_process_error is not a very elegant solution :)

I think you can eliminate the variable by using set_exit_code from uucore::error instead. It's what we use in coreutils in similar situations.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Looks better! Code has been reverted and uses uucore::error.
to be honest, I didn't know about this function before.

Comment thread src/find/mod.rs Outdated
Comment on lines +205 to +207
if has_some_process_error {
return Err("There are some process errors.".into());
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

GNU find doesn't show an error after the processing, it only shows the errors you show on line 157.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This code has been removed in the new commit. Thanks.

@cakebaker
cakebaker merged commit d8e2ce2 into uutils:main Apr 8, 2024
@cakebaker

Copy link
Copy Markdown
Contributor

Good work, thanks :)

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.

Exit code unchanged when an error is encountered

2 participants