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

tests/du: run test_du_time with TZ=UTC. #4446

Merged
merged 1 commit into from
Mar 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions tests/by-util/test_du.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,27 +391,48 @@ fn test_du_h_flag_empty_file() {
fn test_du_time() {
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")
.env("TZ", "UTC")
.arg("-a")
.arg("-t")
.arg("201505150000")
.arg("date_test")
.succeeds();

ts.ccmd("touch")
.env("TZ", "UTC")
.arg("-m")
.arg("-t")
.arg("201606160000")
.arg("date_test")
.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");

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");

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");

if birth_supported() {
Expand Down