Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement -fprintf #444

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Implement -fprintf #444

wants to merge 9 commits into from

Conversation

hanbings
Copy link
Collaborator

Closes #383

Copy link

codecov bot commented Aug 12, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 66.57%. Comparing base (4d36789) to head (6f64a19).

Files with missing lines Patch % Lines
src/find/matchers/mod.rs 44.44% 1 Missing and 4 partials ⚠️
tests/find_cmd_tests.rs 92.30% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #444      +/-   ##
==========================================
+ Coverage   66.53%   66.57%   +0.03%     
==========================================
  Files          36       36              
  Lines        4378     4404      +26     
  Branches      986      993       +7     
==========================================
+ Hits         2913     2932      +19     
- Misses       1063     1064       +1     
- Partials      402      408       +6     

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

Copy link

Commit b5853cb has GNU testsuite comparison:

Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O0 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O1 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O2 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O3 is now passing!
Run GNU findutils tests: GNU tests summary = TOTAL: 694 / PASS: 449 / FAIL: 242 / ERROR: 2
Run GNU findutils tests: Changes from main: PASS +0 / FAIL -4 / ERROR +0 / SKIP +0 
Run GNU findutils tests: Gnu tests No changes
Run BFS tests: Changes from main: PASS +1 / SKIP +0 / FAIL -1
Run BFS tests: BFS tests summary = TOTAL: 288 / PASS: 197 / SKIP: 1 / FAIL: 90

@sylvestre
Copy link
Sponsor Contributor

needs rebasing

Copy link

Commit dc33ca5 has GNU testsuite comparison:

Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O0 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O1 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O2 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O3 is now passing!
Run GNU findutils tests: GNU tests summary = TOTAL: 655 / PASS: 477 / FAIL: 175 / ERROR: 2
Run GNU findutils tests: Changes from main: PASS +0 / FAIL -4 / ERROR +0 / SKIP +0 
Run GNU findutils tests: Gnu tests No changes
Run BFS tests: Congrats! The bfs test gnu/fprintf is now passing!
Run BFS tests: Congrats! The bfs test posix/exec_plus_status is now passing!
Run BFS tests: Changes from main: PASS +1 / SKIP +0 / FAIL -1
Run BFS tests: BFS tests summary = TOTAL: 317 / PASS: 242 / SKIP: 6 / FAIL: 69

Copy link

Commit 67eb6f5 has GNU testsuite comparison:

Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O0 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O1 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O2 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O3 is now passing!
Run GNU findutils tests: GNU tests summary = TOTAL: 655 / PASS: 477 / FAIL: 175 / ERROR: 2
Run GNU findutils tests: Changes from main: PASS +0 / FAIL -4 / ERROR +0 / SKIP +0 
Run GNU findutils tests: Gnu tests No changes
Run BFS tests: Congrats! The bfs test gnu/fprintf is now passing!
Run BFS tests: Changes from main: PASS +1 / SKIP +0 / FAIL -1
Run BFS tests: BFS tests summary = TOTAL: 317 / PASS: 242 / SKIP: 6 / FAIL: 69

Copy link

github-actions bot commented Sep 5, 2024

Commit 4ed3bc0 has GNU testsuite comparison:

Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O0 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O1 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O2 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O3 is now passing!
Run GNU findutils tests: GNU tests summary = TOTAL: 655 / PASS: 477 / FAIL: 175 / ERROR: 2
Run GNU findutils tests: Changes from main: PASS +0 / FAIL -4 / ERROR +0 / SKIP +0 
Run GNU findutils tests: Gnu tests No changes
Run BFS tests: Congrats! The bfs test common/L_ls is now passing!
Run BFS tests: Congrats! The bfs test common/ls is now passing!
Run BFS tests: Congrats! The bfs test gnu/fls is now passing!
Run BFS tests: Congrats! The bfs test gnu/fprintf is now passing!
Run BFS tests: Changes from main: PASS +4 / SKIP +0 / FAIL -4
Run BFS tests: BFS tests summary = TOTAL: 317 / PASS: 245 / SKIP: 6 / FAIL: 66

Copy link

github-actions bot commented Sep 9, 2024

