zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit d6d60fbebf1f83894f83871ba4969ab2d50bec24 (tree)
parent 9a6341a23b3b3a4e7146adb6ab8dca67a927b1c9
Author: Motiejus Jakštys <motiejus@jakstys.lt>
Date:   Thu, 12 Feb 2026 09:29:33 +0200

valgrind no timeout

Diffstat:
Mbuild.zig | 39+++++++++++++++++++++++++--------------
1 file changed, 25 insertions(+), 14 deletions(-)

diff --git a/build.zig b/build.zig @@ -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, .{});