mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
update stack trace tests to account for new defaults
ReleaseSafe optimization mode now defaults error tracing to false.
This commit is contained in:
parent
beed47e8c3
commit
c8c32a0569
2 changed files with 59 additions and 66 deletions
|
|
@ -5,44 +5,33 @@ test_filter: ?[]const u8,
|
|||
optimize_modes: []const OptimizeMode,
|
||||
check_exe: *std.Build.Step.Compile,
|
||||
|
||||
const Expect = [@typeInfo(OptimizeMode).Enum.fields.len][]const u8;
|
||||
const Config = struct {
|
||||
name: []const u8,
|
||||
source: []const u8,
|
||||
Debug: ?PerMode = null,
|
||||
ReleaseSmall: ?PerMode = null,
|
||||
ReleaseSafe: ?PerMode = null,
|
||||
ReleaseFast: ?PerMode = null,
|
||||
|
||||
pub fn addCase(self: *StackTrace, config: anytype) void {
|
||||
if (@hasField(@TypeOf(config), "exclude")) {
|
||||
if (config.exclude.exclude()) return;
|
||||
}
|
||||
if (@hasField(@TypeOf(config), "exclude_arch")) {
|
||||
const exclude_arch: []const std.Target.Cpu.Arch = &config.exclude_arch;
|
||||
for (exclude_arch) |arch| if (arch == builtin.cpu.arch) return;
|
||||
}
|
||||
if (@hasField(@TypeOf(config), "exclude_os")) {
|
||||
const exclude_os: []const std.Target.Os.Tag = &config.exclude_os;
|
||||
for (exclude_os) |os| if (os == builtin.os.tag) return;
|
||||
}
|
||||
for (self.optimize_modes) |optimize_mode| {
|
||||
switch (optimize_mode) {
|
||||
.Debug => {
|
||||
if (@hasField(@TypeOf(config), "Debug")) {
|
||||
self.addExpect(config.name, config.source, optimize_mode, config.Debug);
|
||||
}
|
||||
},
|
||||
.ReleaseSafe => {
|
||||
if (@hasField(@TypeOf(config), "ReleaseSafe")) {
|
||||
self.addExpect(config.name, config.source, optimize_mode, config.ReleaseSafe);
|
||||
}
|
||||
},
|
||||
.ReleaseFast => {
|
||||
if (@hasField(@TypeOf(config), "ReleaseFast")) {
|
||||
self.addExpect(config.name, config.source, optimize_mode, config.ReleaseFast);
|
||||
}
|
||||
},
|
||||
.ReleaseSmall => {
|
||||
if (@hasField(@TypeOf(config), "ReleaseSmall")) {
|
||||
self.addExpect(config.name, config.source, optimize_mode, config.ReleaseSmall);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
const PerMode = struct {
|
||||
expect: []const u8,
|
||||
exclude_os: []const std.Target.Os.Tag = &.{},
|
||||
error_tracing: ?bool = null,
|
||||
};
|
||||
};
|
||||
|
||||
pub fn addCase(self: *StackTrace, config: Config) void {
|
||||
if (config.Debug) |per_mode|
|
||||
self.addExpect(config.name, config.source, .Debug, per_mode);
|
||||
|
||||
if (config.ReleaseSmall) |per_mode|
|
||||
self.addExpect(config.name, config.source, .ReleaseSmall, per_mode);
|
||||
|
||||
if (config.ReleaseFast) |per_mode|
|
||||
self.addExpect(config.name, config.source, .ReleaseFast, per_mode);
|
||||
|
||||
if (config.ReleaseSafe) |per_mode|
|
||||
self.addExpect(config.name, config.source, .ReleaseSafe, per_mode);
|
||||
}
|
||||
|
||||
fn addExpect(
|
||||
|
|
@ -50,19 +39,9 @@ fn addExpect(
|
|||
name: []const u8,
|
||||
source: []const u8,
|
||||
optimize_mode: OptimizeMode,
|
||||
mode_config: anytype,
|
||||
mode_config: Config.PerMode,
|
||||
) void {
|
||||
if (@hasField(@TypeOf(mode_config), "exclude")) {
|
||||
if (mode_config.exclude.exclude()) return;
|
||||
}
|
||||
if (@hasField(@TypeOf(mode_config), "exclude_arch")) {
|
||||
const exclude_arch: []const std.Target.Cpu.Arch = &mode_config.exclude_arch;
|
||||
for (exclude_arch) |arch| if (arch == builtin.cpu.arch) return;
|
||||
}
|
||||
if (@hasField(@TypeOf(mode_config), "exclude_os")) {
|
||||
const exclude_os: []const std.Target.Os.Tag = &mode_config.exclude_os;
|
||||
for (exclude_os) |os| if (os == builtin.os.tag) return;
|
||||
}
|
||||
for (mode_config.exclude_os) |tag| if (tag == builtin.os.tag) return;
|
||||
|
||||
const b = self.b;
|
||||
const annotated_case_name = fmt.allocPrint(b.allocator, "check {s} ({s})", .{
|
||||
|
|
@ -78,6 +57,7 @@ fn addExpect(
|
|||
.root_source_file = write_src.files.items[0].getPath(),
|
||||
.optimize = optimize_mode,
|
||||
.target = b.host,
|
||||
.error_tracing = mode_config.error_tracing,
|
||||
});
|
||||
|
||||
const run = b.addRunArtifact(exe);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
,
|
||||
},
|
||||
.ReleaseSafe = .{
|
||||
.exclude_os = .{
|
||||
.exclude_os = &.{
|
||||
.windows, // TODO
|
||||
.linux, // defeated by aggressive inlining
|
||||
},
|
||||
|
|
@ -31,6 +31,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
\\ ^
|
||||
\\
|
||||
,
|
||||
.error_tracing = true,
|
||||
},
|
||||
.ReleaseFast = .{
|
||||
.expect =
|
||||
|
|
@ -70,7 +71,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
,
|
||||
},
|
||||
.ReleaseSafe = .{
|
||||
.exclude_os = .{
|
||||
.exclude_os = &.{
|
||||
.windows, // TODO
|
||||
},
|
||||
.expect =
|
||||
|
|
@ -83,6 +84,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
\\ ^
|
||||
\\
|
||||
,
|
||||
.error_tracing = true,
|
||||
},
|
||||
.ReleaseFast = .{
|
||||
.expect =
|
||||
|
|
@ -125,7 +127,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
,
|
||||
},
|
||||
.ReleaseSafe = .{
|
||||
.exclude_os = .{
|
||||
.exclude_os = &.{
|
||||
.windows, // TODO
|
||||
.linux, // defeated by aggressive inlining
|
||||
},
|
||||
|
|
@ -136,6 +138,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
\\ ^
|
||||
\\
|
||||
,
|
||||
.error_tracing = true,
|
||||
},
|
||||
.ReleaseFast = .{
|
||||
.expect =
|
||||
|
|
@ -176,7 +179,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
,
|
||||
},
|
||||
.ReleaseSafe = .{
|
||||
.exclude_os = .{
|
||||
.exclude_os = &.{
|
||||
.windows, // TODO
|
||||
.linux, // defeated by aggressive inlining
|
||||
},
|
||||
|
|
@ -187,6 +190,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
\\ ^
|
||||
\\
|
||||
,
|
||||
.error_tracing = true,
|
||||
},
|
||||
.ReleaseFast = .{
|
||||
.expect =
|
||||
|
|
@ -230,7 +234,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
,
|
||||
},
|
||||
.ReleaseSafe = .{
|
||||
.exclude_os = .{
|
||||
.exclude_os = &.{
|
||||
.windows, // TODO
|
||||
.linux, // defeated by aggressive inlining
|
||||
},
|
||||
|
|
@ -244,6 +248,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
\\ ^
|
||||
\\
|
||||
,
|
||||
.error_tracing = true,
|
||||
},
|
||||
.ReleaseFast = .{
|
||||
.expect =
|
||||
|
|
@ -286,7 +291,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
,
|
||||
},
|
||||
.ReleaseSafe = .{
|
||||
.exclude_os = .{
|
||||
.exclude_os = &.{
|
||||
.windows, // TODO
|
||||
.linux, // defeated by aggressive inlining
|
||||
},
|
||||
|
|
@ -297,6 +302,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
\\ ^
|
||||
\\
|
||||
,
|
||||
.error_tracing = true,
|
||||
},
|
||||
.ReleaseFast = .{
|
||||
.expect =
|
||||
|
|
@ -336,7 +342,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
,
|
||||
},
|
||||
.ReleaseSafe = .{
|
||||
.exclude_os = .{
|
||||
.exclude_os = &.{
|
||||
.windows, // TODO
|
||||
.linux, // defeated by aggressive inlining
|
||||
},
|
||||
|
|
@ -350,6 +356,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
\\ ^
|
||||
\\
|
||||
,
|
||||
.error_tracing = true,
|
||||
},
|
||||
.ReleaseFast = .{
|
||||
.expect =
|
||||
|
|
@ -391,7 +398,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
,
|
||||
},
|
||||
.ReleaseSafe = .{
|
||||
.exclude_os = .{
|
||||
.exclude_os = &.{
|
||||
.windows, // TODO
|
||||
.linux, // defeated by aggressive inlining
|
||||
},
|
||||
|
|
@ -402,6 +409,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
\\ ^
|
||||
\\
|
||||
,
|
||||
.error_tracing = true,
|
||||
},
|
||||
.ReleaseFast = .{
|
||||
.expect =
|
||||
|
|
@ -461,7 +469,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
,
|
||||
},
|
||||
.ReleaseSafe = .{
|
||||
.exclude_os = .{
|
||||
.exclude_os = &.{
|
||||
.windows, // TODO
|
||||
.linux, // defeated by aggressive inlining
|
||||
},
|
||||
|
|
@ -478,6 +486,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
\\ ^
|
||||
\\
|
||||
,
|
||||
.error_tracing = true,
|
||||
},
|
||||
.ReleaseFast = .{
|
||||
.expect =
|
||||
|
|
@ -531,7 +540,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
,
|
||||
},
|
||||
.ReleaseSafe = .{
|
||||
.exclude_os = .{
|
||||
.exclude_os = &.{
|
||||
.windows, // TODO
|
||||
},
|
||||
.expect =
|
||||
|
|
@ -547,6 +556,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
\\ ^
|
||||
\\
|
||||
,
|
||||
.error_tracing = true,
|
||||
},
|
||||
.ReleaseFast = .{
|
||||
.expect =
|
||||
|
|
@ -595,7 +605,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
,
|
||||
},
|
||||
.ReleaseSafe = .{
|
||||
.exclude_os = .{
|
||||
.exclude_os = &.{
|
||||
.windows, // TODO
|
||||
},
|
||||
.expect =
|
||||
|
|
@ -611,6 +621,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
\\ ^
|
||||
\\
|
||||
,
|
||||
.error_tracing = true,
|
||||
},
|
||||
.ReleaseFast = .{
|
||||
.expect =
|
||||
|
|
@ -659,7 +670,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
,
|
||||
},
|
||||
.ReleaseSafe = .{
|
||||
.exclude_os = .{
|
||||
.exclude_os = &.{
|
||||
.windows, // TODO
|
||||
},
|
||||
.expect =
|
||||
|
|
@ -675,6 +686,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
\\ ^
|
||||
\\
|
||||
,
|
||||
.error_tracing = true,
|
||||
},
|
||||
.ReleaseFast = .{
|
||||
.expect =
|
||||
|
|
@ -728,7 +740,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
,
|
||||
},
|
||||
.ReleaseSafe = .{
|
||||
.exclude_os = .{
|
||||
.exclude_os = &.{
|
||||
.windows, // TODO
|
||||
},
|
||||
.expect =
|
||||
|
|
@ -747,6 +759,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
\\ ^
|
||||
\\
|
||||
,
|
||||
.error_tracing = true,
|
||||
},
|
||||
.ReleaseFast = .{
|
||||
.expect =
|
||||
|
|
@ -763,10 +776,6 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
});
|
||||
|
||||
cases.addCase(.{
|
||||
.exclude_os = .{
|
||||
.openbsd, // integer overflow
|
||||
.windows, // TODO intermittent failures
|
||||
},
|
||||
.name = "dumpCurrentStackTrace",
|
||||
.source =
|
||||
\\const std = @import("std");
|
||||
|
|
@ -783,6 +792,10 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
\\}
|
||||
,
|
||||
.Debug = .{
|
||||
.exclude_os = &.{
|
||||
.openbsd, // integer overflow
|
||||
.windows, // TODO intermittent failures
|
||||
},
|
||||
.expect =
|
||||
\\source.zig:7:8: [address] in foo (test)
|
||||
\\ bar();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue