zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 2871d32be727fc729ba4be0c615cb5fe97591391 (tree)
parent f253822415304fc069f68452f7f4abbded58a24e
Author: Michael Dusan <michael.dusan@gmail.com>
Date:   Wed,  7 Apr 2021 05:25:59 -0400

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

Diffstat:
Mlib/std/os/linux/io_uring.zig | 2+-
Mlib/std/time.zig | 8++++++--
2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/std/os/linux/io_uring.zig b/lib/std/os/linux/io_uring.zig @@ -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; } diff --git a/lib/std/time.zig b/lib/std/time.zig @@ -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);