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 {
380380
381381 const test_filters = b.option([]const []const u8, "test-filter", "Skip tests that do not match any filter") orelse &[0][]const u8{};
382382 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
384385 const test_cases_options = b.addOptions();
385386
......@@ -459,6 +460,7 @@ pub fn build(b: *std.Build) !void {
459460 test_step.dependOn(tests.addModuleTests(b, .{
460461 .test_filters = test_filters,
461462 .test_target_filters = test_target_filters,
463 .test_slow_targets = test_slow_targets,
462464 .root_src = "test/behavior.zig",
463465 .name = "behavior",
464466 .desc = "Run the behavior tests",
......@@ -473,6 +475,7 @@ pub fn build(b: *std.Build) !void {
473475 test_step.dependOn(tests.addModuleTests(b, .{
474476 .test_filters = test_filters,
475477 .test_target_filters = test_target_filters,
478 .test_slow_targets = test_slow_targets,
476479 .root_src = "test/c_import.zig",
477480 .name = "c-import",
478481 .desc = "Run the @cImport tests",
......@@ -486,6 +489,7 @@ pub fn build(b: *std.Build) !void {
486489 test_step.dependOn(tests.addModuleTests(b, .{
487490 .test_filters = test_filters,
488491 .test_target_filters = test_target_filters,
492 .test_slow_targets = test_slow_targets,
489493 .root_src = "lib/compiler_rt.zig",
490494 .name = "compiler-rt",
491495 .desc = "Run the compiler_rt tests",
......@@ -500,6 +504,7 @@ pub fn build(b: *std.Build) !void {
500504 test_step.dependOn(tests.addModuleTests(b, .{
501505 .test_filters = test_filters,
502506 .test_target_filters = test_target_filters,
507 .test_slow_targets = test_slow_targets,
503508 .root_src = "lib/c.zig",
504509 .name = "universal-libc",
505510 .desc = "Run the universal libc tests",
......@@ -527,6 +532,7 @@ pub fn build(b: *std.Build) !void {
527532 test_step.dependOn(tests.addModuleTests(b, .{
528533 .test_filters = test_filters,
529534 .test_target_filters = test_target_filters,
535 .test_slow_targets = test_slow_targets,
530536 .root_src = "lib/std/std.zig",
531537 .name = "std",
532538 .desc = "Run the standard library tests",
test/tests.zig+19-2
......@@ -27,6 +27,12 @@ const TestTarget = struct {
2727 use_lld: ?bool = null,
2828 pic: ?bool = null,
2929 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,
3036};
3137
3238const test_targets = blk: {
......@@ -310,6 +316,7 @@ const test_targets = blk: {
310316 .os_tag = .linux,
311317 .abi = .none,
312318 },
319 .slow_backend = true,
313320 },
314321 .{
315322 .target = .{
......@@ -318,6 +325,7 @@ const test_targets = blk: {
318325 .abi = .musl,
319326 },
320327 .link_libc = true,
328 .slow_backend = true,
321329 },
322330 .{
323331 .target = .{
......@@ -326,6 +334,7 @@ const test_targets = blk: {
326334 .abi = .gnueabihf,
327335 },
328336 .link_libc = true,
337 .slow_backend = true,
329338 },
330339
331340 .{
......@@ -334,6 +343,7 @@ const test_targets = blk: {
334343 .os_tag = .linux,
335344 .abi = .none,
336345 },
346 .slow_backend = true,
337347 },
338348 .{
339349 .target = .{
......@@ -342,6 +352,7 @@ const test_targets = blk: {
342352 .abi = .musl,
343353 },
344354 .link_libc = true,
355 .slow_backend = true,
345356 },
346357 .{
347358 .target = .{
......@@ -350,6 +361,7 @@ const test_targets = blk: {
350361 .abi = .gnueabihf,
351362 },
352363 .link_libc = true,
364 .slow_backend = true,
353365 },
354366
355367 .{
......@@ -401,7 +413,8 @@ const test_targets = blk: {
401413 .link_libc = true,
402414 },
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`.
405418 // https://github.com/ziglang/zig/issues/18872
406419 //.{
407420 // .target = .{
......@@ -412,7 +425,8 @@ const test_targets = blk: {
412425 // .use_llvm = true,
413426 //},
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`.
416430 // https://github.com/ziglang/zig/issues/18872
417431 //.{
418432 // .target = .{
......@@ -966,6 +980,7 @@ pub fn addRunTranslatedCTests(
966980const ModuleTestOptions = struct {
967981 test_filters: []const []const u8,
968982 test_target_filters: []const []const u8,
983 test_slow_targets: bool,
969984 root_src: []const u8,
970985 name: []const u8,
971986 desc: []const u8,
......@@ -982,6 +997,8 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
982997 const step = b.step(b.fmt("test-{s}", .{options.name}), options.desc);
983998
984999 for (test_targets) |test_target| {
1000 if (!options.test_slow_targets and test_target.slow_backend) continue;
1001
9851002 if (options.skip_non_native and !test_target.target.isNative())
9861003 continue;
9871004