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(...@@ -105,6 +105,7 @@ fn addCaseConfig(
105 exe.bundle_ubsan_rt = false;105 exe.bundle_ubsan_rt = false;
106106
107 const run = b.addRunArtifact(exe);107 const run = b.addRunArtifact(exe);
108 run.skip_foreign_checks = true;
108 run.removeEnvironmentVariable("CLICOLOR_FORCE");109 run.removeEnvironmentVariable("CLICOLOR_FORCE");
109 run.setEnvironmentVariable("NO_COLOR", "1");110 run.setEnvironmentVariable("NO_COLOR", "1");
110 run.expectExitCode(1);111 run.expectExitCode(1);
...@@ -116,6 +117,7 @@ fn addCaseConfig(...@@ -116,6 +117,7 @@ fn addCaseConfig(
116 };117 };
117118
118 const check_run = b.addRunArtifact(self.convert_exe);119 const check_run = b.addRunArtifact(self.convert_exe);
120 check_run.skip_foreign_checks = true;
119 check_run.setName(annotated_case_name);121 check_run.setName(annotated_case_name);
120 check_run.addFileArg(run.captureStdErr(.{}));122 check_run.addFileArg(run.captureStdErr(.{}));
121 check_run.expectStdOutEqual(expected_stderr);123 check_run.expectStdOutEqual(expected_stderr);
test/src/StackTrace.zig+2
...@@ -224,6 +224,7 @@ fn addCaseInstance(...@@ -224,6 +224,7 @@ fn addCaseInstance(
224 exe.bundle_ubsan_rt = false;224 exe.bundle_ubsan_rt = false;
225225
226 const run = b.addRunArtifact(exe);226 const run = b.addRunArtifact(exe);
227 run.skip_foreign_checks = true;
227 run.removeEnvironmentVariable("CLICOLOR_FORCE");228 run.removeEnvironmentVariable("CLICOLOR_FORCE");
228 run.setEnvironmentVariable("NO_COLOR", "1");229 run.setEnvironmentVariable("NO_COLOR", "1");
229 run.addCheck(.{ .expect_term = term: {230 run.addCheck(.{ .expect_term = term: {
...@@ -234,6 +235,7 @@ fn addCaseInstance(...@@ -234,6 +235,7 @@ fn addCaseInstance(
234 run.expectStdOutEqual("");235 run.expectStdOutEqual("");
235236
236 const check_run = b.addRunArtifact(self.convert_exe);237 const check_run = b.addRunArtifact(self.convert_exe);
238 check_run.skip_foreign_checks = true;
237 check_run.setName(annotated_case_name);239 check_run.setName(annotated_case_name);
238 check_run.addFileArg(run.captureStdErr(.{}));240 check_run.addFileArg(run.captureStdErr(.{}));
239 check_run.expectExitCode(0);241 check_run.expectExitCode(0);
test/tests.zig+38-46
...@@ -2455,29 +2455,25 @@ pub fn addStackTraceTests(...@@ -2455,29 +2455,25 @@ pub fn addStackTraceTests(
2455 };2455 };
2456 stack_traces.addCases(host_cases, b.graph.host.result.os.tag);2456 stack_traces.addCases(host_cases, b.graph.host.result.os.tag);
24572457
2458 if (b.enable_wine) {2458 const wine_cases = b.allocator.create(StackTracesContext) catch @panic("OOM");
2459 const wine_cases = b.allocator.create(StackTracesContext) catch @panic("OOM");2459 wine_cases.* = .{
2460 wine_cases.* = .{2460 .b = b,
2461 .b = b,2461 .step = step,
2462 .step = step,2462 .test_filters = test_filters,
2463 .test_filters = test_filters,2463 .targets = wineAndCompatible32bit(b, skip_non_native),
2464 .targets = wineAndCompatible32bit(b, skip_non_native),2464 .convert_exe = convert_exe,
2465 .convert_exe = convert_exe,2465 };
2466 };2466 stack_traces.addCases(wine_cases, .windows);
2467 stack_traces.addCases(wine_cases, .windows);
2468 }
24692467
2470 if (b.enable_darling) {2468 const darling_cases = b.allocator.create(StackTracesContext) catch @panic("OOM");
2471 const darling_cases = b.allocator.create(StackTracesContext) catch @panic("OOM");2469 darling_cases.* = .{
2472 darling_cases.* = .{2470 .b = b,
2473 .b = b,2471 .step = step,
2474 .step = step,2472 .test_filters = test_filters,
2475 .test_filters = test_filters,2473 .targets = darlingTargets(b),
2476 .targets = darlingTargets(b),2474 .convert_exe = convert_exe,
2477 .convert_exe = convert_exe,2475 };
2478 };2476 stack_traces.addCases(darling_cases, .macos);
2479 stack_traces.addCases(darling_cases, .macos);
2480 }
24812477
2482 return step;2478 return step;
2483}2479}
...@@ -2510,31 +2506,27 @@ pub fn addErrorTraceTests(...@@ -2510,31 +2506,27 @@ pub fn addErrorTraceTests(
2510 };2506 };
2511 error_traces.addCases(host_cases, b.graph.host.result.os.tag);2507 error_traces.addCases(host_cases, b.graph.host.result.os.tag);
25122508
2513 if (b.enable_wine) {2509 const wine_cases = b.allocator.create(ErrorTracesContext) catch @panic("OOM");
2514 const wine_cases = b.allocator.create(ErrorTracesContext) catch @panic("OOM");2510 wine_cases.* = .{
2515 wine_cases.* = .{2511 .b = b,
2516 .b = b,2512 .step = step,
2517 .step = step,2513 .test_filters = test_filters,
2518 .test_filters = test_filters,2514 .targets = wineAndCompatible32bit(b, skip_non_native),
2519 .targets = wineAndCompatible32bit(b, skip_non_native),2515 .optimize_modes = optimize_modes,
2520 .optimize_modes = optimize_modes,2516 .convert_exe = convert_exe,
2521 .convert_exe = convert_exe,2517 };
2522 };2518 error_traces.addCases(wine_cases, .windows);
2523 error_traces.addCases(wine_cases, .windows);
2524 }
25252519
2526 if (b.enable_darling) {2520 const darling_cases = b.allocator.create(ErrorTracesContext) catch @panic("OOM");
2527 const darling_cases = b.allocator.create(ErrorTracesContext) catch @panic("OOM");2521 darling_cases.* = .{
2528 darling_cases.* = .{2522 .b = b,
2529 .b = b,2523 .step = step,
2530 .step = step,2524 .test_filters = test_filters,
2531 .test_filters = test_filters,2525 .targets = darlingTargets(b),
2532 .targets = darlingTargets(b),2526 .optimize_modes = optimize_modes,
2533 .optimize_modes = optimize_modes,2527 .convert_exe = convert_exe,
2534 .convert_exe = convert_exe,2528 };
2535 };2529 error_traces.addCases(darling_cases, .macos);
2536 error_traces.addCases(darling_cases, .macos);
2537 }
25382530
2539 return step;2531 return step;
2540}2532}