Skip to content

Fix touch timezone calculation #4309

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

Closed
wants to merge 5 commits into from
Closed

Conversation

ctsk
Copy link
Contributor

@ctsk ctsk commented Jan 29, 2023

The timezone offset calculation didn't take into account that some locales change their UTC offset throughout the year (like due to daylight savings time). This change fixes.

Fixes #4236

@ctsk ctsk force-pushed the fix/touch-timezone branch from 7cc7853 to ee23fe7 Compare January 29, 2023 20:57
@sylvestre
Copy link
Contributor

Could you please add a test to make sure it doesn't regress?

@jfinkels
Copy link
Collaborator

jfinkels commented Feb 5, 2023

looks like there were some test failures in the CI; I've restarted it and copied the failures I saw here:


failures:

error: test failed, to rerun pass '-p coreutils --test tests'
---- test_touch::test_touch_tz_crosses_dst stdout ----
current_directory_resolved: 
run: /home/runner/work/coreutils/coreutils/target/debug/coreutils touch -t 202301010000 -a test_touch_tz_crosses_dst_file
thread 'test_touch::test_touch_tz_crosses_dst' panicked at 'assertion failed: t1 == atime_cet.seconds() + 60 * 60', tests/by-util/test_touch.rs:863:5
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:143:14
   2: core::panicking::panic
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:48:5
   3: tests::test_touch::test_touch_tz_crosses_dst
             at ./tests/by-util/test_touch.rs:863:5
   4: tests::test_touch::test_touch_tz_crosses_dst::{{closure}}
             at ./tests/by-util/test_touch.rs:850:1
   5: core::ops::function::FnOnce::call_once
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:227:5
   6: core::ops::function::FnOnce::call_once
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

---- test_who::test_boot stdout ----
current_directory_resolved: 
run: who --version
uutils-tests-info: version for the reference coreutil 'who' is higher than expected; expected: 8.3, found: 8.32
run: who -b
run: /home/runner/work/coreutils/coreutils/target/debug/coreutils who -b
thread 'test_who::test_boot' panicked at 'assertion failed: `(left == right)`

Diff < left / right > :
<         system boot  Jan 31 14:34
>         system boot  Jan 31 15:34
 

', tests/by-util/test_who.rs:32:39
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:143:14
   2: tests::common::util::CmdResult::stdout_is
             at ./tests/common/util.rs:449:9
   3: tests::test_who::test_boot
             at ./tests/by-util/test_who.rs:32:9
   4: tests::test_who::test_boot::{{closure}}
             at ./tests/by-util/test_who.rs:28:1
   5: core::ops::function::FnOnce::call_once
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:227:5
   6: core::ops::function::FnOnce::call_once
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

---- test_who::test_login stdout ----
current_directory_resolved: 
run: who --version
uutils-tests-info: version for the reference coreutil 'who' is higher than expected; expected: 8.3, found: 8.32
run: who -l
run: /home/runner/work/coreutils/coreutils/target/debug/coreutils who -l
thread 'test_who::test_login' panicked at 'assertion failed: `(left == right)`

Diff < left / right > :
<LOGIN    ttyS0        Jan 31 14:34               717 id=tyS0
<LOGIN    tty1         Jan 31 14:34               748 id=tty1
>LOGIN    ttyS0        Jan 31 15:34               717 id=tyS0
>LOGIN    tty1         Jan 31 15:34               748 id=tty1
 

', tests/by-util/test_who.rs:72:39
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:143:14
   2: tests::common::util::CmdResult::stdout_is
             at ./tests/common/util.rs:449:9
   3: tests::test_who::test_login
             at ./tests/by-util/test_who.rs:72:9
   4: tests::test_who::test_login::{{closure}}
             at ./tests/by-util/test_who.rs:68:1
   5: core::ops::function::FnOnce::call_once
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:227:5
   6: core::ops::function::FnOnce::call_once
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

---- test_who::test_runlevel stdout ----
current_directory_resolved: 
run: who --version
uutils-tests-info: version for the reference coreutil 'who' is higher than expected; expected: 8.3, found: 8.32
run: who -r
run: /home/runner/work/coreutils/coreutils/target/debug/coreutils who -r
thread 'test_who::test_runlevel' panicked at 'assertion failed: `(left == right)`

Diff < left / right > :
<         run-level 5  Jan 31 14:34
>         run-level 5  Jan 31 15:34
 

', tests/by-util/test_who.rs:100:39
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:143:14
   2: tests::common::util::CmdResult::stdout_is
             at ./tests/common/util.rs:449:9
   3: tests::test_who::test_runlevel
             at ./tests/by-util/test_who.rs:100:9
   4: tests::test_who::test_runlevel::{{closure}}
             at ./tests/by-util/test_who.rs:96:1
   5: core::ops::function::FnOnce::call_once
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:227:5
   6: core::ops::function::FnOnce::call_once
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    test_touch::test_touch_tz_crosses_dst
    test_who::test_boot
    test_who::test_login
    test_who::test_runlevel

test result: FAILED. 2484 passed; 4 failed; 39 ignored; 0 measured; 0 filtered out; finished in 150.67s

@ctsk
Copy link
Contributor Author

ctsk commented Feb 7, 2023

Hmm... Perhaps the setenv break subsequent tests?

@tertsdiepraam
Copy link
Member

We should probably add some function in the test utils that sets an environment variable for the subcommand to make this easier without messing up the env variables.

@github-actions
Copy link

github-actions bot commented Feb 7, 2023

GNU testsuite comparison:

Congrats! The gnu test tests/tail-2/inotify-dir-recreate is no longer failing!

@ctsk ctsk force-pushed the fix/touch-timezone branch from 1bf597b to e31d71d Compare February 7, 2023 17:52
ctsk and others added 4 commits February 17, 2023 17:45
to_local assumed that the timezone offset at the specified time would
match the current timezone. This is not the case if the current locale
adheres to e.g. daylight savings time.

Fixes uutils#4236
@uutils uutils deleted a comment from github-actions bot Mar 27, 2023
@uutils uutils deleted a comment from github-actions bot Mar 27, 2023
@uutils uutils deleted a comment from github-actions bot Mar 27, 2023
@uutils uutils deleted a comment from github-actions bot Mar 27, 2023
@ctsk ctsk closed this Apr 21, 2023
@sylvestre
Copy link
Contributor

@ctsk i noticed that you have closed this PR and #4316 (comment)
you aren't interested in finishing them? 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.

touch: test_du::test_du_time fails on wrong date
4 participants