Commit 9d10246a80

Alex Rønne Petersen <alex@alexrp.com>
2024-11-23 18:06:27
test: Enable -Dtest-target-filter=... to work for test-debugger.
1 parent 2a29381
Changed files (2)
test/src/Debugger.zig
@@ -4,6 +4,7 @@ root_step: *std.Build.Step,
 
 pub const Options = struct {
     test_filters: []const []const u8,
+    test_target_filters: []const []const u8,
     gdb: ?[]const u8,
     lldb: ?[]const u8,
     optimize_modes: []const std.builtin.OptimizeMode,
@@ -1988,6 +1989,12 @@ fn addTest(
     for (db.options.test_filters) |test_filter| {
         if (std.mem.indexOf(u8, name, test_filter)) |_| return;
     }
+    if (db.options.test_target_filters.len > 0) {
+        const triple_txt = target.resolved.result.zigTriple(db.b.allocator) catch @panic("OOM");
+        for (db.options.test_target_filters) |filter| {
+            if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
+        } else return;
+    }
     const files_wf = db.b.addWriteFiles();
     const exe = db.b.addExecutable(.{
         .name = name,
build.zig
@@ -552,6 +552,7 @@ pub fn build(b: *std.Build) !void {
     test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filters, optimization_modes));
     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,