From e00939aa6f43ea55ae02f653bfb8097734555aa6 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 21 Jul 2024 20:46:38 -0400 Subject: [PATCH] tests: bail when tzdb isn't available tzdb isn't always available when running tests, so bail out in those cases. --- src/fmt/rfc2822.rs | 16 ++++++++++++++++ src/fmt/strtime/format.rs | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/src/fmt/rfc2822.rs b/src/fmt/rfc2822.rs index e61f074..423e681 100644 --- a/src/fmt/rfc2822.rs +++ b/src/fmt/rfc2822.rs @@ -1543,6 +1543,10 @@ mod tests { #[test] fn ok_print_zoned() { + if crate::tz::db().is_definitively_empty() { + return; + } + let p = |zdt: &Zoned| -> String { let mut buf = String::new(); DateTimePrinter::new().print_zoned(&zdt, &mut buf).unwrap(); @@ -1577,6 +1581,10 @@ mod tests { #[test] fn ok_print_timestamp() { + if crate::tz::db().is_definitively_empty() { + return; + } + let p = |ts: Timestamp| -> String { let mut buf = String::new(); DateTimePrinter::new().print_timestamp(&ts, &mut buf).unwrap(); @@ -1615,6 +1623,10 @@ mod tests { #[test] fn err_print_zoned() { + if crate::tz::db().is_definitively_empty() { + return; + } + let p = |zdt: &Zoned| -> String { let mut buf = String::new(); DateTimePrinter::new() @@ -1630,6 +1642,10 @@ mod tests { #[test] fn err_print_timestamp() { + if crate::tz::db().is_definitively_empty() { + return; + } + let p = |ts: Timestamp| -> String { let mut buf = String::new(); DateTimePrinter::new() diff --git a/src/fmt/strtime/format.rs b/src/fmt/strtime/format.rs index 2016528..51c3a69 100644 --- a/src/fmt/strtime/format.rs +++ b/src/fmt/strtime/format.rs @@ -660,6 +660,10 @@ mod tests { #[test] fn ok_format_offset() { + if crate::tz::db().is_definitively_empty() { + return; + } + let f = |fmt: &str, zdt: &Zoned| format(fmt, zdt).unwrap(); let zdt = date(2024, 7, 14) @@ -686,6 +690,10 @@ mod tests { #[test] fn ok_format_tzabbrev() { + if crate::tz::db().is_definitively_empty() { + return; + } + let f = |fmt: &str, zdt: &Zoned| format(fmt, zdt).unwrap(); let zdt = date(2024, 7, 14)