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

Update parse_datetime to 0.5.0 #5313

Merged
merged 9 commits into from
Oct 1, 2023
Merged

Update parse_datetime to 0.5.0 #5313

merged 9 commits into from
Oct 1, 2023

Conversation

u8sand
Copy link
Contributor

@u8sand u8sand commented Sep 24, 2023

Fix #5274
Fix #5307

@tertsdiepraam
Copy link
Member

Cool! This conflicts with #5181, but we can rebase that once this is merged.

@u8sand
Copy link
Contributor Author

u8sand commented Sep 24, 2023

Okay I believe the error is unrelated to this PR but do let me know.

In terms of coverage, I've had to introduce two new (likely rare) error paths--caused if atime/mtime cannot be converted to DateTime due to overflow. Do let me know if I should attempt to add tests for these, honestly I'm not to sure how it would be triggered, perhaps an a/mtime of INTMAX or INTMIN.

@u8sand
Copy link
Contributor Author

u8sand commented Sep 24, 2023

So I do have a bit of a hacky fix for the new test

Which works in my terminal, but the test still fails with:

run: /home/u8sand/Programs/apps/coreutils/target/debug/coreutils touch -m -t +1000000000000 years test_touch_invalid_date_format
thread 'test_touch::test_touch_invalid_date_format' panicked at ''touch: invalid date format '+1000000000000 years'
' does not contain 'touch: invalid date format ‘+1000000000000 years’'', tests/by-util/test_touch.rs:855:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Not sure why the test suite changes the ticks to quotes? Please advise -- though I probably won't get back to this till next weekend 😞

In any-case, I made the test a bit easier 🤷‍♂️

Comment on lines 377 to 380
let hook = std::panic::take_hook();
std::panic::set_hook(Box::new(|_| {}));
let result = std::panic::catch_unwind(|| parse_datetime::parse_datetime_at_date(ref_time, s));
std::panic::set_hook(hook);
Copy link
Member

Choose a reason for hiding this comment

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

Ehh, I don't think that's a great idea 😄 This won't work with panic = "abort" for example. I think we need to fix parse_datetime instead. We don't need to match GNU's errors exactly. What's different?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I figured, the panic is in Chrono itself. The commits are pretty contained so we can just drop b6c6cca

In terms of the error, touch seems to use directional quotes instead of single quotes.

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

we should contribute in chrono to remove the panic and returns error in general

@tertsdiepraam
Copy link
Member

Oh the quotes are based on locale! We currently entirely ignore locale. If you run LC_ALL=C touch -d invalid foo you'll see the same quotes as uutils.

@sylvestre
Copy link
Sponsor Contributor

please ignore this test for now:


--- TRY 3 STDERR:        coreutils::tests test_touch::test_touch_invalid_date_format ---
thread 'test_touch::test_touch_invalid_date_format' panicked at ''touch: invalid date format '+1000000000000 years'
' does not contain 'touch: invalid date format ‘+1000000000000 years’'', tests/by-util/test_touch.rs:855:10
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
   1: core::panicking::panic_fmt
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
   2: tests::common::util::CmdResult::stderr_contains
             at ./tests/common/util.rs:675:9
   3: tests::test_touch::test_touch_invalid_date_format
             at ./tests/by-util/test_touch.rs:853:5
   4: tests::test_touch::test_touch_invalid_date_format::{{closure}}
             at ./tests/by-util/test_touch.rs:849:37
   5: core::ops::function::FnOnce::call_once
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:250:5
   6: core::ops::function::FnOnce::call_once
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@uutils uutils deleted a comment from github-actions bot Oct 1, 2023
@uutils uutils deleted a comment from github-actions bot Oct 1, 2023
@sylvestre sylvestre merged commit c27fcc4 into uutils:main Oct 1, 2023
44 of 45 checks passed
@sylvestre
Copy link
Sponsor Contributor

Thanks :)

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.

Update the {touch, date} code to use parse_datetime 0.5.0
3 participants