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.
This commit is contained in:
Alex Rønne Petersen 2024-08-14 00:14:02 +02:00
parent 3b51b43dc8
commit b6009a7416
No known key found for this signature in database
2 changed files with 25 additions and 2 deletions

View file

@ -380,6 +380,7 @@ pub fn build(b: *std.Build) !void {
const test_filters = b.option([]const []const u8, "test-filter", "Skip tests that do not match any filter") orelse &[0][]const u8{};
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{};
const test_slow_targets = b.option(bool, "test-slow-targets", "Enable running module tests for targets that have a slow compiler backend") orelse false;
const test_cases_options = b.addOptions();
@ -459,6 +460,7 @@ pub fn build(b: *std.Build) !void {
test_step.dependOn(tests.addModuleTests(b, .{
.test_filters = test_filters,
.test_target_filters = test_target_filters,
.test_slow_targets = test_slow_targets,
.root_src = "test/behavior.zig",
.name = "behavior",
.desc = "Run the behavior tests",
@ -473,6 +475,7 @@ pub fn build(b: *std.Build) !void {
test_step.dependOn(tests.addModuleTests(b, .{
.test_filters = test_filters,
.test_target_filters = test_target_filters,
.test_slow_targets = test_slow_targets,
.root_src = "test/c_import.zig",
.name = "c-import",
.desc = "Run the @cImport tests",
@ -486,6 +489,7 @@ pub fn build(b: *std.Build) !void {
test_step.dependOn(tests.addModuleTests(b, .{
.test_filters = test_filters,
.test_target_filters = test_target_filters,
.test_slow_targets = test_slow_targets,
.root_src = "lib/compiler_rt.zig",
.name = "compiler-rt",
.desc = "Run the compiler_rt tests",
@ -500,6 +504,7 @@ pub fn build(b: *std.Build) !void {
test_step.dependOn(tests.addModuleTests(b, .{
.test_filters = test_filters,
.test_target_filters = test_target_filters,
.test_slow_targets = test_slow_targets,
.root_src = "lib/c.zig",
.name = "universal-libc",
.desc = "Run the universal libc tests",
@ -527,6 +532,7 @@ pub fn build(b: *std.Build) !void {
test_step.dependOn(tests.addModuleTests(b, .{
.test_filters = test_filters,
.test_target_filters = test_target_filters,
.test_slow_targets = test_slow_targets,
.root_src = "lib/std/std.zig",
.name = "std",
.desc = "Run the standard library tests",

View file

@ -27,6 +27,12 @@ const TestTarget = struct {
use_lld: ?bool = null,
pic: ?bool = null,
strip: ?bool = null,
// This is intended for targets that are known to be slow to compile. These are acceptable to
// run in CI, but should not be run on developer machines by default. As an example, at the time
// of writing, this includes LLVM's MIPS backend which takes upwards of 20 minutes longer to
// compile tests than other backends.
slow_backend: bool = false,
};
const test_targets = blk: {
@ -310,6 +316,7 @@ const test_targets = blk: {
.os_tag = .linux,
.abi = .none,
},
.slow_backend = true,
},
.{
.target = .{
@ -318,6 +325,7 @@ const test_targets = blk: {
.abi = .musl,
},
.link_libc = true,
.slow_backend = true,
},
.{
.target = .{
@ -326,6 +334,7 @@ const test_targets = blk: {
.abi = .gnueabihf,
},
.link_libc = true,
.slow_backend = true,
},
.{
@ -334,6 +343,7 @@ const test_targets = blk: {
.os_tag = .linux,
.abi = .none,
},
.slow_backend = true,
},
.{
.target = .{
@ -342,6 +352,7 @@ const test_targets = blk: {
.abi = .musl,
},
.link_libc = true,
.slow_backend = true,
},
.{
.target = .{
@ -350,6 +361,7 @@ const test_targets = blk: {
.abi = .gnueabihf,
},
.link_libc = true,
.slow_backend = true,
},
.{
@ -401,7 +413,8 @@ const test_targets = blk: {
.link_libc = true,
},
// Disabled until LLVM fixes their O(N^2) codegen.
// Disabled until LLVM fixes their O(N^2) codegen. Note that this is so bad that we don't
// even want to include this in CI with `slow_backend`.
// https://github.com/ziglang/zig/issues/18872
//.{
// .target = .{
@ -412,7 +425,8 @@ const test_targets = blk: {
// .use_llvm = true,
//},
// Disabled until LLVM fixes their O(N^2) codegen.
// Disabled until LLVM fixes their O(N^2) codegen. Note that this is so bad that we don't
// even want to include this in CI with `slow_backend`.
// https://github.com/ziglang/zig/issues/18872
//.{
// .target = .{
@ -966,6 +980,7 @@ pub fn addRunTranslatedCTests(
const ModuleTestOptions = struct {
test_filters: []const []const u8,
test_target_filters: []const []const u8,
test_slow_targets: bool,
root_src: []const u8,
name: []const u8,
desc: []const u8,
@ -982,6 +997,8 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
const step = b.step(b.fmt("test-{s}", .{options.name}), options.desc);
for (test_targets) |test_target| {
if (!options.test_slow_targets and test_target.slow_backend) continue;
if (options.skip_non_native and !test_target.target.isNative())
continue;