commit ea45895a2dd75200c36f9f51cb54384476224f89 (tree)
parent 9df02121d0d87c17173f79d55692bed9cb65722c
Author: Jacob Young <jacobly0@users.noreply.github.com>
Date: Wed, 22 Apr 2026 12:02:13 -0400
tests: cleanup c abi test runner
Diffstat:
2 files changed, 30 insertions(+), 34 deletions(-)
diff --git a/build.zig b/build.zig
@@ -416,7 +416,7 @@ pub fn build(b: *std.Build) !void {
chosen_opt_modes_buf[chosen_mode_index] = builtin.OptimizeMode.ReleaseSmall;
chosen_mode_index += 1;
}
- const optimization_modes = chosen_opt_modes_buf[0..chosen_mode_index];
+ const optimize_modes = chosen_opt_modes_buf[0..chosen_mode_index];
const test_only: ?tests.ModuleTestOptions.TestOnly = if (no_matrix)
.default
@@ -476,7 +476,7 @@ pub fn build(b: *std.Build) !void {
.root_src = "test/behavior.zig",
.name = "behavior",
.desc = "Run the behavior tests",
- .optimize_modes = optimization_modes,
+ .optimize_modes = optimize_modes,
.include_paths = &.{},
.sanitize_thread = sanitize_thread,
.skip_single_threaded = skip_single_threaded,
@@ -502,7 +502,7 @@ pub fn build(b: *std.Build) !void {
.root_src = "lib/compiler_rt.zig",
.name = "compiler-rt",
.desc = "Run the compiler_rt tests",
- .optimize_modes = optimization_modes,
+ .optimize_modes = optimize_modes,
.include_paths = &.{},
.sanitize_thread = sanitize_thread,
.skip_single_threaded = true,
@@ -529,7 +529,7 @@ pub fn build(b: *std.Build) !void {
.root_src = "lib/std/std.zig",
.name = "std",
.desc = "Run the standard library tests",
- .optimize_modes = optimization_modes,
+ .optimize_modes = optimize_modes,
.include_paths = &.{},
.sanitize_thread = sanitize_thread,
.skip_single_threaded = skip_single_threaded,
@@ -555,7 +555,7 @@ pub fn build(b: *std.Build) !void {
.root_src = "test/c.zig",
.name = "libc",
.desc = "Run the libc API tests",
- .optimize_modes = optimization_modes,
+ .optimize_modes = optimize_modes,
.include_paths = &.{},
.sanitize_thread = sanitize_thread,
.skip_single_threaded = true,
@@ -599,13 +599,14 @@ pub fn build(b: *std.Build) !void {
test_step.dependOn(tests.addStandaloneTests(
b,
- optimization_modes,
+ optimize_modes,
enable_macos_sdk,
enable_ios_sdk,
enable_symlinks_windows,
));
test_step.dependOn(tests.addCAbiTests(b, .{
.test_target_filters = test_target_filters,
+ .optimize_modes = optimize_modes,
.skip_non_native = skip_non_native,
.skip_wasm = skip_wasm,
.skip_freebsd = skip_freebsd,
@@ -615,19 +616,18 @@ pub fn build(b: *std.Build) !void {
.skip_darwin = skip_darwin,
.skip_linux = skip_linux,
.skip_llvm = skip_llvm,
- .skip_release = skip_release,
.max_rss = 3_300_000_000,
}));
test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, enable_ios_sdk, enable_symlinks_windows));
test_step.dependOn(tests.addStackTraceTests(b, test_filters, skip_non_native));
- test_step.dependOn(tests.addErrorTraceTests(b, test_filters, optimization_modes, skip_non_native));
+ test_step.dependOn(tests.addErrorTraceTests(b, test_filters, optimize_modes, skip_non_native));
test_step.dependOn(tests.addCliTests(b));
if (tests.addDebuggerTests(b, .{
.test_filters = test_filters,
.test_target_filters = test_target_filters,
.gdb = b.option([]const u8, "gdb", "path to gdb binary"),
.lldb = b.option([]const u8, "lldb", "path to lldb binary"),
- .optimize_modes = optimization_modes,
+ .optimize_modes = optimize_modes,
.skip_single_threaded = skip_single_threaded,
.skip_libc = skip_libc,
})) |test_debugger_step| test_step.dependOn(test_debugger_step);
@@ -663,7 +663,7 @@ pub fn build(b: *std.Build) !void {
if (!skip_test_incremental) test_step.dependOn(test_incremental_step);
if (tests.addLibcTestNszTests(b, .{
- .optimize_modes = optimization_modes,
+ .optimize_modes = optimize_modes,
.test_filters = test_filters,
.test_target_filters = test_target_filters,
.skip_wasm = skip_wasm,
diff --git a/test/tests.zig b/test/tests.zig
@@ -2749,6 +2749,7 @@ pub fn wouldUseLlvm(use_llvm: ?bool, query: std.Target.Query, optimize_mode: Opt
const CAbiTestOptions = struct {
test_target_filters: []const []const u8,
+ optimize_modes: []const OptimizeMode,
skip_non_native: bool,
skip_wasm: bool,
skip_freebsd: bool,
@@ -2758,43 +2759,38 @@ const CAbiTestOptions = struct {
skip_darwin: bool,
skip_linux: bool,
skip_llvm: bool,
- skip_release: bool,
max_rss: usize = 0,
};
pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
const step = b.step("test-c-abi", "Run the C ABI tests");
- const optimize_modes: [3]OptimizeMode = .{ .Debug, .ReleaseSafe, .ReleaseFast };
+ for (c_abi_targets) |c_abi_target| {
+ if (options.skip_non_native and !c_abi_target.target.isNative()) continue;
- for (optimize_modes) |optimize_mode| {
- if (optimize_mode != .Debug and options.skip_release) continue;
+ if (options.skip_wasm and c_abi_target.target.cpu_arch != null and c_abi_target.target.cpu_arch.?.isWasm()) continue;
- for (c_abi_targets) |c_abi_target| {
- if (options.skip_non_native and !c_abi_target.target.isNative()) continue;
+ if (options.skip_freebsd and c_abi_target.target.os_tag == .freebsd) continue;
+ if (options.skip_netbsd and c_abi_target.target.os_tag == .netbsd) continue;
+ if (options.skip_openbsd and c_abi_target.target.os_tag == .openbsd) continue;
+ if (options.skip_windows and c_abi_target.target.os_tag == .windows) continue;
+ if (options.skip_darwin and c_abi_target.target.os_tag != null and c_abi_target.target.os_tag.?.isDarwin()) continue;
+ if (options.skip_linux and c_abi_target.target.os_tag == .linux) continue;
- if (options.skip_wasm and c_abi_target.target.cpu_arch != null and c_abi_target.target.cpu_arch.?.isWasm()) continue;
+ const resolved_target = b.resolveTargetQuery(c_abi_target.target);
+ const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM");
+ const target = &resolved_target.result;
- if (options.skip_freebsd and c_abi_target.target.os_tag == .freebsd) continue;
- if (options.skip_netbsd and c_abi_target.target.os_tag == .netbsd) continue;
- if (options.skip_openbsd and c_abi_target.target.os_tag == .openbsd) continue;
- if (options.skip_windows and c_abi_target.target.os_tag == .windows) continue;
- if (options.skip_darwin and c_abi_target.target.os_tag != null and c_abi_target.target.os_tag.?.isDarwin()) continue;
- if (options.skip_linux and c_abi_target.target.os_tag == .linux) continue;
+ if (options.test_target_filters.len > 0) {
+ for (options.test_target_filters) |filter| {
+ if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
+ } else continue;
+ }
- const would_use_llvm = wouldUseLlvm(c_abi_target.use_llvm, c_abi_target.target, .Debug);
+ for (options.optimize_modes) |optimize_mode| {
+ const would_use_llvm = wouldUseLlvm(c_abi_target.use_llvm, c_abi_target.target, optimize_mode);
if (options.skip_llvm and would_use_llvm) continue;
- const resolved_target = b.resolveTargetQuery(c_abi_target.target);
- const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM");
- const target = &resolved_target.result;
-
- if (options.test_target_filters.len > 0) {
- for (options.test_target_filters) |filter| {
- if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
- } else continue;
- }
-
const test_mod = b.createModule(.{
.root_source_file = b.path("test/c_abi/main.zig"),
.target = resolved_target,