authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-08-14 00:14:02+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-08-14 07:03:23+02:00
logb6009a7416c7661e09a23661887698ba520f0db6
treeba758271849a7fc38b5880f86b1ee76f36ea139d
parent3b51b43dc890dd8df17cb647ff7e1d3a53c438e7
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

build/test: Add -Dtest-slow-targets and move mips module tests behind it.

The idea is that these tests are just too slow to include by default on a contributor's local machine. If they want to run these, they need to opt in.

2 files changed, 25 insertions(+), 2 deletions(-)

build.zig+6
...@@ -380,6 +380,7 @@ pub fn build(b: *std.Build) !void {...@@ -380,6 +380,7 @@ pub fn build(b: *std.Build) !void {
380380
381 const test_filters = b.option([]const []const u8, "test-filter", "Skip tests that do not match any filter") orelse &[0][]const u8{};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{};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;
383384
384 const test_cases_options = b.addOptions();385 const test_cases_options = b.addOptions();
385386
...@@ -459,6 +460,7 @@ pub fn build(b: *std.Build) !void {...@@ -459,6 +460,7 @@ pub fn build(b: *std.Build) !void {
459 test_step.dependOn(tests.addModuleTests(b, .{460 test_step.dependOn(tests.addModuleTests(b, .{
460 .test_filters = test_filters,461 .test_filters = test_filters,
461 .test_target_filters = test_target_filters,462 .test_target_filters = test_target_filters,
463 .test_slow_targets = test_slow_targets,
462 .root_src = "test/behavior.zig",464 .root_src = "test/behavior.zig",
463 .name = "behavior",465 .name = "behavior",
464 .desc = "Run the behavior tests",466 .desc = "Run the behavior tests",
...@@ -473,6 +475,7 @@ pub fn build(b: *std.Build) !void {...@@ -473,6 +475,7 @@ pub fn build(b: *std.Build) !void {
473 test_step.dependOn(tests.addModuleTests(b, .{475 test_step.dependOn(tests.addModuleTests(b, .{
474 .test_filters = test_filters,476 .test_filters = test_filters,
475 .test_target_filters = test_target_filters,477 .test_target_filters = test_target_filters,
478 .test_slow_targets = test_slow_targets,
476 .root_src = "test/c_import.zig",479 .root_src = "test/c_import.zig",
477 .name = "c-import",480 .name = "c-import",
478 .desc = "Run the @cImport tests",481 .desc = "Run the @cImport tests",
...@@ -486,6 +489,7 @@ pub fn build(b: *std.Build) !void {...@@ -486,6 +489,7 @@ pub fn build(b: *std.Build) !void {
486 test_step.dependOn(tests.addModuleTests(b, .{489 test_step.dependOn(tests.addModuleTests(b, .{
487 .test_filters = test_filters,490 .test_filters = test_filters,
488 .test_target_filters = test_target_filters,491 .test_target_filters = test_target_filters,
492 .test_slow_targets = test_slow_targets,
489 .root_src = "lib/compiler_rt.zig",493 .root_src = "lib/compiler_rt.zig",
490 .name = "compiler-rt",494 .name = "compiler-rt",
491 .desc = "Run the compiler_rt tests",495 .desc = "Run the compiler_rt tests",
...@@ -500,6 +504,7 @@ pub fn build(b: *std.Build) !void {...@@ -500,6 +504,7 @@ pub fn build(b: *std.Build) !void {
500 test_step.dependOn(tests.addModuleTests(b, .{504 test_step.dependOn(tests.addModuleTests(b, .{
501 .test_filters = test_filters,505 .test_filters = test_filters,
502 .test_target_filters = test_target_filters,506 .test_target_filters = test_target_filters,
507 .test_slow_targets = test_slow_targets,
503 .root_src = "lib/c.zig",508 .root_src = "lib/c.zig",
504 .name = "universal-libc",509 .name = "universal-libc",
505 .desc = "Run the universal libc tests",510 .desc = "Run the universal libc tests",
...@@ -527,6 +532,7 @@ pub fn build(b: *std.Build) !void {...@@ -527,6 +532,7 @@ pub fn build(b: *std.Build) !void {
527 test_step.dependOn(tests.addModuleTests(b, .{532 test_step.dependOn(tests.addModuleTests(b, .{
528 .test_filters = test_filters,533 .test_filters = test_filters,
529 .test_target_filters = test_target_filters,534 .test_target_filters = test_target_filters,
535 .test_slow_targets = test_slow_targets,
530 .root_src = "lib/std/std.zig",536 .root_src = "lib/std/std.zig",
531 .name = "std",537 .name = "std",
532 .desc = "Run the standard library tests",538 .desc = "Run the standard library tests",
test/tests.zig+19-2
...@@ -27,6 +27,12 @@ const TestTarget = struct {...@@ -27,6 +27,12 @@ const TestTarget = struct {
27 use_lld: ?bool = null,27 use_lld: ?bool = null,
28 pic: ?bool = null,28 pic: ?bool = null,
29 strip: ?bool = null,29 strip: ?bool = null,
30
31 // This is intended for targets that are known to be slow to compile. These are acceptable to
32 // run in CI, but should not be run on developer machines by default. As an example, at the time
33 // of writing, this includes LLVM's MIPS backend which takes upwards of 20 minutes longer to
34 // compile tests than other backends.
35 slow_backend: bool = false,
30};36};
3137
32const test_targets = blk: {38const test_targets = blk: {
...@@ -310,6 +316,7 @@ const test_targets = blk: {...@@ -310,6 +316,7 @@ const test_targets = blk: {
310 .os_tag = .linux,316 .os_tag = .linux,
311 .abi = .none,317 .abi = .none,
312 },318 },
319 .slow_backend = true,
313 },320 },
314 .{321 .{
315 .target = .{322 .target = .{
...@@ -318,6 +325,7 @@ const test_targets = blk: {...@@ -318,6 +325,7 @@ const test_targets = blk: {
318 .abi = .musl,325 .abi = .musl,
319 },326 },
320 .link_libc = true,327 .link_libc = true,
328 .slow_backend = true,
321 },329 },
322 .{330 .{
323 .target = .{331 .target = .{
...@@ -326,6 +334,7 @@ const test_targets = blk: {...@@ -326,6 +334,7 @@ const test_targets = blk: {
326 .abi = .gnueabihf,334 .abi = .gnueabihf,
327 },335 },
328 .link_libc = true,336 .link_libc = true,
337 .slow_backend = true,
329 },338 },
330339
331 .{340 .{
...@@ -334,6 +343,7 @@ const test_targets = blk: {...@@ -334,6 +343,7 @@ const test_targets = blk: {
334 .os_tag = .linux,343 .os_tag = .linux,
335 .abi = .none,344 .abi = .none,
336 },345 },
346 .slow_backend = true,
337 },347 },
338 .{348 .{
339 .target = .{349 .target = .{
...@@ -342,6 +352,7 @@ const test_targets = blk: {...@@ -342,6 +352,7 @@ const test_targets = blk: {
342 .abi = .musl,352 .abi = .musl,
343 },353 },
344 .link_libc = true,354 .link_libc = true,
355 .slow_backend = true,
345 },356 },
346 .{357 .{
347 .target = .{358 .target = .{
...@@ -350,6 +361,7 @@ const test_targets = blk: {...@@ -350,6 +361,7 @@ const test_targets = blk: {
350 .abi = .gnueabihf,361 .abi = .gnueabihf,
351 },362 },
352 .link_libc = true,363 .link_libc = true,
364 .slow_backend = true,
353 },365 },
354366
355 .{367 .{
...@@ -401,7 +413,8 @@ const test_targets = blk: {...@@ -401,7 +413,8 @@ const test_targets = blk: {
401 .link_libc = true,413 .link_libc = true,
402 },414 },
403415
404 // Disabled until LLVM fixes their O(N^2) codegen.416 // Disabled until LLVM fixes their O(N^2) codegen. Note that this is so bad that we don't
417 // even want to include this in CI with `slow_backend`.
405 // https://github.com/ziglang/zig/issues/18872418 // https://github.com/ziglang/zig/issues/18872
406 //.{419 //.{
407 // .target = .{420 // .target = .{
...@@ -412,7 +425,8 @@ const test_targets = blk: {...@@ -412,7 +425,8 @@ const test_targets = blk: {
412 // .use_llvm = true,425 // .use_llvm = true,
413 //},426 //},
414427
415 // Disabled until LLVM fixes their O(N^2) codegen.428 // Disabled until LLVM fixes their O(N^2) codegen. Note that this is so bad that we don't
429 // even want to include this in CI with `slow_backend`.
416 // https://github.com/ziglang/zig/issues/18872430 // https://github.com/ziglang/zig/issues/18872
417 //.{431 //.{
418 // .target = .{432 // .target = .{
...@@ -966,6 +980,7 @@ pub fn addRunTranslatedCTests(...@@ -966,6 +980,7 @@ pub fn addRunTranslatedCTests(
966const ModuleTestOptions = struct {980const ModuleTestOptions = struct {
967 test_filters: []const []const u8,981 test_filters: []const []const u8,
968 test_target_filters: []const []const u8,982 test_target_filters: []const []const u8,
983 test_slow_targets: bool,
969 root_src: []const u8,984 root_src: []const u8,
970 name: []const u8,985 name: []const u8,
971 desc: []const u8,986 desc: []const u8,
...@@ -982,6 +997,8 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {...@@ -982,6 +997,8 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
982 const step = b.step(b.fmt("test-{s}", .{options.name}), options.desc);997 const step = b.step(b.fmt("test-{s}", .{options.name}), options.desc);
983998
984 for (test_targets) |test_target| {999 for (test_targets) |test_target| {
1000 if (!options.test_slow_targets and test_target.slow_backend) continue;
1001
985 if (options.skip_non_native and !test_target.target.isNative())1002 if (options.skip_non_native and !test_target.target.isNative())
986 continue;1003 continue;
9871004