| author | |
| committer | |
| log | 50056a5b3ad29695c795534cebbd031408633813 |
| tree | 10a8be75d6a44a93451a92aa1aeabfd1538d5f74 |
| parent | db8330adaf760a1a73237bfb90428d5d22610657 |
| signature |
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 \ |
| 51 | 51 | --search-prefix "$PREFIX" \ |
| 52 | 52 | --zig-lib-dir "$PWD/../lib" \ |
| 53 | 53 | -Denable-superhtml \ |
| 54 | --test-timeout-ms 60_000 | |
| 54 | --test-timeout 60s | |
| 55 | 55 | |
| 56 | 56 | stage3-debug/bin/zig build \ |
| 57 | 57 | --prefix stage4-debug \ |
ci/aarch64-linux-release.sh+1-1| ... | ... | @@ -51,7 +51,7 @@ stage3-release/bin/zig build test docs \ |
| 51 | 51 | --search-prefix "$PREFIX" \ |
| 52 | 52 | --zig-lib-dir "$PWD/../lib" \ |
| 53 | 53 | -Denable-superhtml \ |
| 54 | --test-timeout-ms 60_000 | |
| 54 | --test-timeout 60s | |
| 55 | 55 | |
| 56 | 56 | # Ensure that stage3 and stage4 are byte-for-byte identical. |
| 57 | 57 | stage3-release/bin/zig build \ |
ci/aarch64-macos-debug.sh+1-1| ... | ... | @@ -47,4 +47,4 @@ stage3-debug/bin/zig build test docs \ |
| 47 | 47 | -Dstatic-llvm \ |
| 48 | 48 | -Dskip-non-native \ |
| 49 | 49 | --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 \ |
| 47 | 47 | -Dstatic-llvm \ |
| 48 | 48 | -Dskip-non-native \ |
| 49 | 49 | --search-prefix "$PREFIX" \ |
| 50 | --test-timeout-ms 60_000 | |
| 50 | --test-timeout 60s | |
| 51 | 51 | |
| 52 | 52 | # Ensure that stage3 and stage4 are byte-for-byte identical. |
| 53 | 53 | stage3-release/bin/zig build \ |
ci/aarch64-windows.ps1+1-1| ... | ... | @@ -59,7 +59,7 @@ Write-Output "Main test suite..." |
| 59 | 59 | -Dstatic-llvm ` |
| 60 | 60 | -Dskip-non-native ` |
| 61 | 61 | -Denable-symlinks-windows ` |
| 62 | --test-timeout-ms 60_000 | |
| 62 | --test-timeout 60s | |
| 63 | 63 | CheckLastExitCode |
| 64 | 64 | |
| 65 | 65 | # 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 \ |
| 51 | 51 | -Dtarget=native-native-musl \ |
| 52 | 52 | --search-prefix "$PREFIX" \ |
| 53 | 53 | --zig-lib-dir "$PWD/../lib" \ |
| 54 | --test-timeout-ms 120_000 | |
| 54 | --test-timeout 2m | |
| 55 | 55 | |
| 56 | 56 | stage3-debug/bin/zig build \ |
| 57 | 57 | --prefix stage4-debug \ |
ci/loongarch64-linux-release.sh+1-1| ... | ... | @@ -51,7 +51,7 @@ stage3-release/bin/zig build test docs \ |
| 51 | 51 | -Dtarget=native-native-musl \ |
| 52 | 52 | --search-prefix "$PREFIX" \ |
| 53 | 53 | --zig-lib-dir "$PWD/../lib" \ |
| 54 | --test-timeout-ms 120_000 | |
| 54 | --test-timeout 2m | |
| 55 | 55 | |
| 56 | 56 | # Ensure that stage3 and stage4 are byte-for-byte identical. |
| 57 | 57 | stage3-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 |
| 52 | 52 | -Dtarget=native-native-musl \ |
| 53 | 53 | --search-prefix "$PREFIX" \ |
| 54 | 54 | --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 |
| 52 | 52 | -Dtarget=native-native-musl \ |
| 53 | 53 | --search-prefix "$PREFIX" \ |
| 54 | 54 | --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 \ |
| 52 | 52 | -Dskip-macos \ |
| 53 | 53 | --search-prefix "$PREFIX" \ |
| 54 | 54 | --zig-lib-dir "$PWD/../lib" \ |
| 55 | --test-timeout-ms 60_000 | |
| 55 | --test-timeout 60s | |
| 56 | 56 | |
| 57 | 57 | stage3-debug/bin/zig build \ |
| 58 | 58 | --prefix stage4-debug \ |
ci/x86_64-freebsd-release.sh+1-1| ... | ... | @@ -52,7 +52,7 @@ stage3-release/bin/zig build test docs \ |
| 52 | 52 | -Dskip-macos \ |
| 53 | 53 | --search-prefix "$PREFIX" \ |
| 54 | 54 | --zig-lib-dir "$PWD/../lib" \ |
| 55 | --test-timeout-ms 60_000 | |
| 55 | --test-timeout 60s | |
| 56 | 56 | |
| 57 | 57 | # Ensure that stage3 and stage4 are byte-for-byte identical. |
| 58 | 58 | stage3-release/bin/zig build \ |
ci/x86_64-linux-debug-llvm.sh+1-1| ... | ... | @@ -62,4 +62,4 @@ stage3-debug/bin/zig build test docs \ |
| 62 | 62 | --search-prefix "$PREFIX" \ |
| 63 | 63 | --zig-lib-dir "$PWD/../lib" \ |
| 64 | 64 | -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 \ |
| 62 | 62 | --search-prefix "$PREFIX" \ |
| 63 | 63 | --zig-lib-dir "$PWD/../lib" \ |
| 64 | 64 | -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 \ |
| 64 | 64 | --search-prefix "$PREFIX" \ |
| 65 | 65 | --zig-lib-dir "$PWD/../lib" \ |
| 66 | 66 | -Denable-superhtml \ |
| 67 | --test-timeout-ms 240_000 | |
| 67 | --test-timeout 4m | |
| 68 | 68 | |
| 69 | 69 | # Ensure that stage3 and stage4 are byte-for-byte identical. |
| 70 | 70 | stage3-release/bin/zig build \ |
ci/x86_64-windows-debug.ps1+1-1| ... | ... | @@ -60,7 +60,7 @@ Write-Output "Main test suite..." |
| 60 | 60 | -Dskip-non-native ` |
| 61 | 61 | -Dskip-release ` |
| 62 | 62 | -Denable-symlinks-windows ` |
| 63 | --test-timeout-ms 240_000 | |
| 63 | --test-timeout 4m | |
| 64 | 64 | CheckLastExitCode |
| 65 | 65 | |
| 66 | 66 | Write-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..." |
| 59 | 59 | -Dstatic-llvm ` |
| 60 | 60 | -Dskip-non-native ` |
| 61 | 61 | -Denable-symlinks-windows ` |
| 62 | --test-timeout-ms 240_000 | |
| 62 | --test-timeout 4m | |
| 63 | 63 | CheckLastExitCode |
| 64 | 64 | |
| 65 | 65 | # 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 { |
| 108 | 108 | var summary: ?Summary = null; |
| 109 | 109 | var max_rss: u64 = 0; |
| 110 | 110 | var skip_oom_steps = false; |
| 111 | var test_timeout_ms: ?u64 = null; | |
| 111 | var test_timeout_ns: ?u64 = null; | |
| 112 | 112 | var color: Color = .auto; |
| 113 | 113 | var help_menu = false; |
| 114 | 114 | var steps_menu = false; |
| ... | ... | @@ -189,14 +189,41 @@ pub fn main() !void { |
| 189 | 189 | }; |
| 190 | 190 | } else if (mem.eql(u8, arg, "--skip-oom-steps")) { |
| 191 | 191 | 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 }, | |
| 199 | 206 | }; |
| 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); | |
| 200 | 227 | } else if (mem.eql(u8, arg, "--search-prefix")) { |
| 201 | 228 | const search_prefix = nextArgOrFatal(args, &arg_idx); |
| 202 | 229 | builder.addSearchPrefix(search_prefix); |
| ... | ... | @@ -480,10 +507,7 @@ pub fn main() !void { |
| 480 | 507 | .max_rss_is_default = false, |
| 481 | 508 | .max_rss_mutex = .{}, |
| 482 | 509 | .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, | |
| 487 | 511 | |
| 488 | 512 | .watch = watch, |
| 489 | 513 | .web_server = undefined, // set after `prepare` |
| ... | ... | @@ -1584,7 +1608,8 @@ fn printUsage(b: *std.Build, w: *Writer) !void { |
| 1584 | 1608 | \\ -j<N> Limit concurrent jobs (default is to use all CPU cores) |
| 1585 | 1609 | \\ --maxrss <bytes> Limit memory usage (default is to use available memory) |
| 1586 | 1610 | \\ --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 | |
| 1588 | 1613 | \\ --fetch[=mode] Fetch dependency tree (optionally choose laziness) and exit |
| 1589 | 1614 | \\ needed (Default) Lazy dependencies are fetched as needed |
| 1590 | 1615 | \\ all Lazy dependencies are always fetched |
lib/std/Build/Step/Run.zig+1-1| ... | ... | @@ -1814,7 +1814,7 @@ fn pollZigTest( |
| 1814 | 1814 | // test. For instance, if the test runner leaves this much time between us requesting a test to |
| 1815 | 1815 | // start and it acknowledging the test starting, we terminate the child and raise an error. This |
| 1816 | 1816 | // *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); | |
| 1818 | 1818 | |
| 1819 | 1819 | const stdout = poller.reader(.stdout); |
| 1820 | 1820 | const stderr = poller.reader(.stderr); |