@@ -196,7 +196,8 @@ const StepBuilder = struct {
196196pub fn build (b : * std.Build ) void {
197197 const target = b .standardTargetOptions (.{});
198198 const optimize = b .standardOptimizeOption (.{});
199- const coverage = b .option (bool , "coverage" , "Generate a coverage report with kcov" );
199+ const test_coverage = b .option (bool , "coverage" , "Generate a coverage report with kcov" );
200+ const test_focus_on_rule = b .option ([]const u8 , "test_focus_on_rule" , "Only run integration tests for this rule" );
200201
201202 const zlinter_lib_module = b .addModule ("zlinter" , .{
202203 .root_source_file = b .path ("src/lib/zlinter.zig" ),
@@ -222,7 +223,7 @@ pub fn build(b: *std.Build) void {
222223
223224 const unit_tests_exe = b .addTest (.{
224225 .root_module = zlinter_lib_module ,
225- .use_llvm = coverage ,
226+ .use_llvm = test_coverage ,
226227 });
227228
228229 // --------------------------------------------------------------------
@@ -269,6 +270,9 @@ pub fn build(b: *std.Build) void {
269270 install_coverage .step .dependOn (& merge_coverage .step );
270271
271272 const run_integration_tests = b .addSystemCommand (&.{ b .graph .zig_exe , "build" , "test" });
273+ if (test_focus_on_rule ) | r | {
274+ run_integration_tests .addArg (b .fmt ("-Dtest_focus_on_rule={s}" , .{r }));
275+ }
272276 run_integration_tests .setCwd (b .path ("./integration_tests" ));
273277 run_integration_tests .has_side_effects = true ;
274278
@@ -303,7 +307,7 @@ pub fn build(b: *std.Build) void {
303307 integration_check_step .dependOn (& run_integration_check .step );
304308
305309 const unit_test_step = b .step ("unit-test" , "Run unit tests" );
306- if (coverage orelse false ) {
310+ if (test_coverage orelse false ) {
307311 const cover_run = std .Build .Step .Run .create (b , "Unit test coverage" );
308312 cover_run .addArgs (&.{ kcov_bin , "--clean" , "--collect-only" });
309313 cover_run .addPrefixedDirectoryArg ("--include-pattern=" , b .path ("src" ));
@@ -320,10 +324,10 @@ pub fn build(b: *std.Build) void {
320324 const test_rule_exe = b .addTest (.{
321325 .name = b .fmt ("{s}_unit_test_coverage" , .{rule_import .name }),
322326 .root_module = rule_import .module ,
323- .use_llvm = coverage ,
327+ .use_llvm = test_coverage ,
324328 });
325329
326- if (coverage orelse false ) {
330+ if (test_coverage orelse false ) {
327331 const cover_run = std .Build .Step .Run .create (b , "Unit test coverage" );
328332 cover_run .addArgs (&.{ kcov_bin , "--clean" , "--collect-only" });
329333 cover_run .addPrefixedDirectoryArg ("--include-pattern=" , b .path ("src" ));
0 commit comments