mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
compiler: rename --test-timeout-ms to --test-timeout
The unit can now be specified in the argument.
This commit is contained in:
parent
db8330adaf
commit
50056a5b3a
@ -51,7 +51,7 @@ stage3-debug/bin/zig build test docs \
|
|||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--zig-lib-dir "$PWD/../lib" \
|
--zig-lib-dir "$PWD/../lib" \
|
||||||
-Denable-superhtml \
|
-Denable-superhtml \
|
||||||
--test-timeout-ms 60_000
|
--test-timeout 60s
|
||||||
|
|
||||||
stage3-debug/bin/zig build \
|
stage3-debug/bin/zig build \
|
||||||
--prefix stage4-debug \
|
--prefix stage4-debug \
|
||||||
|
|||||||
@ -51,7 +51,7 @@ stage3-release/bin/zig build test docs \
|
|||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--zig-lib-dir "$PWD/../lib" \
|
--zig-lib-dir "$PWD/../lib" \
|
||||||
-Denable-superhtml \
|
-Denable-superhtml \
|
||||||
--test-timeout-ms 60_000
|
--test-timeout 60s
|
||||||
|
|
||||||
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
||||||
stage3-release/bin/zig build \
|
stage3-release/bin/zig build \
|
||||||
|
|||||||
@ -47,4 +47,4 @@ stage3-debug/bin/zig build test docs \
|
|||||||
-Dstatic-llvm \
|
-Dstatic-llvm \
|
||||||
-Dskip-non-native \
|
-Dskip-non-native \
|
||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--test-timeout-ms 60_000
|
--test-timeout 60s
|
||||||
|
|||||||
@ -47,7 +47,7 @@ stage3-release/bin/zig build test docs \
|
|||||||
-Dstatic-llvm \
|
-Dstatic-llvm \
|
||||||
-Dskip-non-native \
|
-Dskip-non-native \
|
||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--test-timeout-ms 60_000
|
--test-timeout 60s
|
||||||
|
|
||||||
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
||||||
stage3-release/bin/zig build \
|
stage3-release/bin/zig build \
|
||||||
|
|||||||
@ -59,7 +59,7 @@ Write-Output "Main test suite..."
|
|||||||
-Dstatic-llvm `
|
-Dstatic-llvm `
|
||||||
-Dskip-non-native `
|
-Dskip-non-native `
|
||||||
-Denable-symlinks-windows `
|
-Denable-symlinks-windows `
|
||||||
--test-timeout-ms 60_000
|
--test-timeout 60s
|
||||||
CheckLastExitCode
|
CheckLastExitCode
|
||||||
|
|
||||||
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
||||||
|
|||||||
@ -51,7 +51,7 @@ stage3-debug/bin/zig build test docs \
|
|||||||
-Dtarget=native-native-musl \
|
-Dtarget=native-native-musl \
|
||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--zig-lib-dir "$PWD/../lib" \
|
--zig-lib-dir "$PWD/../lib" \
|
||||||
--test-timeout-ms 120_000
|
--test-timeout 2m
|
||||||
|
|
||||||
stage3-debug/bin/zig build \
|
stage3-debug/bin/zig build \
|
||||||
--prefix stage4-debug \
|
--prefix stage4-debug \
|
||||||
|
|||||||
@ -51,7 +51,7 @@ stage3-release/bin/zig build test docs \
|
|||||||
-Dtarget=native-native-musl \
|
-Dtarget=native-native-musl \
|
||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--zig-lib-dir "$PWD/../lib" \
|
--zig-lib-dir "$PWD/../lib" \
|
||||||
--test-timeout-ms 120_000
|
--test-timeout 2m
|
||||||
|
|
||||||
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
||||||
stage3-release/bin/zig build \
|
stage3-release/bin/zig build \
|
||||||
|
|||||||
@ -52,4 +52,4 @@ stage3-debug/bin/zig build test-cases test-modules test-unit test-c-abi test-sta
|
|||||||
-Dtarget=native-native-musl \
|
-Dtarget=native-native-musl \
|
||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--zig-lib-dir "$PWD/../lib" \
|
--zig-lib-dir "$PWD/../lib" \
|
||||||
--test-timeout-ms 120_000
|
--test-timeout 2m
|
||||||
|
|||||||
@ -52,4 +52,4 @@ stage3-release/bin/zig build test-cases test-modules test-unit test-c-abi test-s
|
|||||||
-Dtarget=native-native-musl \
|
-Dtarget=native-native-musl \
|
||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--zig-lib-dir "$PWD/../lib" \
|
--zig-lib-dir "$PWD/../lib" \
|
||||||
--test-timeout-ms 120_000
|
--test-timeout 2m
|
||||||
|
|||||||
@ -52,7 +52,7 @@ stage3-debug/bin/zig build test docs \
|
|||||||
-Dskip-macos \
|
-Dskip-macos \
|
||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--zig-lib-dir "$PWD/../lib" \
|
--zig-lib-dir "$PWD/../lib" \
|
||||||
--test-timeout-ms 60_000
|
--test-timeout 60s
|
||||||
|
|
||||||
stage3-debug/bin/zig build \
|
stage3-debug/bin/zig build \
|
||||||
--prefix stage4-debug \
|
--prefix stage4-debug \
|
||||||
|
|||||||
@ -52,7 +52,7 @@ stage3-release/bin/zig build test docs \
|
|||||||
-Dskip-macos \
|
-Dskip-macos \
|
||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--zig-lib-dir "$PWD/../lib" \
|
--zig-lib-dir "$PWD/../lib" \
|
||||||
--test-timeout-ms 60_000
|
--test-timeout 60s
|
||||||
|
|
||||||
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
||||||
stage3-release/bin/zig build \
|
stage3-release/bin/zig build \
|
||||||
|
|||||||
@ -62,4 +62,4 @@ stage3-debug/bin/zig build test docs \
|
|||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--zig-lib-dir "$PWD/../lib" \
|
--zig-lib-dir "$PWD/../lib" \
|
||||||
-Denable-superhtml \
|
-Denable-superhtml \
|
||||||
--test-timeout-ms 240_000
|
--test-timeout 4m
|
||||||
|
|||||||
@ -62,4 +62,4 @@ stage3-debug/bin/zig build test docs \
|
|||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--zig-lib-dir "$PWD/../lib" \
|
--zig-lib-dir "$PWD/../lib" \
|
||||||
-Denable-superhtml \
|
-Denable-superhtml \
|
||||||
--test-timeout-ms 240_000
|
--test-timeout 4m
|
||||||
|
|||||||
@ -64,7 +64,7 @@ stage3-release/bin/zig build test docs \
|
|||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--zig-lib-dir "$PWD/../lib" \
|
--zig-lib-dir "$PWD/../lib" \
|
||||||
-Denable-superhtml \
|
-Denable-superhtml \
|
||||||
--test-timeout-ms 240_000
|
--test-timeout 4m
|
||||||
|
|
||||||
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
||||||
stage3-release/bin/zig build \
|
stage3-release/bin/zig build \
|
||||||
|
|||||||
@ -60,7 +60,7 @@ Write-Output "Main test suite..."
|
|||||||
-Dskip-non-native `
|
-Dskip-non-native `
|
||||||
-Dskip-release `
|
-Dskip-release `
|
||||||
-Denable-symlinks-windows `
|
-Denable-symlinks-windows `
|
||||||
--test-timeout-ms 240_000
|
--test-timeout 4m
|
||||||
CheckLastExitCode
|
CheckLastExitCode
|
||||||
|
|
||||||
Write-Output "Build x86_64-windows-msvc behavior tests using the C backend..."
|
Write-Output "Build x86_64-windows-msvc behavior tests using the C backend..."
|
||||||
|
|||||||
@ -59,7 +59,7 @@ Write-Output "Main test suite..."
|
|||||||
-Dstatic-llvm `
|
-Dstatic-llvm `
|
||||||
-Dskip-non-native `
|
-Dskip-non-native `
|
||||||
-Denable-symlinks-windows `
|
-Denable-symlinks-windows `
|
||||||
--test-timeout-ms 240_000
|
--test-timeout 4m
|
||||||
CheckLastExitCode
|
CheckLastExitCode
|
||||||
|
|
||||||
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
||||||
|
|||||||
@ -108,7 +108,7 @@ pub fn main() !void {
|
|||||||
var summary: ?Summary = null;
|
var summary: ?Summary = null;
|
||||||
var max_rss: u64 = 0;
|
var max_rss: u64 = 0;
|
||||||
var skip_oom_steps = false;
|
var skip_oom_steps = false;
|
||||||
var test_timeout_ms: ?u64 = null;
|
var test_timeout_ns: ?u64 = null;
|
||||||
var color: Color = .auto;
|
var color: Color = .auto;
|
||||||
var help_menu = false;
|
var help_menu = false;
|
||||||
var steps_menu = false;
|
var steps_menu = false;
|
||||||
@ -189,14 +189,41 @@ pub fn main() !void {
|
|||||||
};
|
};
|
||||||
} else if (mem.eql(u8, arg, "--skip-oom-steps")) {
|
} else if (mem.eql(u8, arg, "--skip-oom-steps")) {
|
||||||
skip_oom_steps = true;
|
skip_oom_steps = true;
|
||||||
} else if (mem.eql(u8, arg, "--test-timeout-ms")) {
|
} else if (mem.eql(u8, arg, "--test-timeout")) {
|
||||||
const millis_str = nextArgOrFatal(args, &arg_idx);
|
const units: []const struct { []const u8, u64 } = &.{
|
||||||
test_timeout_ms = std.fmt.parseInt(u64, millis_str, 10) catch |err| {
|
.{ "ns", 1 },
|
||||||
std.debug.print("invalid millisecond count: '{s}': {s}\n", .{
|
.{ "nanosecond", 1 },
|
||||||
millis_str, @errorName(err),
|
.{ "us", std.time.ns_per_us },
|
||||||
});
|
.{ "microsecond", std.time.ns_per_us },
|
||||||
process.exit(1);
|
.{ "ms", std.time.ns_per_ms },
|
||||||
|
.{ "millisecond", std.time.ns_per_ms },
|
||||||
|
.{ "s", std.time.ns_per_s },
|
||||||
|
.{ "second", std.time.ns_per_s },
|
||||||
|
.{ "m", std.time.ns_per_min },
|
||||||
|
.{ "minute", std.time.ns_per_min },
|
||||||
|
.{ "h", std.time.ns_per_hour },
|
||||||
|
.{ "hour", std.time.ns_per_hour },
|
||||||
};
|
};
|
||||||
|
const timeout_str = nextArgOrFatal(args, &arg_idx);
|
||||||
|
const num_end_idx = std.mem.findLastNone(u8, timeout_str, "abcdefghijklmnopqrstuvwxyz") orelse fatal(
|
||||||
|
"invalid timeout '{s}': expected unit (ns, us, ms, s, m, h)",
|
||||||
|
.{timeout_str},
|
||||||
|
);
|
||||||
|
const num_str = timeout_str[0 .. num_end_idx + 1];
|
||||||
|
const unit_str = timeout_str[num_end_idx + 1 ..];
|
||||||
|
const unit_factor: f64 = for (units) |unit_and_factor| {
|
||||||
|
if (std.mem.eql(u8, unit_str, unit_and_factor[0])) {
|
||||||
|
break @floatFromInt(unit_and_factor[1]);
|
||||||
|
}
|
||||||
|
} else fatal(
|
||||||
|
"invalid timeout '{s}': invalid unit '{s}' (expected ns, us, ms, s, m, h)",
|
||||||
|
.{ timeout_str, unit_str },
|
||||||
|
);
|
||||||
|
const num_parsed = std.fmt.parseFloat(f64, num_str) catch |err| fatal(
|
||||||
|
"invalid timeout '{s}': invalid number '{s}' ({t})",
|
||||||
|
.{ timeout_str, num_str, err },
|
||||||
|
);
|
||||||
|
test_timeout_ns = std.math.lossyCast(u64, unit_factor * num_parsed);
|
||||||
} else if (mem.eql(u8, arg, "--search-prefix")) {
|
} else if (mem.eql(u8, arg, "--search-prefix")) {
|
||||||
const search_prefix = nextArgOrFatal(args, &arg_idx);
|
const search_prefix = nextArgOrFatal(args, &arg_idx);
|
||||||
builder.addSearchPrefix(search_prefix);
|
builder.addSearchPrefix(search_prefix);
|
||||||
@ -480,10 +507,7 @@ pub fn main() !void {
|
|||||||
.max_rss_is_default = false,
|
.max_rss_is_default = false,
|
||||||
.max_rss_mutex = .{},
|
.max_rss_mutex = .{},
|
||||||
.skip_oom_steps = skip_oom_steps,
|
.skip_oom_steps = skip_oom_steps,
|
||||||
.unit_test_timeout_ns = ns: {
|
.unit_test_timeout_ns = test_timeout_ns,
|
||||||
const ms = test_timeout_ms orelse break :ns null;
|
|
||||||
break :ns std.math.mul(u64, ms, std.time.ns_per_ms) catch null;
|
|
||||||
},
|
|
||||||
|
|
||||||
.watch = watch,
|
.watch = watch,
|
||||||
.web_server = undefined, // set after `prepare`
|
.web_server = undefined, // set after `prepare`
|
||||||
@ -1584,7 +1608,8 @@ fn printUsage(b: *std.Build, w: *Writer) !void {
|
|||||||
\\ -j<N> Limit concurrent jobs (default is to use all CPU cores)
|
\\ -j<N> Limit concurrent jobs (default is to use all CPU cores)
|
||||||
\\ --maxrss <bytes> Limit memory usage (default is to use available memory)
|
\\ --maxrss <bytes> Limit memory usage (default is to use available memory)
|
||||||
\\ --skip-oom-steps Instead of failing, skip steps that would exceed --maxrss
|
\\ --skip-oom-steps Instead of failing, skip steps that would exceed --maxrss
|
||||||
\\ --test-timeout-ms <ms> Limit execution time of unit tests, terminating if exceeded
|
\\ --test-timeout <timeout> Limit execution time of unit tests, terminating if exceeded.
|
||||||
|
\\ The timeout must include a unit: ns, us, ms, s, m, h
|
||||||
\\ --fetch[=mode] Fetch dependency tree (optionally choose laziness) and exit
|
\\ --fetch[=mode] Fetch dependency tree (optionally choose laziness) and exit
|
||||||
\\ needed (Default) Lazy dependencies are fetched as needed
|
\\ needed (Default) Lazy dependencies are fetched as needed
|
||||||
\\ all Lazy dependencies are always fetched
|
\\ all Lazy dependencies are always fetched
|
||||||
|
|||||||
@ -1814,7 +1814,7 @@ fn pollZigTest(
|
|||||||
// test. For instance, if the test runner leaves this much time between us requesting a test to
|
// test. For instance, if the test runner leaves this much time between us requesting a test to
|
||||||
// start and it acknowledging the test starting, we terminate the child and raise an error. This
|
// start and it acknowledging the test starting, we terminate the child and raise an error. This
|
||||||
// *should* never happen, but could in theory be caused by some very unlucky IB in a test.
|
// *should* never happen, but could in theory be caused by some very unlucky IB in a test.
|
||||||
const response_timeout_ns = options.unit_test_timeout_ns orelse 60 * std.time.ns_per_s;
|
const response_timeout_ns = @max(options.unit_test_timeout_ns orelse 0, 60 * std.time.ns_per_s);
|
||||||
|
|
||||||
const stdout = poller.reader(.stdout);
|
const stdout = poller.reader(.stdout);
|
||||||
const stderr = poller.reader(.stderr);
|
const stderr = poller.reader(.stderr);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user