Skip to content

Commit

Permalink
tests: bail when tzdb isn't available
Browse files Browse the repository at this point in the history
tzdb isn't always available when running tests, so bail out in
those cases.
  • Loading branch information
BurntSushi committed Jul 22, 2024
1 parent 41cedac commit e00939a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/fmt/rfc2822.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down
8 changes: 8 additions & 0 deletions src/fmt/strtime/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit e00939a

Please sign in to comment.