Give an error message when the wasm test fails (#482)

This commit is contained in:
Brandon W Maister 2020-09-26 11:03:14 -04:00 committed by GitHub
parent 1b895b4719
commit cf771cb5be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 6 deletions

View File

@ -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 "$@"

View File

@ -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);