Commit 07e9b11 has GNU testsuite comparison:

Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O0 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O1 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O2 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O3 is now passing!
Run GNU findutils tests: GNU tests summary = TOTAL: 655 / PASS: 477 / FAIL: 175 / ERROR: 2
Run GNU findutils tests: Changes from main: PASS +0 / FAIL -4 / ERROR +0 / SKIP +0 
Run GNU findutils tests: Gnu tests No changes
Run BFS tests: Congrats! The bfs test gnu/fprintf is now passing!
Run BFS tests: Changes from main: PASS +1 / SKIP +0 / FAIL -1
Run BFS tests: BFS tests summary = TOTAL: 317 / PASS: 245 / SKIP: 6 / FAIL: 66

Copy link

github-actions bot commented Sep 9, 2024

Commit 4130c38 has GNU testsuite comparison:

Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O0 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O1 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O2 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O3 is now passing!
Run GNU findutils tests: GNU tests summary = TOTAL: 651 / PASS: 481 / FAIL: 167 / ERROR: 2
Run GNU findutils tests: Changes from main: PASS +0 / FAIL -4 / ERROR +0 / SKIP +0 
Run GNU findutils tests: Gnu tests No changes
Run BFS tests: Congrats! The bfs test gnu/fprint0 is now passing!
Run BFS tests: Congrats! The bfs test gnu/fprintf is now passing!
Run BFS tests: Changes from main: PASS +2 / SKIP +0 / FAIL -2
Run BFS tests: BFS tests summary = TOTAL: 317 / PASS: 246 / SKIP: 6 / FAIL: 65

@sylvestre
Copy link
Sponsor Contributor

Any idea why PASS +0 in ?
Run GNU findutils tests: Changes from main: PASS +0 / FAIL -4 / ERROR +0 / SKIP +0

Copy link

github-actions bot commented Sep 9, 2024

Commit 6f64a19 has GNU testsuite comparison:

Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O0 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O1 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O2 is now passing!
Run GNU findutils tests: Congrats! The GNU test fprintf-samefile.new-O3 is now passing!
Run GNU findutils tests: GNU tests summary = TOTAL: 651 / PASS: 481 / FAIL: 167 / ERROR: 2
Run GNU findutils tests: Changes from main: PASS +0 / FAIL -4 / ERROR +0 / SKIP +0 
Run GNU findutils tests: Gnu tests No changes
Run BFS tests: Congrats! The bfs test gnu/fprintf is now passing!
Run BFS tests: Changes from main: PASS +1 / SKIP +0 / FAIL -1
Run BFS tests: BFS tests summary = TOTAL: 317 / PASS: 246 / SKIP: 6 / FAIL: 65

@hanbings
Copy link
Collaborator Author

hanbings commented Sep 9, 2024

Any idea why PASS +0 in ? Run GNU findutils tests: Changes from main: PASS +0 / FAIL -4 / ERROR +0 / SKIP +0

I guess it's something to do with the total number of GNU tests changing?
I haven't seen anything like this either, it seems to have been like this since the beginning of this PR. ¯\(ツ)

But at least we know the code works.

Comment on lines +625 to +629
if let Some(file) = &self.output_file {
self.print(file_info, file);
} else {
self.print(file_info, &mut *matcher_io.deps.get_output().borrow_mut());
}
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

a bit more rust idiomatic:

Suggested change
if let Some(file) = &self.output_file {
self.print(file_info, file);
} else {
self.print(file_info, &mut *matcher_io.deps.get_output().borrow_mut());
}
let output = self.output_file.as_ref()
.unwrap_or_else(|| matcher_io.deps.get_output().borrow_mut());
self.print(file_info, output);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wow, that's much cleaner.

I tried modifying it but I seem to be having some type issues.

error[E0308]: mismatched types
   --> src/find/matchers/printf.rs:628:32
    |
628 |             .unwrap_or_else(|| matcher_io.deps.get_output().borrow_mut());
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
                                     expected `&File`, found `RefMut<'_, dyn Write>`
    |
    = note: expected reference `&File`
                  found struct `RefMut<'_, (dyn std::io::Write + 'static)>`

and I also tried:

fn print(&self, file_info: &WalkEntry, out: &mut dyn Write) { ... }

...
let output: &mut dyn Write = self.output_file
    .as_ref()
    .map(|file| file.borrow_mut() as &mut dyn Write)
    .unwrap_or_else(|| matcher_io.deps.get_output().borrow_mut());

self.print(file_info, output);
...

I'm relatively new at this, would you mind pointing me out further?

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.

Implement -fprintf
2 participants