GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Display modification times of input files in context and unified diff by TanmayPatil105 · Pull Request #33 · uutils/diffutils Conversation
Contributor
Fixes #31 tanmay@tanmay-lenovo:~/Desktop/projects/uutils/diffutils$ cargo run -- -c fruits_old.txt fruits_new.txt Finished dev [unoptimized + debuginfo] target(s) in 0.04s Running `target/debug/diffutils -c fruits_old.txt fruits_new.txt` *** fruits_old.txt 2024-03-24 23:43:05.189597645 +0530 --- fruits_new.txt 2024-03-24 23:35:08.922581904 +0530 *************** *** 1,3 **** Apple ! Banana Cherry --- 1,3 ---- Apple ! Fig Cherry tanmay@tanmay-lenovo:~/Desktop/projects/uutils/diffutils$ diff -c fruits_old.txt fruits_new.txt *** fruits_old.txt 2024-03-24 23:43:05.189597645 +0530 --- fruits_new.txt 2024-03-24 23:35:08.922581904 +0530 *************** *** 1,3 **** Apple ! Banana Cherry --- 1,3 ---- Apple ! Fig Cherry
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
|
There was an error while loading. Please reload this page.
|
Okay! The current tests are failing. Isn't this strange? We check if file exists in Edit: These are unit tests. My bad! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Can you guide me more on these 😅? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This one is pretty simple, no ? :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@sylvestre I was looking at the unit tests and I see we are not actually creating files but only passing filename literals to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
yes please :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
392f726 to
9d4346e
Compare
There was an error while loading. Please reload this page.
9d4346e to
9ff8f89
Compare
There was an error while loading. Please reload this page.
|
I'm not sure on how the tests are failing on CI, we are creating the files now. It should have worked. Strange 🤔 The tests are working fine on my machine: test context_diff::tests::test_permutations_missing_lines ... ok test context_diff::tests::test_permutations_empty_lines ... ok test context_diff::tests::test_permutations_reverse ... ok test context_diff::tests::test_permutations ... ok test normal_diff::tests::test_stop_early ... ok |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
sorry, could you please fix the conflict? Sorry :( |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
38bd174 to
88a7568
Compare
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@ ## main #33 +/- ## ========================================== - Coverage 76.29% 75.85% -0.45% ========================================== Files 9 9 Lines 2582 2597 +15 Branches 663 662 -1 ========================================== Hits 1970 1970 - Misses 459 476 +17 + Partials 153 151 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I realized that the tests were passing locally because files were generated during previous test runs. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Yeah, just https://crates.io/crates/tempfile to create these files |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
a760034 to
a3a372f
Compare
…il105/diffutils into context-diff-modification-time
81c1346 to
0a77fe1
Compare
|
Hey @oSoMoN , I have made the necessary changes! Can you review the MR? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| let target = "target/utils"; | ||
| let _ = std::fs::create_dir(target); | ||
| let filename = &format!("{target}/foo"); | ||
| let temp = File::create(filename).unwrap(); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can you use a tempfile.NamedTempFile instead?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't think there are APIs to set modification time for a NamedTempFile.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
NamedTempFile::as_file() exposes a reference to the underlying file, so you could do something like this:
use tempfile::NamedTempFile; let temp = NamedTempFile::new().unwrap(); let current = SystemTime::now(); let _ = temp.as_file().set_modified(current); … assert_eq!(current, get_modification_time(&temp.path().to_string_lossy()));
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks Tanmay, that looks quite good!
I have left a handful of comments/suggestions, see inline.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Halfway through the changes. I'll complete them shortly! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
d9d7b56 to
aab1a13
Compare
Since we now returning SystemTime::now() for invalid file input, there is no need to crate dummy files
aab1a13 to
ba7cb0a
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that looks really good now. Almost ready to merge, see only my suggestion on the use of NamedTempFile.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| let target = "target/utils"; | ||
| let _ = std::fs::create_dir(target); | ||
| let filename = &format!("{target}/foo"); | ||
| let temp = File::create(filename).unwrap(); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
NamedTempFile::as_file() exposes a reference to the underlying file, so you could do something like this:
use tempfile::NamedTempFile; let temp = NamedTempFile::new().unwrap(); let current = SystemTime::now(); let _ = temp.as_file().set_modified(current); … assert_eq!(current, get_modification_time(&temp.path().to_string_lossy()));
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
It's worth noting that with the changes in this PR, one test from the GNU test suite which currently fails in main now passes (the timezone test). Nice improvement! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Done! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry for the noise! I forgot to run |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Merged, thanks Tanmay for the contribution! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Fixes uutils#223. Very simple reproduction ``` cd diffutils mkdir a touch a/alef a/alefn a/alef_ a/alefx a/alefr a/fuzz.file cargo test ``` => fail https://www.gnu.org/software/diffutils/manual/html_node/Multiple-Patches.html states that the "old" file name has precedence over the "new" filename. I hit this problem because some other (and unfortunately: unknown for now) test issue left bogus `a/alef*` file(s) behind in my workspace. I didn't bother cleaning them up because I assumed some test would keep recreating them and that cost me a lot of time. This issue seems to have existed since the very first commit. Interestingly, there as a previous attempt in 2024 to fix this in commit a3a372f ! So I was apparently not the only affected. BUT that fix was immediately reverted by commit ba7cb0a in the same PR. Admittedly, that fix seemed somewhat off-topic in uutils#33. So here it is again.
Fixes #223. Very simple reproduction ``` cd diffutils mkdir a touch a/alef a/alefn a/alef_ a/alefx a/alefr a/fuzz.file cargo test ``` => fail https://www.gnu.org/software/diffutils/manual/html_node/Multiple-Patches.html states that the "old" file name has precedence over the "new" filename. I hit this problem because some other (and unfortunately: unknown for now) test issue left bogus `a/alef*` file(s) behind in my workspace. I didn't bother cleaning them up because I assumed some test would keep recreating them and that cost me a lot of time. This issue seems to have existed since the very first commit. Interestingly, there as a previous attempt in 2024 to fix this in commit a3a372f ! So I was apparently not the only affected. BUT that fix was immediately reverted by commit ba7cb0a in the same PR. Admittedly, that fix seemed somewhat off-topic in #33. So here it is again.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Context diff doesn't display the last modification timestamp
There was an error while loading. Please reload this page.