mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
build.zig: add -Dtest-default-only option
handy during development when it is already known that not all tests will pass.
This commit is contained in:
parent
328ae41468
commit
8964737ffc
2 changed files with 191 additions and 164 deletions
|
|
@ -81,12 +81,13 @@ pub fn build(b: *std.Build) !void {
|
|||
docs_step.dependOn(langref_step);
|
||||
docs_step.dependOn(std_docs_step);
|
||||
|
||||
const test_default_only = b.option(bool, "test-default-only", "Limit test matrix to exactly one target configuration") orelse false;
|
||||
const skip_debug = b.option(bool, "skip-debug", "Main test suite skips debug builds") orelse false;
|
||||
const skip_release = b.option(bool, "skip-release", "Main test suite skips release builds") orelse false;
|
||||
const skip_release = b.option(bool, "skip-release", "Main test suite skips release builds") orelse test_default_only;
|
||||
const skip_release_small = b.option(bool, "skip-release-small", "Main test suite skips release-small builds") orelse skip_release;
|
||||
const skip_release_fast = b.option(bool, "skip-release-fast", "Main test suite skips release-fast builds") orelse skip_release;
|
||||
const skip_release_safe = b.option(bool, "skip-release-safe", "Main test suite skips release-safe builds") orelse skip_release;
|
||||
const skip_non_native = b.option(bool, "skip-non-native", "Main test suite skips non-native builds") orelse false;
|
||||
const skip_non_native = b.option(bool, "skip-non-native", "Main test suite skips non-native builds") orelse test_default_only;
|
||||
const skip_libc = b.option(bool, "skip-libc", "Main test suite skips tests that link libc") orelse false;
|
||||
const skip_single_threaded = b.option(bool, "skip-single-threaded", "Main test suite skips tests that are single-threaded") orelse false;
|
||||
const skip_compile_errors = b.option(bool, "skip-compile-errors", "Main test suite skips compile error tests") orelse false;
|
||||
|
|
@ -449,6 +450,7 @@ pub fn build(b: *std.Build) !void {
|
|||
.include_paths = &.{},
|
||||
.skip_single_threaded = skip_single_threaded,
|
||||
.skip_non_native = skip_non_native,
|
||||
.test_default_only = test_default_only,
|
||||
.skip_freebsd = skip_freebsd,
|
||||
.skip_netbsd = skip_netbsd,
|
||||
.skip_windows = skip_windows,
|
||||
|
|
@ -471,6 +473,7 @@ pub fn build(b: *std.Build) !void {
|
|||
.include_paths = &.{},
|
||||
.skip_single_threaded = true,
|
||||
.skip_non_native = skip_non_native,
|
||||
.test_default_only = test_default_only,
|
||||
.skip_freebsd = skip_freebsd,
|
||||
.skip_netbsd = skip_netbsd,
|
||||
.skip_windows = skip_windows,
|
||||
|
|
@ -492,6 +495,7 @@ pub fn build(b: *std.Build) !void {
|
|||
.include_paths = &.{},
|
||||
.skip_single_threaded = true,
|
||||
.skip_non_native = skip_non_native,
|
||||
.test_default_only = test_default_only,
|
||||
.skip_freebsd = skip_freebsd,
|
||||
.skip_netbsd = skip_netbsd,
|
||||
.skip_windows = skip_windows,
|
||||
|
|
@ -513,6 +517,7 @@ pub fn build(b: *std.Build) !void {
|
|||
.include_paths = &.{},
|
||||
.skip_single_threaded = skip_single_threaded,
|
||||
.skip_non_native = skip_non_native,
|
||||
.test_default_only = test_default_only,
|
||||
.skip_freebsd = skip_freebsd,
|
||||
.skip_netbsd = skip_netbsd,
|
||||
.skip_windows = skip_windows,
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ const test_targets = blk: {
|
|||
break :blk [_]TestTarget{
|
||||
// Native Targets
|
||||
|
||||
.{},
|
||||
.{}, // 0 index must be all defaults
|
||||
.{
|
||||
.link_libc = true,
|
||||
},
|
||||
|
|
@ -2224,6 +2224,7 @@ const ModuleTestOptions = struct {
|
|||
desc: []const u8,
|
||||
optimize_modes: []const OptimizeMode,
|
||||
include_paths: []const []const u8,
|
||||
test_default_only: bool,
|
||||
skip_single_threaded: bool,
|
||||
skip_non_native: bool,
|
||||
skip_freebsd: bool,
|
||||
|
|
@ -2235,13 +2236,21 @@ const ModuleTestOptions = struct {
|
|||
skip_libc: bool,
|
||||
max_rss: usize = 0,
|
||||
no_builtin: bool = false,
|
||||
build_options: ?*std.Build.Step.Options = null,
|
||||
build_options: ?*Step.Options = null,
|
||||
};
|
||||
|
||||
pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
|
||||
const step = b.step(b.fmt("test-{s}", .{options.name}), options.desc);
|
||||
|
||||
for_targets: for (test_targets) |test_target| {
|
||||
if (options.test_default_only) {
|
||||
const test_target = &test_targets[0];
|
||||
const resolved_target = b.resolveTargetQuery(test_target.target);
|
||||
const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM");
|
||||
addOneModuleTest(b, step, test_target, &resolved_target, triple_txt, options);
|
||||
return step;
|
||||
}
|
||||
|
||||
for_targets: for (&test_targets) |*test_target| {
|
||||
if (test_target.skip_modules.len > 0) {
|
||||
for (test_target.skip_modules) |skip_mod| {
|
||||
if (std.mem.eql(u8, options.name, skip_mod)) continue :for_targets;
|
||||
|
|
@ -2306,6 +2315,20 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
|
|||
} else false;
|
||||
if (!want_this_mode) continue;
|
||||
|
||||
addOneModuleTest(b, step, test_target, &resolved_target, triple_txt, options);
|
||||
}
|
||||
return step;
|
||||
}
|
||||
|
||||
fn addOneModuleTest(
|
||||
b: *std.Build,
|
||||
step: *Step,
|
||||
test_target: *const TestTarget,
|
||||
resolved_target: *const std.Build.ResolvedTarget,
|
||||
triple_txt: []const u8,
|
||||
options: ModuleTestOptions,
|
||||
) void {
|
||||
const target = &resolved_target.result;
|
||||
const libc_suffix = if (test_target.link_libc == true) "-libc" else "";
|
||||
const model_txt = target.cpu.model.name;
|
||||
|
||||
|
|
@ -2319,7 +2342,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
|
|||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path(options.root_src),
|
||||
.optimize = test_target.optimize_mode,
|
||||
.target = resolved_target,
|
||||
.target = resolved_target.*,
|
||||
.link_libc = test_target.link_libc,
|
||||
.pic = test_target.pic,
|
||||
.strip = test_target.strip,
|
||||
|
|
@ -2353,11 +2376,11 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
|
|||
|
||||
for (options.include_paths) |include_path| these_tests.root_module.addIncludePath(b.path(include_path));
|
||||
|
||||
const qualified_name = b.fmt("{s}-{s}-{s}-{s}{s}{s}{s}{s}{s}{s}", .{
|
||||
const qualified_name = b.fmt("{s}-{s}-{s}-{t}{s}{s}{s}{s}{s}{s}", .{
|
||||
options.name,
|
||||
triple_txt,
|
||||
model_txt,
|
||||
@tagName(test_target.optimize_mode),
|
||||
test_target.optimize_mode,
|
||||
libc_suffix,
|
||||
single_threaded_suffix,
|
||||
backend_suffix,
|
||||
|
|
@ -2429,8 +2452,9 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
|
|||
if (true) {
|
||||
// Unfortunately this requires about 8G of RAM for clang to compile
|
||||
// and our Windows CI runners do not have this much.
|
||||
// TODO This is not an appropriate way to work around this problem.
|
||||
step.dependOn(&these_tests.step);
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
if (test_target.link_libc == false) {
|
||||
compile_c_exe.subsystem = .Console;
|
||||
|
|
@ -2465,8 +2489,6 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
|
|||
|
||||
step.dependOn(&run.step);
|
||||
}
|
||||
}
|
||||
return step;
|
||||
}
|
||||
|
||||
pub fn wouldUseLlvm(use_llvm: ?bool, query: std.Target.Query, optimize_mode: OptimizeMode) bool {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue