test: respect -Dskip-translate-c in test-standalone

This commit is contained in:
Alex Rønne Petersen 2025-09-17 11:15:24 +02:00
parent 4e9b8aec2c
commit 9095a7fefd
No known key found for this signature in database
7 changed files with 23 additions and 2 deletions

View file

@ -576,6 +576,7 @@ pub fn build(b: *std.Build) !void {
enable_macos_sdk,
enable_ios_sdk,
enable_symlinks_windows,
skip_translate_c,
));
test_step.dependOn(tests.addCAbiTests(b, .{
.test_target_filters = test_target_filters,

View file

@ -9,6 +9,7 @@ pub fn build(b: *std.Build) void {
const enable_macos_sdk = b.option(bool, "enable_macos_sdk", "Run tests requiring presence of macOS SDK and frameworks") orelse enable_ios_sdk;
const enable_symlinks_windows = b.option(bool, "enable_symlinks_windows", "Run tests requiring presence of symlinks on Windows") orelse false;
const omit_symlinks = builtin.os.tag == .windows and !enable_symlinks_windows;
const skip_translate_c = b.option(bool, "skip_translate_c", "Test suite skips translate-c tests") orelse false;
const simple_skip_debug = b.option(bool, "simple_skip_debug", "Simple tests skip debug builds") orelse false;
const simple_skip_release_safe = b.option(bool, "simple_skip_release_safe", "Simple tests skip release-safe builds") orelse false;
@ -20,6 +21,7 @@ pub fn build(b: *std.Build) void {
.skip_release_safe = simple_skip_release_safe,
.skip_release_fast = simple_skip_release_fast,
.skip_release_small = simple_skip_release_small,
.skip_translate_c = skip_translate_c,
});
const simple_dep_step = simple_dep.builder.default_step;
simple_dep_step.name = "standalone_test_cases.simple";
@ -97,9 +99,12 @@ pub fn build(b: *std.Build) void {
pkg.build_zig.requires_macos_sdk;
const requires_symlinks = @hasDecl(pkg.build_zig, "requires_symlinks") and
pkg.build_zig.requires_symlinks;
const requires_translate_c = @hasDecl(pkg.build_zig, "requires_translate_c") and
pkg.build_zig.requires_translate_c;
if ((requires_symlinks and omit_symlinks) or
(requires_macos_sdk and !enable_macos_sdk) or
(requires_ios_sdk and !enable_ios_sdk))
(requires_ios_sdk and !enable_ios_sdk) or
(requires_translate_c and skip_translate_c))
{
continue :add_dep_steps;
}

View file

@ -1,5 +1,7 @@
const std = @import("std");
pub const requires_translate_c = true;
pub fn build(b: *std.Build) void {
const test_step = b.step("test", "Test it");
b.default_step = test_step;

View file

@ -1,6 +1,8 @@
const std = @import("std");
const builtin = @import("builtin");
pub const requires_translate_c = true;
// To run executables linked against a specific glibc version, the
// run-time glibc version needs to be new enough. Check the host's glibc
// version. Note that this does not allow for translation/vm/emulation

View file

@ -1,5 +1,7 @@
const std = @import("std");
pub const requires_translate_c = true;
pub fn build(b: *std.Build) void {
const test_step = b.step("test", "Test it");
b.default_step = test_step;

View file

@ -9,6 +9,7 @@ pub fn build(b: *std.Build) void {
const skip_release_safe = b.option(bool, "skip_release_safe", "Skip release-safe builds") orelse false;
const skip_release_fast = b.option(bool, "skip_release_fast", "Skip release-fast builds") orelse false;
const skip_release_small = b.option(bool, "skip_release_small", "Skip release-small builds") orelse false;
const skip_translate_c = b.option(bool, "skip_translate_c", "Test suite skips translate-c tests") orelse false;
var optimize_modes_buf: [4]std.builtin.OptimizeMode = undefined;
var optimize_modes_len: usize = 0;
@ -36,6 +37,7 @@ pub fn build(b: *std.Build) void {
if (case.os_filter) |os_tag| {
if (os_tag != builtin.os.tag) continue;
}
if (case.uses_translate_c and skip_translate_c) continue;
const resolved_target = b.resolveTargetQuery(case.target);
@ -82,6 +84,7 @@ const Case = struct {
is_exe: bool = true,
/// Run only on this OS.
os_filter: ?std.Target.Os.Tag = null,
uses_translate_c: bool = false,
};
const cases = [_]Case{
@ -93,6 +96,7 @@ const cases = [_]Case{
.src_path = "hello_world/hello_libc.zig",
.link_libc = true,
.all_modes = true,
.uses_translate_c = true,
},
.{
.src_path = "cat/main.zig",
@ -108,7 +112,10 @@ const cases = [_]Case{
.os_tag = .freestanding,
},
},
.{ .src_path = "issue_12471/main.zig" },
.{
.src_path = "issue_12471/main.zig",
.uses_translate_c = true,
},
.{ .src_path = "guess_number/main.zig" },
.{ .src_path = "main_return_error/error_u8.zig" },
.{ .src_path = "main_return_error/error_u8_non_zero.zig" },

View file

@ -1893,6 +1893,7 @@ pub fn addStandaloneTests(
enable_macos_sdk: bool,
enable_ios_sdk: bool,
enable_symlinks_windows: bool,
skip_translate_c: bool,
) *Step {
const step = b.step("test-standalone", "Run the standalone tests");
if (compilerHasPackageManager(b)) {
@ -1905,6 +1906,7 @@ pub fn addStandaloneTests(
.simple_skip_release_safe = mem.indexOfScalar(OptimizeMode, optimize_modes, .ReleaseSafe) == null,
.simple_skip_release_fast = mem.indexOfScalar(OptimizeMode, optimize_modes, .ReleaseFast) == null,
.simple_skip_release_small = mem.indexOfScalar(OptimizeMode, optimize_modes, .ReleaseSmall) == null,
.skip_translate_c = skip_translate_c,
});
const test_cases_dep_step = test_cases_dep.builder.default_step;
test_cases_dep_step.name = b.dupe(test_cases_dep_name);