authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-08-05 16:31:10-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-08-07 11:19:55-07:00
log5228c8902fe178834f678cb5bec12a5a32d5df2f
tree641ffa086b8d519d4c585a572919db1d1e150710
parent3a8984f254addc3de4423bab367192c77ebba4fc

tests: use skip_foreign_checks rather than dead branch

Configuration logic, in general, should not try to guess whether an executable will be able to be run on the host. This can only be determined by trying to, and encountering failure, for example because binfmt_misc might be installed. OS might handle illegal instruction traps and emulate CPU features not available, etc. skip_foreign_checks is the mechanism intended to handle this use case.

3 files changed, 42 insertions(+), 46 deletions(-)

test/src/ErrorTrace.zig+2
......@@ -105,6 +105,7 @@ fn addCaseConfig(
105105 exe.bundle_ubsan_rt = false;
106106
107107 const run = b.addRunArtifact(exe);
108 run.skip_foreign_checks = true;
108109 run.removeEnvironmentVariable("CLICOLOR_FORCE");
109110 run.setEnvironmentVariable("NO_COLOR", "1");
110111 run.expectExitCode(1);
......@@ -116,6 +117,7 @@ fn addCaseConfig(
116117 };
117118
118119 const check_run = b.addRunArtifact(self.convert_exe);
120 check_run.skip_foreign_checks = true;
119121 check_run.setName(annotated_case_name);
120122 check_run.addFileArg(run.captureStdErr(.{}));
121123 check_run.expectStdOutEqual(expected_stderr);
test/src/StackTrace.zig+2
......@@ -224,6 +224,7 @@ fn addCaseInstance(
224224 exe.bundle_ubsan_rt = false;
225225
226226 const run = b.addRunArtifact(exe);
227 run.skip_foreign_checks = true;
227228 run.removeEnvironmentVariable("CLICOLOR_FORCE");
228229 run.setEnvironmentVariable("NO_COLOR", "1");
229230 run.addCheck(.{ .expect_term = term: {
......@@ -234,6 +235,7 @@ fn addCaseInstance(
234235 run.expectStdOutEqual("");
235236
236237 const check_run = b.addRunArtifact(self.convert_exe);
238 check_run.skip_foreign_checks = true;
237239 check_run.setName(annotated_case_name);
238240 check_run.addFileArg(run.captureStdErr(.{}));
239241 check_run.expectExitCode(0);
test/tests.zig+38-46
......@@ -2455,29 +2455,25 @@ pub fn addStackTraceTests(
24552455 };
24562456 stack_traces.addCases(host_cases, b.graph.host.result.os.tag);
24572457
2458 if (b.enable_wine) {
2459 const wine_cases = b.allocator.create(StackTracesContext) catch @panic("OOM");
2460 wine_cases.* = .{
2461 .b = b,
2462 .step = step,
2463 .test_filters = test_filters,
2464 .targets = wineAndCompatible32bit(b, skip_non_native),
2465 .convert_exe = convert_exe,
2466 };
2467 stack_traces.addCases(wine_cases, .windows);
2468 }
2458 const wine_cases = b.allocator.create(StackTracesContext) catch @panic("OOM");
2459 wine_cases.* = .{
2460 .b = b,
2461 .step = step,
2462 .test_filters = test_filters,
2463 .targets = wineAndCompatible32bit(b, skip_non_native),
2464 .convert_exe = convert_exe,
2465 };
2466 stack_traces.addCases(wine_cases, .windows);
24692467
2470 if (b.enable_darling) {
2471 const darling_cases = b.allocator.create(StackTracesContext) catch @panic("OOM");
2472 darling_cases.* = .{
2473 .b = b,
2474 .step = step,
2475 .test_filters = test_filters,
2476 .targets = darlingTargets(b),
2477 .convert_exe = convert_exe,
2478 };
2479 stack_traces.addCases(darling_cases, .macos);
2480 }
2468 const darling_cases = b.allocator.create(StackTracesContext) catch @panic("OOM");
2469 darling_cases.* = .{
2470 .b = b,
2471 .step = step,
2472 .test_filters = test_filters,
2473 .targets = darlingTargets(b),
2474 .convert_exe = convert_exe,
2475 };
2476 stack_traces.addCases(darling_cases, .macos);
24812477
24822478 return step;
24832479}
......@@ -2510,31 +2506,27 @@ pub fn addErrorTraceTests(
25102506 };
25112507 error_traces.addCases(host_cases, b.graph.host.result.os.tag);
25122508
2513 if (b.enable_wine) {
2514 const wine_cases = b.allocator.create(ErrorTracesContext) catch @panic("OOM");
2515 wine_cases.* = .{
2516 .b = b,
2517 .step = step,
2518 .test_filters = test_filters,
2519 .targets = wineAndCompatible32bit(b, skip_non_native),
2520 .optimize_modes = optimize_modes,
2521 .convert_exe = convert_exe,
2522 };
2523 error_traces.addCases(wine_cases, .windows);
2524 }
2509 const wine_cases = b.allocator.create(ErrorTracesContext) catch @panic("OOM");
2510 wine_cases.* = .{
2511 .b = b,
2512 .step = step,
2513 .test_filters = test_filters,
2514 .targets = wineAndCompatible32bit(b, skip_non_native),
2515 .optimize_modes = optimize_modes,
2516 .convert_exe = convert_exe,
2517 };
2518 error_traces.addCases(wine_cases, .windows);
25252519
2526 if (b.enable_darling) {
2527 const darling_cases = b.allocator.create(ErrorTracesContext) catch @panic("OOM");
2528 darling_cases.* = .{
2529 .b = b,
2530 .step = step,
2531 .test_filters = test_filters,
2532 .targets = darlingTargets(b),
2533 .optimize_modes = optimize_modes,
2534 .convert_exe = convert_exe,
2535 };
2536 error_traces.addCases(darling_cases, .macos);
2537 }
2520 const darling_cases = b.allocator.create(ErrorTracesContext) catch @panic("OOM");
2521 darling_cases.* = .{
2522 .b = b,
2523 .step = step,
2524 .test_filters = test_filters,
2525 .targets = darlingTargets(b),
2526 .optimize_modes = optimize_modes,
2527 .convert_exe = convert_exe,
2528 };
2529 error_traces.addCases(darling_cases, .macos);
25382530
25392531 return step;
25402532}