mirror of
https://github.com/uutils/coreutils
synced 2024-10-15 04:14:44 +00:00
tests/du: run test_du_time with TZ=UTC.
du --time formats a file's timestamp according to the local timezone, but the test implicitly assumed UTC. This caused it to fail when running locally in my UTC+1 machine. $ cargo test --features "du touch" --no-default-features Failure: https://gist.github.com/eggpi/651e01559b7c59e9457c1b22fe4c0c19
This commit is contained in:
parent
b9bca794cc
commit
d29119728a
|
@ -391,7 +391,12 @@ fn test_du_h_flag_empty_file() {
|
||||||
fn test_du_time() {
|
fn test_du_time() {
|
||||||
let ts = TestScenario::new(util_name!());
|
let ts = TestScenario::new(util_name!());
|
||||||
|
|
||||||
|
// du --time formats the timestamp according to the local timezone. We set the TZ
|
||||||
|
// environment variable to UTC in the commands below to ensure consistent outputs
|
||||||
|
// and test results regardless of the timezone of the machine this test runs in.
|
||||||
|
|
||||||
ts.ccmd("touch")
|
ts.ccmd("touch")
|
||||||
|
.env("TZ", "UTC")
|
||||||
.arg("-a")
|
.arg("-a")
|
||||||
.arg("-t")
|
.arg("-t")
|
||||||
.arg("201505150000")
|
.arg("201505150000")
|
||||||
|
@ -399,19 +404,35 @@ fn test_du_time() {
|
||||||
.succeeds();
|
.succeeds();
|
||||||
|
|
||||||
ts.ccmd("touch")
|
ts.ccmd("touch")
|
||||||
|
.env("TZ", "UTC")
|
||||||
.arg("-m")
|
.arg("-m")
|
||||||
.arg("-t")
|
.arg("-t")
|
||||||
.arg("201606160000")
|
.arg("201606160000")
|
||||||
.arg("date_test")
|
.arg("date_test")
|
||||||
.succeeds();
|
.succeeds();
|
||||||
|
|
||||||
let result = ts.ucmd().arg("--time").arg("date_test").succeeds();
|
let result = ts
|
||||||
|
.ucmd()
|
||||||
|
.env("TZ", "UTC")
|
||||||
|
.arg("--time")
|
||||||
|
.arg("date_test")
|
||||||
|
.succeeds();
|
||||||
result.stdout_only("0\t2016-06-16 00:00\tdate_test\n");
|
result.stdout_only("0\t2016-06-16 00:00\tdate_test\n");
|
||||||
|
|
||||||
let result = ts.ucmd().arg("--time=atime").arg("date_test").succeeds();
|
let result = ts
|
||||||
|
.ucmd()
|
||||||
|
.env("TZ", "UTC")
|
||||||
|
.arg("--time=atime")
|
||||||
|
.arg("date_test")
|
||||||
|
.succeeds();
|
||||||
result.stdout_only("0\t2015-05-15 00:00\tdate_test\n");
|
result.stdout_only("0\t2015-05-15 00:00\tdate_test\n");
|
||||||
|
|
||||||
let result = ts.ucmd().arg("--time=ctime").arg("date_test").succeeds();
|
let result = ts
|
||||||
|
.ucmd()
|
||||||
|
.env("TZ", "UTC")
|
||||||
|
.arg("--time=ctime")
|
||||||
|
.arg("date_test")
|
||||||
|
.succeeds();
|
||||||
result.stdout_only("0\t2016-06-16 00:00\tdate_test\n");
|
result.stdout_only("0\t2016-06-16 00:00\tdate_test\n");
|
||||||
|
|
||||||
if birth_supported() {
|
if birth_supported() {
|
||||||
|
|
Loading…
Reference in a new issue