authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-10-14 23:01:13+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-10-18 09:28:43+01:00
log50056a5b3ad29695c795534cebbd031408633813
tree10a8be75d6a44a93451a92aa1aeabfd1538d5f74
parentdb8330adaf760a1a73237bfb90428d5d22610657
signaturelock-open Commit is signed but in an unrecognized format.

compiler: rename `--test-timeout-ms` to `--test-timeout`

The unit can now be specified in the argument.

18 files changed, 55 insertions(+), 30 deletions(-)

ci/aarch64-linux-debug.sh+1-1
......@@ -51,7 +51,7 @@ stage3-debug/bin/zig build test docs \
5151 --search-prefix "$PREFIX" \
5252 --zig-lib-dir "$PWD/../lib" \
5353 -Denable-superhtml \
54 --test-timeout-ms 60_000
54 --test-timeout 60s
5555
5656stage3-debug/bin/zig build \
5757 --prefix stage4-debug \
ci/aarch64-linux-release.sh+1-1
......@@ -51,7 +51,7 @@ stage3-release/bin/zig build test docs \
5151 --search-prefix "$PREFIX" \
5252 --zig-lib-dir "$PWD/../lib" \
5353 -Denable-superhtml \
54 --test-timeout-ms 60_000
54 --test-timeout 60s
5555
5656# Ensure that stage3 and stage4 are byte-for-byte identical.
5757stage3-release/bin/zig build \
ci/aarch64-macos-debug.sh+1-1
......@@ -47,4 +47,4 @@ stage3-debug/bin/zig build test docs \
4747 -Dstatic-llvm \
4848 -Dskip-non-native \
4949 --search-prefix "$PREFIX" \
50 --test-timeout-ms 60_000
50 --test-timeout 60s
ci/aarch64-macos-release.sh+1-1
......@@ -47,7 +47,7 @@ stage3-release/bin/zig build test docs \
4747 -Dstatic-llvm \
4848 -Dskip-non-native \
4949 --search-prefix "$PREFIX" \
50 --test-timeout-ms 60_000
50 --test-timeout 60s
5151
5252# Ensure that stage3 and stage4 are byte-for-byte identical.
5353stage3-release/bin/zig build \
ci/aarch64-windows.ps1+1-1
......@@ -59,7 +59,7 @@ Write-Output "Main test suite..."
5959 -Dstatic-llvm `
6060 -Dskip-non-native `
6161 -Denable-symlinks-windows `
62 --test-timeout-ms 60_000
62 --test-timeout 60s
6363CheckLastExitCode
6464
6565# Ensure that stage3 and stage4 are byte-for-byte identical.
ci/loongarch64-linux-debug.sh+1-1
......@@ -51,7 +51,7 @@ stage3-debug/bin/zig build test docs \
5151 -Dtarget=native-native-musl \
5252 --search-prefix "$PREFIX" \
5353 --zig-lib-dir "$PWD/../lib" \
54 --test-timeout-ms 120_000
54 --test-timeout 2m
5555
5656stage3-debug/bin/zig build \
5757 --prefix stage4-debug \
ci/loongarch64-linux-release.sh+1-1
......@@ -51,7 +51,7 @@ stage3-release/bin/zig build test docs \
5151 -Dtarget=native-native-musl \
5252 --search-prefix "$PREFIX" \
5353 --zig-lib-dir "$PWD/../lib" \
54 --test-timeout-ms 120_000
54 --test-timeout 2m
5555
5656# Ensure that stage3 and stage4 are byte-for-byte identical.
5757stage3-release/bin/zig build \
ci/riscv64-linux-debug.sh+1-1
......@@ -52,4 +52,4 @@ stage3-debug/bin/zig build test-cases test-modules test-unit test-c-abi test-sta
5252 -Dtarget=native-native-musl \
5353 --search-prefix "$PREFIX" \
5454 --zig-lib-dir "$PWD/../lib" \
55 --test-timeout-ms 120_000
55 --test-timeout 2m
ci/riscv64-linux-release.sh+1-1
......@@ -52,4 +52,4 @@ stage3-release/bin/zig build test-cases test-modules test-unit test-c-abi test-s
5252 -Dtarget=native-native-musl \
5353 --search-prefix "$PREFIX" \
5454 --zig-lib-dir "$PWD/../lib" \
55 --test-timeout-ms 120_000
55 --test-timeout 2m
ci/x86_64-freebsd-debug.sh+1-1
......@@ -52,7 +52,7 @@ stage3-debug/bin/zig build test docs \
5252 -Dskip-macos \
5353 --search-prefix "$PREFIX" \
5454 --zig-lib-dir "$PWD/../lib" \
55 --test-timeout-ms 60_000
55 --test-timeout 60s
5656
5757stage3-debug/bin/zig build \
5858 --prefix stage4-debug \
ci/x86_64-freebsd-release.sh+1-1
......@@ -52,7 +52,7 @@ stage3-release/bin/zig build test docs \
5252 -Dskip-macos \
5353 --search-prefix "$PREFIX" \
5454 --zig-lib-dir "$PWD/../lib" \
55 --test-timeout-ms 60_000
55 --test-timeout 60s
5656
5757# Ensure that stage3 and stage4 are byte-for-byte identical.
5858stage3-release/bin/zig build \
ci/x86_64-linux-debug-llvm.sh+1-1
......@@ -62,4 +62,4 @@ stage3-debug/bin/zig build test docs \
6262 --search-prefix "$PREFIX" \
6363 --zig-lib-dir "$PWD/../lib" \
6464 -Denable-superhtml \
65 --test-timeout-ms 240_000
65 --test-timeout 4m
ci/x86_64-linux-debug.sh+1-1
......@@ -62,4 +62,4 @@ stage3-debug/bin/zig build test docs \
6262 --search-prefix "$PREFIX" \
6363 --zig-lib-dir "$PWD/../lib" \
6464 -Denable-superhtml \
65 --test-timeout-ms 240_000
65 --test-timeout 4m
ci/x86_64-linux-release.sh+1-1
......@@ -64,7 +64,7 @@ stage3-release/bin/zig build test docs \
6464 --search-prefix "$PREFIX" \
6565 --zig-lib-dir "$PWD/../lib" \
6666 -Denable-superhtml \
67 --test-timeout-ms 240_000
67 --test-timeout 4m
6868
6969# Ensure that stage3 and stage4 are byte-for-byte identical.
7070stage3-release/bin/zig build \
ci/x86_64-windows-debug.ps1+1-1
......@@ -60,7 +60,7 @@ Write-Output "Main test suite..."
6060 -Dskip-non-native `
6161 -Dskip-release `
6262 -Denable-symlinks-windows `
63 --test-timeout-ms 240_000
63 --test-timeout 4m
6464CheckLastExitCode
6565
6666Write-Output "Build x86_64-windows-msvc behavior tests using the C backend..."
ci/x86_64-windows-release.ps1+1-1
......@@ -59,7 +59,7 @@ Write-Output "Main test suite..."
5959 -Dstatic-llvm `
6060 -Dskip-non-native `
6161 -Denable-symlinks-windows `
62 --test-timeout-ms 240_000
62 --test-timeout 4m
6363CheckLastExitCode
6464
6565# Ensure that stage3 and stage4 are byte-for-byte identical.
lib/compiler/build_runner.zig+38-13
......@@ -108,7 +108,7 @@ pub fn main() !void {
108108 var summary: ?Summary = null;
109109 var max_rss: u64 = 0;
110110 var skip_oom_steps = false;
111 var test_timeout_ms: ?u64 = null;
111 var test_timeout_ns: ?u64 = null;
112112 var color: Color = .auto;
113113 var help_menu = false;
114114 var steps_menu = false;
......@@ -189,14 +189,41 @@ pub fn main() !void {
189189 };
190190 } else if (mem.eql(u8, arg, "--skip-oom-steps")) {
191191 skip_oom_steps = true;
192 } else if (mem.eql(u8, arg, "--test-timeout-ms")) {
193 const millis_str = nextArgOrFatal(args, &arg_idx);
194 test_timeout_ms = std.fmt.parseInt(u64, millis_str, 10) catch |err| {
195 std.debug.print("invalid millisecond count: '{s}': {s}\n", .{
196 millis_str, @errorName(err),
197 });
198 process.exit(1);
192 } else if (mem.eql(u8, arg, "--test-timeout")) {
193 const units: []const struct { []const u8, u64 } = &.{
194 .{ "ns", 1 },
195 .{ "nanosecond", 1 },
196 .{ "us", std.time.ns_per_us },
197 .{ "microsecond", std.time.ns_per_us },
198 .{ "ms", std.time.ns_per_ms },
199 .{ "millisecond", std.time.ns_per_ms },
200 .{ "s", std.time.ns_per_s },
201 .{ "second", std.time.ns_per_s },
202 .{ "m", std.time.ns_per_min },
203 .{ "minute", std.time.ns_per_min },
204 .{ "h", std.time.ns_per_hour },
205 .{ "hour", std.time.ns_per_hour },
199206 };
207 const timeout_str = nextArgOrFatal(args, &arg_idx);
208 const num_end_idx = std.mem.findLastNone(u8, timeout_str, "abcdefghijklmnopqrstuvwxyz") orelse fatal(
209 "invalid timeout '{s}': expected unit (ns, us, ms, s, m, h)",
210 .{timeout_str},
211 );
212 const num_str = timeout_str[0 .. num_end_idx + 1];
213 const unit_str = timeout_str[num_end_idx + 1 ..];
214 const unit_factor: f64 = for (units) |unit_and_factor| {
215 if (std.mem.eql(u8, unit_str, unit_and_factor[0])) {
216 break @floatFromInt(unit_and_factor[1]);
217 }
218 } else fatal(
219 "invalid timeout '{s}': invalid unit '{s}' (expected ns, us, ms, s, m, h)",
220 .{ timeout_str, unit_str },
221 );
222 const num_parsed = std.fmt.parseFloat(f64, num_str) catch |err| fatal(
223 "invalid timeout '{s}': invalid number '{s}' ({t})",
224 .{ timeout_str, num_str, err },
225 );
226 test_timeout_ns = std.math.lossyCast(u64, unit_factor * num_parsed);
200227 } else if (mem.eql(u8, arg, "--search-prefix")) {
201228 const search_prefix = nextArgOrFatal(args, &arg_idx);
202229 builder.addSearchPrefix(search_prefix);
......@@ -480,10 +507,7 @@ pub fn main() !void {
480507 .max_rss_is_default = false,
481508 .max_rss_mutex = .{},
482509 .skip_oom_steps = skip_oom_steps,
483 .unit_test_timeout_ns = ns: {
484 const ms = test_timeout_ms orelse break :ns null;
485 break :ns std.math.mul(u64, ms, std.time.ns_per_ms) catch null;
486 },
510 .unit_test_timeout_ns = test_timeout_ns,
487511
488512 .watch = watch,
489513 .web_server = undefined, // set after `prepare`
......@@ -1584,7 +1608,8 @@ fn printUsage(b: *std.Build, w: *Writer) !void {
15841608 \\ -j<N> Limit concurrent jobs (default is to use all CPU cores)
15851609 \\ --maxrss <bytes> Limit memory usage (default is to use available memory)
15861610 \\ --skip-oom-steps Instead of failing, skip steps that would exceed --maxrss
1587 \\ --test-timeout-ms <ms> Limit execution time of unit tests, terminating if exceeded
1611 \\ --test-timeout <timeout> Limit execution time of unit tests, terminating if exceeded.
1612 \\ The timeout must include a unit: ns, us, ms, s, m, h
15881613 \\ --fetch[=mode] Fetch dependency tree (optionally choose laziness) and exit
15891614 \\ needed (Default) Lazy dependencies are fetched as needed
15901615 \\ all Lazy dependencies are always fetched
lib/std/Build/Step/Run.zig+1-1
......@@ -1814,7 +1814,7 @@ fn pollZigTest(
18141814 // test. For instance, if the test runner leaves this much time between us requesting a test to
18151815 // start and it acknowledging the test starting, we terminate the child and raise an error. This
18161816 // *should* never happen, but could in theory be caused by some very unlucky IB in a test.
1817 const response_timeout_ns = options.unit_test_timeout_ns orelse 60 * std.time.ns_per_s;
1817 const response_timeout_ns = @max(options.unit_test_timeout_ns orelse 0, 60 * std.time.ns_per_s);
18181818
18191819 const stdout = poller.reader(.stdout);
18201820 const stderr = poller.reader(.stderr);