aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/test/jest.zig
diff options
context:
space:
mode:
authorGravatar Ashcon Partovi <ashcon@partovi.net> 2023-05-23 22:33:32 -0700
committerGravatar GitHub <noreply@github.com> 2023-05-23 22:33:32 -0700
commitc3d402ce47e273b60e3a37164a6ba2be6e1eee5d (patch)
tree5e780162de9c723aba5126fd3276df51d9048c18 /src/bun.js/test/jest.zig
parentd9bdfcf1317f0ea14453cb2023daa07830d446d8 (diff)
downloadbun-c3d402ce47e273b60e3a37164a6ba2be6e1eee5d.tar.gz
bun-c3d402ce47e273b60e3a37164a6ba2be6e1eee5d.tar.zst
bun-c3d402ce47e273b60e3a37164a6ba2be6e1eee5d.zip
Implement `bun test --timeout` (#3040)
You can change the default per-test timeout in `bun test`: > bun test --timeout 10 The default timeout is 5000.
Diffstat (limited to 'src/bun.js/test/jest.zig')
-rw-r--r--src/bun.js/test/jest.zig9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig
index 8b06caa0f..dcc7a8149 100644
--- a/src/bun.js/test/jest.zig
+++ b/src/bun.js/test/jest.zig
@@ -35,8 +35,6 @@ const getAllocator = @import("../base.zig").getAllocator;
const JSPrivateDataPtr = @import("../base.zig").JSPrivateDataPtr;
const GetJSPrivateData = @import("../base.zig").GetJSPrivateData;
-const default_timeout = std.time.ms_per_min * 5;
-
const ZigString = JSC.ZigString;
const JSInternalPromise = JSC.JSInternalPromise;
const JSPromise = JSC.JSPromise;
@@ -360,8 +358,6 @@ pub const TestRunner = struct {
only: bool = false,
last_file: u64 = 0,
- timeout_seconds: f64 = 5.0,
-
allocator: std.mem.Allocator,
callback: *Callback = undefined,
@@ -376,6 +372,7 @@ pub const TestRunner = struct {
snapshots: Snapshots,
+ default_timeout_ms: u32 = 0,
test_timeout_timer: ?*bun.uws.Timer = null,
last_test_timeout_timer_duration: u32 = 0,
active_test_for_timeout: ?TestRunner.Test.ID = null,
@@ -3243,7 +3240,7 @@ pub const TestScope = struct {
skipped: bool = false,
is_todo: bool = false,
snapshot_count: usize = 0,
- timeout_millis: u32 = default_timeout,
+ timeout_millis: u32 = 0,
pub const Class = NewClass(
void,
@@ -3382,7 +3379,7 @@ pub const TestScope = struct {
.label = label,
.callback = function.asObjectRef(),
.parent = DescribeScope.active,
- .timeout_millis = if (arguments.len > 2) @intCast(u32, @max(args[2].coerce(i32, ctx), 0)) else default_timeout,
+ .timeout_millis = if (arguments.len > 2) @intCast(u32, @max(args[2].coerce(i32, ctx), 0)) else Jest.runner.?.default_timeout_ms,
}) catch unreachable;
if (test_elapsed_timer == null) create_tiemr: {