xtask: the test suite and clippy pass on Windows (#2198)

* xtask: the test suite and clippy pass on Windows

Two Windows-only failures stopped `cargo xtask ci` before it got going on
a Windows checkout (CI runs the gate on Linux only, so neither showed):

- parity::tests::civil_dates built a SystemTime 115,740,740 days after
  the epoch (year 318857). Windows' SystemTime ends in the year 30828, so
  the addition panicked ("overflow when adding duration to `SystemTime`").
  That case now checks `civil_from_days` on the day count, which is what
  it was about, on every platform.
- stats.rs imported `walk` for a test that only exists on Unix, so the
  import was unused on Windows and `clippy -D warnings` refused it. The
  Unix test calls `super::walk`, as its neighbour calls `super::walk_inner`.

Checked on Windows 11 x64: `cargo test --workspace` and
`cargo clippy --workspace --all-targets -- -D warnings` both pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Contributors: add 2ez4gcx (Doan Huynh Huu Khuong)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2ez4gcx
2026-10-29 21:21:20 -04:00
committed by GitHub
co-authored by Claude Opus 5.5
parent bcf0dbc5e8
commit 9a1f200795
3 changed files with 10 additions and 3 deletions
+5
View File
@@ -91,3 +91,8 @@ sync_github_name = false
real_name = "Robert Lee"
sync_github_name = true
[people.2ez4gcx]
real_name = "Doan Huynh Huu Khuong"
display_name = "Doan Huynh Huu Khuong"
sync_github_name = false
+3 -1
View File
@@ -136,7 +136,9 @@ mod tests {
assert_eq!(day(20_736), "2026-10-10");
assert_eq!(date(std::time::UNIX_EPOCH - std::time::Duration::from_secs(86_400)), "1970-01-01");
// Past chrono's range keeps the proleptic Gregorian date, not the epoch (old `civil_from_days`).
assert_eq!(day(115_740_740), "318857-05-20");
// Checked on the day count: Windows' SystemTime ends in the year 30828, so building that
// SystemTime panics there.
assert_eq!(civil_from_days(115_740_740), (318_857, 5, 20));
// Windows' SystemTime can't hold u64::MAX / 2 seconds, so it is only checked where it exists.
if let Some(far) = std::time::UNIX_EPOCH.checked_add(std::time::Duration::from_secs(u64::MAX / 2)) {
assert_eq!(date(far), "292277026596-12-04");
+2 -2
View File
@@ -134,7 +134,7 @@ pub fn run(_root: &Path, exact: bool) -> Result<(), String> {
#[cfg(test)]
mod tests {
use super::{Counts, count_tests, walk};
use super::{Counts, count_tests};
#[test]
fn counts_attributes_and_proptest_blocks() {
@@ -155,7 +155,7 @@ mod tests {
// A directory symlink pointing back at `real` would be re-scanned if followed.
symlink(&real, base.join("alias")).unwrap();
let mut c = Counts::default();
walk(&base, &mut c).unwrap();
super::walk(&base, &mut c).unwrap();
assert_eq!(c.files, 1, "the aliased directory was followed and counted twice");
std::fs::remove_dir_all(&base).ok();
}