@@ -379,6 +379,8 @@ pub fn build(b: *std.Build) !void {
379
379
}
380
380
381
381
const test_filters = b .option ([]const []const u8 , "test-filter" , "Skip tests that do not match any filter" ) orelse &[0 ][]const u8 {};
382
+ const test_target_filters = b .option ([]const []const u8 , "test-target-filter" , "Skip tests whose target triple do not match any filter" ) orelse &[0 ][]const u8 {};
383
+ const test_slow_targets = b .option (bool , "test-slow-targets" , "Enable running module tests for targets that have a slow compiler backend" ) orelse false ;
382
384
383
385
const test_cases_options = b .addOptions ();
384
386
@@ -455,8 +457,12 @@ pub fn build(b: *std.Build) !void {
455
457
});
456
458
test_step .dependOn (test_cases_step );
457
459
458
- test_step .dependOn (tests .addModuleTests (b , .{
460
+ const test_modules_step = b .step ("test-modules" , "Run the per-target module tests" );
461
+
462
+ test_modules_step .dependOn (tests .addModuleTests (b , .{
459
463
.test_filters = test_filters ,
464
+ .test_target_filters = test_target_filters ,
465
+ .test_slow_targets = test_slow_targets ,
460
466
.root_src = "test/behavior.zig" ,
461
467
.name = "behavior" ,
462
468
.desc = "Run the behavior tests" ,
@@ -468,8 +474,10 @@ pub fn build(b: *std.Build) !void {
468
474
.max_rss = 1 * 1024 * 1024 * 1024 ,
469
475
}));
470
476
471
- test_step .dependOn (tests .addModuleTests (b , .{
477
+ test_modules_step .dependOn (tests .addModuleTests (b , .{
472
478
.test_filters = test_filters ,
479
+ .test_target_filters = test_target_filters ,
480
+ .test_slow_targets = test_slow_targets ,
473
481
.root_src = "test/c_import.zig" ,
474
482
.name = "c-import" ,
475
483
.desc = "Run the @cImport tests" ,
@@ -480,8 +488,10 @@ pub fn build(b: *std.Build) !void {
480
488
.skip_libc = skip_libc ,
481
489
}));
482
490
483
- test_step .dependOn (tests .addModuleTests (b , .{
491
+ test_modules_step .dependOn (tests .addModuleTests (b , .{
484
492
.test_filters = test_filters ,
493
+ .test_target_filters = test_target_filters ,
494
+ .test_slow_targets = test_slow_targets ,
485
495
.root_src = "lib/compiler_rt.zig" ,
486
496
.name = "compiler-rt" ,
487
497
.desc = "Run the compiler_rt tests" ,
@@ -493,8 +503,10 @@ pub fn build(b: *std.Build) !void {
493
503
.no_builtin = true ,
494
504
}));
495
505
496
- test_step .dependOn (tests .addModuleTests (b , .{
506
+ test_modules_step .dependOn (tests .addModuleTests (b , .{
497
507
.test_filters = test_filters ,
508
+ .test_target_filters = test_target_filters ,
509
+ .test_slow_targets = test_slow_targets ,
498
510
.root_src = "lib/c.zig" ,
499
511
.name = "universal-libc" ,
500
512
.desc = "Run the universal libc tests" ,
@@ -506,6 +518,24 @@ pub fn build(b: *std.Build) !void {
506
518
.no_builtin = true ,
507
519
}));
508
520
521
+ test_modules_step .dependOn (tests .addModuleTests (b , .{
522
+ .test_filters = test_filters ,
523
+ .test_target_filters = test_target_filters ,
524
+ .test_slow_targets = test_slow_targets ,
525
+ .root_src = "lib/std/std.zig" ,
526
+ .name = "std" ,
527
+ .desc = "Run the standard library tests" ,
528
+ .optimize_modes = optimization_modes ,
529
+ .include_paths = &.{},
530
+ .skip_single_threaded = skip_single_threaded ,
531
+ .skip_non_native = skip_non_native ,
532
+ .skip_libc = skip_libc ,
533
+ // I observed a value of 4572626944 on the M2 CI.
534
+ .max_rss = 5029889638 ,
535
+ }));
536
+
537
+ test_step .dependOn (test_modules_step );
538
+
509
539
test_step .dependOn (tests .addCompareOutputTests (b , test_filters , optimization_modes ));
510
540
test_step .dependOn (tests .addStandaloneTests (
511
541
b ,
@@ -519,39 +549,25 @@ pub fn build(b: *std.Build) !void {
519
549
test_step .dependOn (tests .addStackTraceTests (b , test_filters , optimization_modes ));
520
550
test_step .dependOn (tests .addCliTests (b ));
521
551
test_step .dependOn (tests .addAssembleAndLinkTests (b , test_filters , optimization_modes ));
522
- test_step .dependOn (tests .addModuleTests (b , .{
523
- .test_filters = test_filters ,
524
- .root_src = "lib/std/std.zig" ,
525
- .name = "std" ,
526
- .desc = "Run the standard library tests" ,
527
- .optimize_modes = optimization_modes ,
528
- .include_paths = &.{},
529
- .skip_single_threaded = skip_single_threaded ,
530
- .skip_non_native = skip_non_native ,
531
- .skip_libc = skip_libc ,
532
- // I observed a value of 4572626944 on the M2 CI.
533
- .max_rss = 5029889638 ,
534
- }));
535
552
536
553
try addWasiUpdateStep (b , version );
537
554
538
555
const update_mingw_step = b .step ("update-mingw" , "Update zig's bundled mingw" );
539
556
const opt_mingw_src_path = b .option ([]const u8 , "mingw-src" , "path to mingw-w64 source directory" );
540
- const update_mingw_exe = b .addExecutable (.{
541
- .name = "update_mingw" ,
542
- .target = b .graph .host ,
543
- .root_source_file = b .path ("tools/update_mingw.zig" ),
544
- });
545
- const update_mingw_run = b .addRunArtifact (update_mingw_exe );
546
- update_mingw_run .addDirectoryArg (b .path ("lib" ));
547
557
if (opt_mingw_src_path ) | mingw_src_path | {
558
+ const update_mingw_exe = b .addExecutable (.{
559
+ .name = "update_mingw" ,
560
+ .target = b .graph .host ,
561
+ .root_source_file = b .path ("tools/update_mingw.zig" ),
562
+ });
563
+ const update_mingw_run = b .addRunArtifact (update_mingw_exe );
564
+ update_mingw_run .addDirectoryArg (b .path ("lib" ));
548
565
update_mingw_run .addDirectoryArg (.{ .cwd_relative = mingw_src_path });
566
+
567
+ update_mingw_step .dependOn (& update_mingw_run .step );
549
568
} else {
550
- // Intentionally cause an error if this build step is requested.
551
- update_mingw_run .addArg ("--missing-mingw-source-directory" );
569
+ update_mingw_step .dependOn (& b .addFail ("The -Dmingw-src=... option is required for this step" ).step );
552
570
}
553
-
554
- update_mingw_step .dependOn (& update_mingw_run .step );
555
571
}
556
572
557
573
fn addWasiUpdateStep (b : * std.Build , version : [:0 ]const u8 ) ! void {
0 commit comments