test: fix std.time timing tests to skip on failure

This commit is contained in:
Michael Dusan 2021-04-07 05:25:59 -04:00
parent f253822415
commit 2871d32be7
2 changed files with 7 additions and 3 deletions

View File

@ -1354,7 +1354,7 @@ test "timeout (after a relative time)" {
.flags = 0,
}, cqe);
// Tests should not depend on timings: skip test (result) if outside margin.
// Tests should not depend on timings: skip test if outside margin.
if (!std.math.approxEqAbs(f64, ms, @intToFloat(f64, stopped - started), margin)) return error.SkipZigTest;
}

View File

@ -271,7 +271,9 @@ test "timestamp" {
sleep(ns_per_ms);
const time_1 = milliTimestamp();
const interval = time_1 - time_0;
testing.expect(interval > 0 and interval < margin);
testing.expect(interval > 0);
// Tests should not depend on timings: skip test if outside margin.
if (!(interval < margin)) return error.SkipZigTest;
}
test "Timer" {
@ -280,7 +282,9 @@ test "Timer" {
var timer = try Timer.start();
sleep(10 * ns_per_ms);
const time_0 = timer.read();
testing.expect(time_0 > 0 and time_0 < margin);
testing.expect(time_0 > 0);
// Tests should not depend on timings: skip test if outside margin.
if (!(time_0 < margin)) return error.SkipZigTest;
const time_1 = timer.lap();
testing.expect(time_1 >= time_0);