-
Notifications
You must be signed in to change notification settings - Fork 41
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
find: Implement -amin
-cmin
-mmin
age ranges.
#355
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #355 +/- ##
==========================================
+ Coverage 58.83% 59.12% +0.28%
==========================================
Files 30 30
Lines 3855 3914 +59
Branches 846 863 +17
==========================================
+ Hits 2268 2314 +46
- Misses 1254 1259 +5
- Partials 333 341 +8 ☔ View full report in Codecov by Sentry. |
src/find/matchers/time.rs
Outdated
File::create(temp_dir.path().join(new_file_name)).expect("create temp file"); | ||
let new_file = get_dir_entry_for(&temp_dir_path, new_file_name); | ||
|
||
// mores test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// mores test | |
// more test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Changed in new commit.
please add integrations tests in https://github.com/uutils/findutils/blob/main/tests/find_cmd_tests.rs |
I've added tests for string type numbers. This has to do with the way the Should I fix them in a new PR? $ find . -atime 1%2
find: invalid argument `1%2' to `-atime'
$ find . -amin 1%2
find: invalid argument `1%2' to `-amin'
$ ./target/debug/find . -atime 1%2
$ ./target/debug/find . -amin 1%2
./.git
./.git/objects/b1
./.git/objects/7f
./.git/objects/a8
./target/debug/deps
./target/debug/incremental/find_cmd_tests-8yeq2sf4g2ts
... |
tests/find_cmd_tests.rs
Outdated
"\"-60\"", "\"-120\"", "\"-240\"", "\"-60\"", "\"-120\"", "\"-240\"", | ||
]; | ||
|
||
for (arg, time) in args.iter().zip(times.iter()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this piece of code doesn't do what you think it does ;-) It doesn't create the Cartesian product of args
and times
:
for (arg, time) in args.iter().zip(times.iter()) {
println!("{arg}: {time}");
}
outputs:
-amin: -60
-cmin: -120
-mmin: -240
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. I replaced it with a nested loop. : )
tests/find_cmd_tests.rs
Outdated
.code(0); | ||
} | ||
|
||
for (arg, time_string) in args.iter().zip(time_strings.iter()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my previous comment.
tests/find_cmd_tests.rs
Outdated
for arg in args.iter() { | ||
for time in times.iter() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling iter()
is not necessary here.
for arg in args.iter() { | |
for time in times.iter() { | |
for arg in args { | |
for time in times { |
tests/find_cmd_tests.rs
Outdated
for arg in args.iter() { | ||
for time_string in time_strings.iter() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for arg in args.iter() { | |
for time_string in time_strings.iter() { | |
for arg in args { | |
for time_string in time_strings { |
tests/find_cmd_tests.rs
Outdated
for arg in args.iter() { | ||
for time_string in time_strings.iter() { | ||
Command::cargo_bin("find") | ||
.expect("the except time should not match") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this one:
.expect("the except time should not match") | |
.expect("the time should not match") |
src/find/mod.rs
Outdated
let args = ["-amin", "-cmin", "-mmin"]; | ||
let times = ["-60", "-120", "-240", "+60", "+120", "+240"]; | ||
|
||
for (arg, time) in args.iter().zip(times.iter()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you need a nested loop to get the expected result because zip
doesn't generate the Cartesian product of args
and times
.
Thanks, the conflict has been resolved and the code modified in new commits. |
it would be nice to work on #360 next |
Thanks! I will complete it as soon as I can. |
implement: #221