From 4a0b337345e2eb9a41a2db27c6e3f4d479f38f3a Mon Sep 17 00:00:00 2001 From: Tw Date: Sun, 28 Apr 2024 10:06:28 +0800 Subject: [PATCH] build: also apply test filter for dependency Signed-off-by: Tw --- build.zig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build.zig b/build.zig index f89a72a..d215af0 100644 --- a/build.zig +++ b/build.zig @@ -156,12 +156,13 @@ fn create_target_step(ctx: *const Ctx, main_path: []const u8, prog_path: []const } fn create_test_step(ctx: *const Ctx) !void { + const filter = ctx.b.option([]const u8, "test", "test filter"); // Creates a step for unit testing. const exe_tests = ctx.b.addTest(.{ .root_source_file = .{ .path = "src/tests/root.zig" }, .target = ctx.target, .optimize = ctx.optimize, - .filter = ctx.b.option([]const u8, "test", "test filter"), + .filter = filter, }); exe_tests.linkLibrary(ctx.libbpf_step); exe_tests.root_module.addImport("bpf", ctx.bpf); @@ -173,6 +174,11 @@ fn create_test_step(ctx: *const Ctx) !void { defer sample_dir.close(); var it = sample_dir.iterate(); while (try it.next()) |entry| { + if (filter) |f| { + if (!std.mem.containsAtLeast(u8, entry.name, 1, f)) { + continue; + } + } const bpf_prog = create_bpf_prog(ctx, try fs.path.join(ctx.b.allocator, &[_][]const u8{ "samples", entry.name })); exe_tests.root_module.addAnonymousImport(try std.fmt.allocPrint(ctx.b.allocator, "@{s}", .{fs.path.stem(entry.name)}), .{ .root_source_file = bpf_prog.getEmittedBin(),