build: move test-filter build parameter to fix release builds

This commit is contained in:
CJ van den Berg 2025-10-10 09:40:38 +02:00
parent c7b46856bb
commit b30b0a69bd
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -11,6 +11,7 @@ pub fn build(b: *std.Build) void {
const use_llvm = b.option(bool, "use_llvm", "Enable llvm backend (default: none)"); const use_llvm = b.option(bool, "use_llvm", "Enable llvm backend (default: none)");
const pie = b.option(bool, "pie", "Produce an executable with position independent code (default: none)"); const pie = b.option(bool, "pie", "Produce an executable with position independent code (default: none)");
const gui = b.option(bool, "gui", "Standalone GUI mode") orelse false; const gui = b.option(bool, "gui", "Standalone GUI mode") orelse false;
const test_filters = b.option([]const []const u8, "test-filter", "Skip tests that do not match any filter") orelse &[0][]const u8{};
const run_step = b.step("run", "Run the app"); const run_step = b.step("run", "Run the app");
const check_step = b.step("check", "Check the app"); const check_step = b.step("check", "Check the app");
@ -47,6 +48,7 @@ pub fn build(b: *std.Build) void {
gui, gui,
version.items, version.items,
all_targets, all_targets,
test_filters,
); );
} }
@ -64,6 +66,7 @@ fn build_development(
gui: bool, gui: bool,
version: []const u8, version: []const u8,
_: bool, // all_targets _: bool, // all_targets
test_filters: []const []const u8,
) void { ) void {
const target = b.standardTargetOptions(.{ .default_target = .{ .abi = if (builtin.os.tag == .linux and !tracy_enabled) .musl else null } }); const target = b.standardTargetOptions(.{ .default_target = .{ .abi = if (builtin.os.tag == .linux and !tracy_enabled) .musl else null } });
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
@ -84,6 +87,7 @@ fn build_development(
pie, pie,
gui, gui,
version, version,
test_filters,
); );
} }
@ -101,6 +105,7 @@ fn build_release(
_: bool, //gui _: bool, //gui
version: []const u8, version: []const u8,
all_targets: bool, all_targets: bool,
test_filters: []const []const u8,
) void { ) void {
const targets: []const std.Target.Query = if (all_targets) &.{ const targets: []const std.Target.Query = if (all_targets) &.{
.{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .musl }, .{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .musl },
@ -166,6 +171,7 @@ fn build_release(
pie, pie,
false, //gui false, //gui
version, version,
test_filters,
); );
build_exe( build_exe(
@ -184,6 +190,7 @@ fn build_release(
pie, pie,
false, //gui false, //gui
version, version,
test_filters,
); );
if (t.os_tag == .windows) { if (t.os_tag == .windows) {
@ -203,6 +210,7 @@ fn build_release(
pie, pie,
true, //gui true, //gui
version, version,
test_filters,
); );
build_exe( build_exe(
@ -221,6 +229,7 @@ fn build_release(
pie, pie,
true, //gui true, //gui
version, version,
test_filters,
); );
} }
} }
@ -242,6 +251,7 @@ pub fn build_exe(
pie: ?bool, pie: ?bool,
gui: bool, gui: bool,
version: []const u8, version: []const u8,
test_filters: []const []const u8,
) void { ) void {
const options = b.addOptions(); const options = b.addOptions();
options.addOption(bool, "enable_tracy", tracy_enabled); options.addOption(bool, "enable_tracy", tracy_enabled);
@ -712,7 +722,6 @@ pub fn build_exe(
check_exe.root_module.addImport("version_info", b.createModule(.{ .root_source_file = version_info_file })); check_exe.root_module.addImport("version_info", b.createModule(.{ .root_source_file = version_info_file }));
check_step.dependOn(&check_exe.step); check_step.dependOn(&check_exe.step);
const test_filters = b.option([]const []const u8, "test-filter", "Skip tests that do not match any filter") orelse &[0][]const u8{};
const tests = b.addTest(.{ const tests = b.addTest(.{
.root_module = b.createModule(.{ .root_module = b.createModule(.{
.root_source_file = b.path("test/tests.zig"), .root_source_file = b.path("test/tests.zig"),