authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-11-23 15:45:15+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-11-24 22:11:17+01:00
log9c7776a9389f2c752c9cc66b653844a7d935f719
tree7ce9635e7165f88e9011fdea459770c4e2b92468
parent1e0267a96b5bb1e0703f81778715346441e3c54f
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

test: Enable -Dtest-target-filter=... to work for test-c-abi.


2 files changed, 22 insertions(+), 5 deletions(-)

build.zig+5-1
......@@ -541,7 +541,11 @@ pub fn build(b: *std.Build) !void {
541541 enable_ios_sdk,
542542 enable_symlinks_windows,
543543 ));
544 test_step.dependOn(tests.addCAbiTests(b, skip_non_native, skip_release));
544 test_step.dependOn(tests.addCAbiTests(b, .{
545 .test_target_filters = test_target_filters,
546 .skip_non_native = skip_non_native,
547 .skip_release = skip_release,
548 }));
545549 test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, enable_ios_sdk, enable_symlinks_windows));
546550 test_step.dependOn(tests.addStackTraceTests(b, test_filters, optimization_modes));
547551 test_step.dependOn(tests.addCliTests(b));
test/tests.zig+17-4
......@@ -1486,19 +1486,32 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
14861486 return step;
14871487}
14881488
1489pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *Step {
1489const CAbiTestOptions = struct {
1490 test_target_filters: []const []const u8,
1491 skip_non_native: bool,
1492 skip_release: bool,
1493};
1494
1495pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
14901496 const step = b.step("test-c-abi", "Run the C ABI tests");
14911497
14921498 const optimize_modes: [3]OptimizeMode = .{ .Debug, .ReleaseSafe, .ReleaseFast };
14931499
14941500 for (optimize_modes) |optimize_mode| {
1495 if (optimize_mode != .Debug and skip_release) continue;
1501 if (optimize_mode != .Debug and options.skip_release) continue;
14961502
14971503 for (c_abi_targets) |c_abi_target| {
1498 if (skip_non_native and !c_abi_target.target.isNative()) continue;
1504 if (options.skip_non_native and !c_abi_target.target.isNative()) continue;
14991505
15001506 const resolved_target = b.resolveTargetQuery(c_abi_target.target);
15011507 const target = resolved_target.result;
1508 const triple_txt = target.zigTriple(b.allocator) catch @panic("OOM");
1509
1510 if (options.test_target_filters.len > 0) {
1511 for (options.test_target_filters) |filter| {
1512 if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
1513 } else continue;
1514 }
15021515
15031516 if (target.os.tag == .windows and target.cpu.arch == .aarch64) {
15041517 // https://github.com/ziglang/zig/issues/14908
......@@ -1507,7 +1520,7 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S
15071520
15081521 const test_step = b.addTest(.{
15091522 .name = b.fmt("test-c-abi-{s}-{s}-{s}{s}{s}{s}", .{
1510 target.zigTriple(b.allocator) catch @panic("OOM"),
1523 triple_txt,
15111524 target.cpu.model.name,
15121525 @tagName(optimize_mode),
15131526 if (c_abi_target.use_llvm == true)