From d6d60fbebf1f83894f83871ba4969ab2d50bec24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Thu, 12 Feb 2026 09:29:33 +0200 Subject: [PATCH] valgrind no timeout --- build.zig | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/build.zig b/build.zig index bc13bac0a8..08f8aefbe1 100644 --- 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, .{});