find: reject a signed -maxdepth/-mindepth value to match GNU - #835
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #835 +/- ##
==========================================
+ Coverage 92.22% 92.27% +0.05%
==========================================
Files 35 35
Lines 7435 7435
Branches 386 386
==========================================
+ Hits 6857 6861 +4
+ Misses 437 433 -4
Partials 141 141 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Commit 2c18ead has test result changes: GNU findutils testsuite: bfs testsuite: |
|
please add a test_find.rs |
|
Done, added an integration test in test_find.rs for the signed -maxdepth/-mindepth case. |
2c18ead to
e056014
Compare
|
Commit e056014 has test result changes: GNU findutils testsuite: bfs testsuite: |
|
Commit f9fbd6e has test result changes: GNU findutils testsuite: bfs testsuite: |
|
a bunch of jobs have been failing |
convert_arg_to_number parsed the depth with Rust's usize parser, which accepts a leading '+', so "-maxdepth +1" was silently accepted. GNU find rejects a signed value there. Only accept plain decimal digits. Adds a test_find.rs test.
f9fbd6e to
0f7a2da
Compare
|
The failing jobs were from a stale base; rebased the branch on the latest main. fmt, clippy and the tests pass locally now. |
|
Commit 0f7a2da has test result changes: GNU findutils testsuite: |
Problem
-maxdepth/-mindepthaccepted a+-signed value that GNU rejects:Rust's
usize::from_straccepts a leading+, soconvert_arg_to_numberletit through, which is inconsistent with the function's own "positive decimal
integer" error message.
Fix
Only accept plain decimal digits.
Verification
Compared against GNU findutils (
gfind) for-maxdepthand-mindepthover1,+1,-1,+2,0,2; exit codes match in every case. Added a unittest;
cargo test --libpasses andcargo fmt/cargo clippyare clean.