mirror of
https://github.com/chronotope/chrono.git
synced 2025-10-02 07:21:41 +00:00
Give an error message when the wasm test fails (#482)
This commit is contained in:
parent
1b895b4719
commit
cf771cb5be
11
ci/github.sh
11
ci/github.sh
@ -102,9 +102,14 @@ test_wasm() {
|
||||
}
|
||||
|
||||
test_wasm_simple() {
|
||||
now=$(date +%s)
|
||||
tz=$(date +%z)
|
||||
runt env TZ="$tz" NOW="$now" wasm-pack test --node -- --features wasmbind
|
||||
if ! runt env TZ="$(date +%z)" NOW="$(date +%s)" wasm-pack test --node -- --features wasmbind ; then
|
||||
# sometimes on github the initial build takes 8-10 minutes, and we
|
||||
# check that the time makes sense inside the test by approximately
|
||||
# comparing it to the env var,
|
||||
#
|
||||
# so re-run the test in case it took too long
|
||||
runt env TZ="$(date +%z)" NOW="$(date +%s)" wasm-pack test --node -- --features wasmbind
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
@ -11,9 +11,18 @@ mod test {
|
||||
let utc: DateTime<Utc> = Utc::now();
|
||||
let local: DateTime<Local> = Local::now();
|
||||
|
||||
// Ensure time fetched is correct
|
||||
let actual = Utc.datetime_from_str(&env!("NOW"), "%s").unwrap();
|
||||
assert!(utc - actual < chrono::Duration::minutes(5));
|
||||
// Ensure time set by the test script is correct
|
||||
let now = env!("NOW");
|
||||
let actual = Utc.datetime_from_str(&now, "%s").unwrap();
|
||||
let diff = utc - actual;
|
||||
assert!(
|
||||
diff < chrono::Duration::minutes(5),
|
||||
"expected {} - {} == {} < 5m (env var: {})",
|
||||
utc,
|
||||
actual,
|
||||
diff,
|
||||
now,
|
||||
);
|
||||
|
||||
let tz = env!("TZ");
|
||||
eprintln!("testing with tz={}", tz);
|
||||
|
Loading…
x
Reference in New Issue
Block a user