Skip to content

Commit

Permalink
try_verify_against_date_command NFC print progress messages
Browse files Browse the repository at this point in the history
Print progress messages for human users watching this long-running
test `try_verify_against_date_command`.
  • Loading branch information
jtmoon79 authored and djc committed May 30, 2023
1 parent b1729f3 commit e41451d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/dateutils.rs
Expand Up @@ -83,7 +83,6 @@ fn assert_run_date_version() {
#[test]
#[cfg(unix)]
fn try_verify_against_date_command() {

if !path::Path::new(DATE_PATH).exists() {
eprintln!("date command {:?} not found, skipping", DATE_PATH);
return;
Expand All @@ -92,16 +91,29 @@ fn try_verify_against_date_command() {

let mut date = NaiveDate::from_ymd_opt(1975, 1, 1).unwrap().and_hms_opt(0, 0, 0).unwrap();

eprintln!(
"Run command {:?} for every hour from {} to 2077, skipping some years...",
DATE_PATH,
date.year()
);
let mut count: u64 = 0;
let mut year_at = date.year();
while date.year() < 2078 {
if (1975..=1977).contains(&date.year())
|| (2020..=2022).contains(&date.year())
|| (2073..=2077).contains(&date.year())
{
if date.year() != year_at {
eprintln!("at year {}...", date.year());
year_at = date.year();
}
verify_against_date_command_local(DATE_PATH, date);
count += 1;
}

date += chrono::Duration::hours(1);
}
eprintln!("Command {:?} was run {} times", DATE_PATH, count);
}

#[cfg(target_os = "linux")]
Expand Down

0 comments on commit e41451d

Please sign in to comment.