coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

Fix touch timezone calculation

Open ctsk opened this issue 2 years ago • 9 comments

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 avatar Jan 29 '23 20:01 ctsk

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

sylvestre avatar Jan 29 '23 21:01 sylvestre

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

jfinkels avatar Feb 05 '23 18:02 jfinkels

Hmm... Perhaps the setenv break subsequent tests?

ctsk avatar Feb 07 '23 11:02 ctsk

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.

tertsdiepraam avatar Feb 07 '23 12:02 tertsdiepraam

GNU testsuite comparison:

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

github-actions[bot] avatar Feb 07 '23 17:02 github-actions[bot]

@ctsk i noticed that you have closed this PR and https://github.com/uutils/coreutils/pull/4316#event-9068743633 you aren't interested in finishing them? thanks

sylvestre avatar Apr 22 '23 06:04 sylvestre