From d5a2fa9062574238e4363fcfdd6e1604ada6bb2e Mon Sep 17 00:00:00 2001 From: Trey Turner Date: Mon, 16 Sep 2024 18:01:20 -0500 Subject: [PATCH] feat: support default test timeout in bunfig.toml --- docs/runtime/bunfig.md | 9 +++++++++ src/bunfig.zig | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/docs/runtime/bunfig.md b/docs/runtime/bunfig.md index 4af518744556a2..7e22c6d492fb8a 100644 --- a/docs/runtime/bunfig.md +++ b/docs/runtime/bunfig.md @@ -144,6 +144,15 @@ Same as the top-level `smol` field, but only applies to `bun test`. smol = true ``` +### `test.timeout` + +A default timeout for each test in milliseconds. Default `5000`. Use `--timeout` to override. + +```toml +[test] +timeout = 15000 +``` + ### `test.coverage` Enables coverage reporting. Default `false`. Use `--coverage` to override. diff --git a/src/bunfig.zig b/src/bunfig.zig index ede8389cde3c3d..7217886285152b 100644 --- a/src/bunfig.zig +++ b/src/bunfig.zig @@ -253,6 +253,11 @@ pub const Bunfig = struct { this.ctx.runtime_options.smol = expr.data.e_boolean.value; } + if (test_.get("timeout")) |expr| { + try this.expect(expr, .e_big_int); + this.ctx.test_options.default_timeout_ms = expr.data.e_big_int.value; + } + if (test_.get("coverage")) |expr| { try this.expect(expr, .e_boolean); this.ctx.test_options.coverage.enabled = expr.data.e_boolean.value;