valgrind no timeout

This commit is contained in:
2026-02-12 09:29:33 +02:00
parent 9a6341a23b
commit d6d60fbebf

View File

@@ -48,7 +48,7 @@ pub fn build(b: *std.Build) !void {
const cc = b.option([]const u8, "cc", "C compiler") orelse "zig";
const no_exec = b.option(bool, "no-exec", "Compile test binary without running it") orelse false;
const valgrind = b.option(bool, "valgrind", "Run tests under valgrind") orelse false;
const test_timeout = b.option([]const u8, "test-timeout", "Test execution timeout (default: 10s, or 60s with valgrind)");
const test_timeout = b.option([]const u8, "test-timeout", "Test execution timeout (default: 10s, none with valgrind)");
const target = blk: {
var query = b.standardTargetOptionsQueryOnly(.{});
@@ -166,21 +166,32 @@ fn addTestStep(
.use_llvm = false,
.use_lld = false,
});
const timeout = test_timeout orelse if (valgrind) "300" else "10";
const timeout: ?[]const u8 = test_timeout orelse if (valgrind) null else "10";
if (valgrind) {
test_exe.setExecCmd(&.{
"timeout",
timeout,
"valgrind",
"--error-exitcode=2",
"--leak-check=full",
"--show-leak-kinds=all",
"--errors-for-leak-kinds=all",
"--track-fds=yes",
null,
});
if (timeout) |t|
test_exe.setExecCmd(&.{
"timeout",
t,
"valgrind",
"--error-exitcode=2",
"--leak-check=full",
"--show-leak-kinds=all",
"--errors-for-leak-kinds=all",
"--track-fds=yes",
null,
})
else
test_exe.setExecCmd(&.{
"valgrind",
"--error-exitcode=2",
"--leak-check=full",
"--show-leak-kinds=all",
"--errors-for-leak-kinds=all",
"--track-fds=yes",
null,
});
} else {
test_exe.setExecCmd(&.{ "timeout", timeout, null });
test_exe.setExecCmd(&.{ "timeout", timeout orelse "10", null });
}
if (no_exec) {
const install = b.addInstallArtifact(test_exe, .{});