mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
test: Respect various test skip options in test-cases
This commit is contained in:
parent
aa1556156e
commit
9ef4bdf234
3 changed files with 56 additions and 13 deletions
13
build.zig
13
build.zig
|
|
@ -415,7 +415,18 @@ pub fn build(b: *std.Build) !void {
|
|||
test_step.dependOn(check_fmt);
|
||||
|
||||
const test_cases_step = b.step("test-cases", "Run the main compiler test cases");
|
||||
try tests.addCases(b, test_cases_step, test_filters, test_target_filters, target, .{
|
||||
try tests.addCases(b, test_cases_step, target, .{
|
||||
.test_filters = test_filters,
|
||||
.test_target_filters = test_target_filters,
|
||||
.skip_non_native = skip_non_native,
|
||||
.skip_freebsd = skip_freebsd,
|
||||
.skip_netbsd = skip_netbsd,
|
||||
.skip_windows = skip_windows,
|
||||
.skip_macos = skip_macos,
|
||||
.skip_linux = skip_linux,
|
||||
.skip_llvm = skip_llvm,
|
||||
.skip_libc = skip_libc,
|
||||
}, .{
|
||||
.skip_translate_c = skip_translate_c,
|
||||
.skip_run_translated_c = skip_run_translated_c,
|
||||
}, .{
|
||||
|
|
|
|||
|
|
@ -594,30 +594,57 @@ pub fn lowerToTranslateCSteps(
|
|||
};
|
||||
}
|
||||
|
||||
pub const CaseTestOptions = struct {
|
||||
test_filters: []const []const u8,
|
||||
test_target_filters: []const []const u8,
|
||||
skip_non_native: bool,
|
||||
skip_freebsd: bool,
|
||||
skip_netbsd: bool,
|
||||
skip_windows: bool,
|
||||
skip_macos: bool,
|
||||
skip_linux: bool,
|
||||
skip_llvm: bool,
|
||||
skip_libc: bool,
|
||||
};
|
||||
|
||||
pub fn lowerToBuildSteps(
|
||||
self: *Cases,
|
||||
b: *std.Build,
|
||||
parent_step: *std.Build.Step,
|
||||
test_filters: []const []const u8,
|
||||
test_target_filters: []const []const u8,
|
||||
options: CaseTestOptions,
|
||||
) void {
|
||||
const host = std.zig.system.resolveTargetQuery(.{}) catch |err|
|
||||
std.debug.panic("unable to detect native host: {s}\n", .{@errorName(err)});
|
||||
const cases_dir_path = b.build_root.join(b.allocator, &.{ "test", "cases" }) catch @panic("OOM");
|
||||
|
||||
for (self.cases.items) |case| {
|
||||
for (test_filters) |test_filter| {
|
||||
for (options.test_filters) |test_filter| {
|
||||
if (std.mem.indexOf(u8, case.name, test_filter)) |_| break;
|
||||
} else if (test_filters.len > 0) continue;
|
||||
} else if (options.test_filters.len > 0) continue;
|
||||
|
||||
if (options.skip_non_native and !case.target.query.isNative())
|
||||
continue;
|
||||
|
||||
if (options.skip_freebsd and case.target.query.os_tag == .freebsd) continue;
|
||||
if (options.skip_netbsd and case.target.query.os_tag == .netbsd) continue;
|
||||
if (options.skip_windows and case.target.query.os_tag == .windows) continue;
|
||||
if (options.skip_macos and case.target.query.os_tag == .macos) continue;
|
||||
if (options.skip_linux and case.target.query.os_tag == .linux) continue;
|
||||
|
||||
const would_use_llvm = @import("../tests.zig").wouldUseLlvm(case.backend == .llvm, case.target.query, case.optimize_mode);
|
||||
if (options.skip_llvm and would_use_llvm) continue;
|
||||
|
||||
const triple_txt = case.target.query.zigTriple(b.allocator) catch @panic("OOM");
|
||||
|
||||
if (test_target_filters.len > 0) {
|
||||
for (test_target_filters) |filter| {
|
||||
if (options.test_target_filters.len > 0) {
|
||||
for (options.test_target_filters) |filter| {
|
||||
if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
|
||||
} else continue;
|
||||
}
|
||||
|
||||
if (options.skip_libc and case.link_libc)
|
||||
continue;
|
||||
|
||||
const writefiles = b.addWriteFiles();
|
||||
var file_sources = std.StringHashMap(std.Build.LazyPath).init(b.allocator);
|
||||
defer file_sources.deinit();
|
||||
|
|
|
|||
|
|
@ -2517,7 +2517,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
|
|||
return step;
|
||||
}
|
||||
|
||||
fn wouldUseLlvm(use_llvm: ?bool, query: std.Target.Query, optimize_mode: OptimizeMode) bool {
|
||||
pub fn wouldUseLlvm(use_llvm: ?bool, query: std.Target.Query, optimize_mode: OptimizeMode) bool {
|
||||
if (use_llvm) |x| return x;
|
||||
if (query.ofmt == .c) return false;
|
||||
switch (optimize_mode) {
|
||||
|
|
@ -2629,9 +2629,8 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
|
|||
pub fn addCases(
|
||||
b: *std.Build,
|
||||
parent_step: *Step,
|
||||
test_filters: []const []const u8,
|
||||
test_target_filters: []const []const u8,
|
||||
target: std.Build.ResolvedTarget,
|
||||
case_test_options: @import("src/Cases.zig").CaseTestOptions,
|
||||
translate_c_options: @import("src/Cases.zig").TranslateCOptions,
|
||||
build_options: @import("cases.zig").BuildOptions,
|
||||
) !void {
|
||||
|
|
@ -2646,13 +2645,19 @@ pub fn addCases(
|
|||
cases.addFromDir(dir, b);
|
||||
try @import("cases.zig").addCases(&cases, build_options, b);
|
||||
|
||||
cases.lowerToTranslateCSteps(b, parent_step, test_filters, test_target_filters, target, translate_c_options);
|
||||
cases.lowerToTranslateCSteps(
|
||||
b,
|
||||
parent_step,
|
||||
case_test_options.test_filters,
|
||||
case_test_options.test_target_filters,
|
||||
target,
|
||||
translate_c_options,
|
||||
);
|
||||
|
||||
cases.lowerToBuildSteps(
|
||||
b,
|
||||
parent_step,
|
||||
test_filters,
|
||||
test_target_filters,
|
||||
case_test_options,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue