-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add comprehensive readonly file regression tests for cp #9045
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
Conversation
|
please remove the trivial comments :) |
|
GNU testsuite comparison: |
- Add 10 new test functions covering readonly destination behavior - Tests cover basic readonly copying, flag combinations, and edge cases - Include macOS-specific clonefile behavior tests - Ensure readonly file protection from PR #5261 cannot regress - Tests provide evidence for closing issue #5349
78e2aa7 to
b8d7d4a
Compare
CodSpeed Performance ReportMerging #9045 will degrade performances by 2.59%Comparing Summary
Benchmarks breakdown
Footnotes
|
|
GNU testsuite comparison: |
- Reduce file I/O overhead by batching file operations - Consolidate setup operations to minimize system calls - Improve test execution time from 0.44s to 0.27s (38% improvement) - Maintain comprehensive test coverage for readonly file behavior
|
GNU testsuite comparison: |
tests/by-util/test_cp.rs
Outdated
| #[cfg(not(windows))] | ||
| #[test] | ||
| fn test_cp_readonly_dest_with_force() { | ||
| let ts = TestScenario::new(util_name!()); | ||
| let at = &ts.fixtures; | ||
|
|
||
| // Use consistent file operations and batch setup | ||
| at.write("source.txt", "source content"); | ||
| at.write("readonly_dest.txt", "original content"); | ||
| at.set_readonly("readonly_dest.txt"); | ||
|
|
||
| ts.ucmd() | ||
| .args(&["--force", "source.txt", "readonly_dest.txt"]) | ||
| .succeeds(); | ||
|
|
||
| assert_eq!(at.read("readonly_dest.txt"), "source content"); | ||
| } |
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.
This test is more or less the same as test_cp_arg_force on line 941. I would keep this test as it is cleaner and remove the other one.
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 sorry, my comment was unclear :| What I meant is to keep this test, test_cp_readonly_dest_with_force, and to remove test_cp_arg_force.
tests/by-util/test_cp.rs
Outdated
| fn test_cp_readonly_dest_with_remove_destination() { | ||
| let ts = TestScenario::new(util_name!()); | ||
| let at = &ts.fixtures; | ||
|
|
||
| // Batch file operations for better performance | ||
| at.write("source.txt", "source content"); | ||
| at.write("readonly_dest.txt", "original content"); | ||
| at.set_readonly("readonly_dest.txt"); | ||
|
|
||
| ts.ucmd() | ||
| .args(&["--remove-destination", "source.txt", "readonly_dest.txt"]) | ||
| .succeeds(); | ||
|
|
||
| assert_eq!(at.read("readonly_dest.txt"), "source content"); | ||
| } |
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.
Same here: it's more or less the same as test_cp_arg_remove_destination on line 967. And I would also keep this test and remove the other one.
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.
Same here, my comment was unclear, I'm sorry. Here I also meant to keep test_cp_readonly_dest_with_remove_destination and to remove test_cp_arg_remove_destination.
5fddc7f to
a1fb012
Compare
|
GNU testsuite comparison: |
a1fb012 to
9a80703
Compare
- Remove test_cp_readonly_dest_regression (duplicate of test_cp_dest_no_permissions) - Remove test_cp_readonly_dest_with_force (duplicate of test_cp_arg_force) - Remove test_cp_readonly_dest_with_remove_destination (duplicate of test_cp_arg_remove_destination) - Remove test_cp_macos_clonefile_readonly (duplicate of test_cp_existing_target) - Remove test_cp_normal_copy_still_works (duplicate of test_cp_existing_target) - Remove trivial performance comments from readonly tests - Keep existing proven tests per maintainer preferences - Keep unique readonly tests that provide additional coverage
9a80703 to
112f646
Compare
|
GNU testsuite comparison: |
Fixes issue #5349
The tests ensure the readonly file behavior from PR #5261 cannot regress in future development.