Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/main_wpt.zig
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ const TestHTTPServer = @import("TestHTTPServer.zig");

const WPT_DIR = "tests/wpt";

// use in custom panic handler
var current_test: ?[]const u8 = null;

pub fn main() !void {
var gpa: std.heap.DebugAllocator(.{}) = .init;
defer _ = gpa.deinit();
Expand Down Expand Up @@ -77,6 +80,9 @@ pub fn main() !void {
while (try it.next()) |test_file| {
defer _ = test_arena.reset(.retain_capacity);

defer current_test = null;
current_test = test_file;

var err_out: ?[]const u8 = null;
const result = run(
test_arena.allocator(),
Expand Down Expand Up @@ -448,3 +454,12 @@ fn httpHandler(req: *std.http.Server.Request) !void {
const file_path = try std.fmt.bufPrint(&buf, WPT_DIR ++ "{s}", .{path});
return TestHTTPServer.sendFile(req, file_path);
}

pub const panic = std.debug.FullPanic(struct {
pub fn panicFn(msg: []const u8, first_trace_addr: ?usize) noreturn {
if (current_test) |ct| {
std.debug.print("===panic running: {s}===\n", .{ct});
}
std.debug.defaultPanic(msg, first_trace_addr);
}
}.panicFn);