authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-09-13 17:40:42+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-09-30 13:44:54+01:00
loge9c0d43c5b6fc5065ac2e22e162b7d7476f5097d
tree6935edc5add7088088a8677a4812165d63275516
parent2fefe0e4b39ab6f86e5af423304b8a7b2da5fe72
signaturelock-open Commit is signed but in an unrecognized format.

test-error-traces: skip some more optimized traces


2 files changed, 23 insertions(+), 6 deletions(-)

test/error_traces.zig+19-6
......@@ -37,6 +37,8 @@ pub fn addCases(cases: *@import("tests.zig").ErrorTracesContext) void {
3737 .disable_trace_optimized = &.{
3838 .{ .x86_64, .windows },
3939 .{ .x86, .windows },
40 .{ .x86_64, .macos },
41 .{ .aarch64, .macos },
4042 },
4143 });
4244 cases.addCase(.{
......@@ -86,12 +88,6 @@ pub fn addCases(cases: *@import("tests.zig").ErrorTracesContext) void {
8688 \\ return error.UnrelatedError;
8789 \\ ^
8890 ,
89 .disable_trace_optimized = &.{
90 .{ .x86_64, .linux },
91 .{ .x86, .linux },
92 .{ .x86_64, .windows },
93 .{ .x86, .windows },
94 },
9591 });
9692
9793 cases.addCase(.{
......@@ -121,6 +117,8 @@ pub fn addCases(cases: *@import("tests.zig").ErrorTracesContext) void {
121117 .disable_trace_optimized = &.{
122118 .{ .x86_64, .windows },
123119 .{ .x86, .windows },
120 .{ .x86_64, .macos },
121 .{ .aarch64, .macos },
124122 },
125123 });
126124
......@@ -172,6 +170,8 @@ pub fn addCases(cases: *@import("tests.zig").ErrorTracesContext) void {
172170 .disable_trace_optimized = &.{
173171 .{ .x86_64, .windows },
174172 .{ .x86, .windows },
173 .{ .x86_64, .macos },
174 .{ .aarch64, .macos },
175175 },
176176 });
177177
......@@ -242,6 +242,8 @@ pub fn addCases(cases: *@import("tests.zig").ErrorTracesContext) void {
242242 .disable_trace_optimized = &.{
243243 .{ .x86_64, .windows },
244244 .{ .x86, .windows },
245 .{ .x86_64, .macos },
246 .{ .aarch64, .macos },
245247 },
246248 });
247249
......@@ -282,6 +284,8 @@ pub fn addCases(cases: *@import("tests.zig").ErrorTracesContext) void {
282284 .disable_trace_optimized = &.{
283285 .{ .x86_64, .windows },
284286 .{ .x86, .windows },
287 .{ .x86_64, .macos },
288 .{ .aarch64, .macos },
285289 },
286290 });
287291
......@@ -317,6 +321,8 @@ pub fn addCases(cases: *@import("tests.zig").ErrorTracesContext) void {
317321 .disable_trace_optimized = &.{
318322 .{ .x86_64, .windows },
319323 .{ .x86, .windows },
324 .{ .x86_64, .macos },
325 .{ .aarch64, .macos },
320326 },
321327 });
322328
......@@ -352,6 +358,8 @@ pub fn addCases(cases: *@import("tests.zig").ErrorTracesContext) void {
352358 .disable_trace_optimized = &.{
353359 .{ .x86_64, .windows },
354360 .{ .x86, .windows },
361 .{ .x86_64, .macos },
362 .{ .aarch64, .macos },
355363 },
356364 });
357365
......@@ -392,6 +400,8 @@ pub fn addCases(cases: *@import("tests.zig").ErrorTracesContext) void {
392400 .disable_trace_optimized = &.{
393401 .{ .x86_64, .windows },
394402 .{ .x86, .windows },
403 .{ .x86_64, .macos },
404 .{ .aarch64, .macos },
395405 },
396406 });
397407
......@@ -423,8 +433,11 @@ pub fn addCases(cases: *@import("tests.zig").ErrorTracesContext) void {
423433 .disable_trace_optimized = &.{
424434 .{ .x86_64, .linux },
425435 .{ .x86, .linux },
436 .{ .aarch64, .linux },
426437 .{ .x86_64, .windows },
427438 .{ .x86, .windows },
439 .{ .x86_64, .macos },
440 .{ .aarch64, .macos },
428441 },
429442 });
430443}
test/src/ErrorTrace.zig+4
......@@ -13,6 +13,9 @@ pub const Case = struct {
1313 /// On these arch/OS pairs we will not test the error trace on optimized LLVM builds because the
1414 /// optimizations break the error trace. We will test the binary with error tracing disabled,
1515 /// just to ensure that the expected error is still returned from `main`.
16 ///
17 /// LLVM ReleaseSmall builds always have the trace disabled regardless of this field, because it
18 /// seems that LLVM is particularly good at optimizing traces away in those.
1619 disable_trace_optimized: []const DisableConfig = &.{},
1720
1821 pub const DisableConfig = struct { std.Target.Cpu.Arch, std.Target.Os.Tag };
......@@ -58,6 +61,7 @@ fn addCaseConfig(
5861 const error_tracing: bool = tracing: {
5962 if (optimize == .Debug) break :tracing true;
6063 if (backend != .llvm) break :tracing true;
64 if (optimize == .ReleaseSmall) break :tracing false;
6165 for (case.disable_trace_optimized) |disable| {
6266 const d_arch, const d_os = disable;
6367 if (target.result.cpu.arch == d_arch and target.result.os.tag == d_os) {