mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
Merge pull request #1108 from lightpanda-io/wpt_panic_handler
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
Add custom panic handler to printt which file caused a panic
This commit is contained in:
@@ -29,6 +29,9 @@ const TestHTTPServer = @import("TestHTTPServer.zig");
|
|||||||
|
|
||||||
const WPT_DIR = "tests/wpt";
|
const WPT_DIR = "tests/wpt";
|
||||||
|
|
||||||
|
// use in custom panic handler
|
||||||
|
var current_test: ?[]const u8 = null;
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
var gpa: std.heap.DebugAllocator(.{}) = .init;
|
var gpa: std.heap.DebugAllocator(.{}) = .init;
|
||||||
defer _ = gpa.deinit();
|
defer _ = gpa.deinit();
|
||||||
@@ -77,6 +80,9 @@ pub fn main() !void {
|
|||||||
while (try it.next()) |test_file| {
|
while (try it.next()) |test_file| {
|
||||||
defer _ = test_arena.reset(.retain_capacity);
|
defer _ = test_arena.reset(.retain_capacity);
|
||||||
|
|
||||||
|
defer current_test = null;
|
||||||
|
current_test = test_file;
|
||||||
|
|
||||||
var err_out: ?[]const u8 = null;
|
var err_out: ?[]const u8 = null;
|
||||||
const result = run(
|
const result = run(
|
||||||
test_arena.allocator(),
|
test_arena.allocator(),
|
||||||
@@ -448,3 +454,12 @@ fn httpHandler(req: *std.http.Server.Request) !void {
|
|||||||
const file_path = try std.fmt.bufPrint(&buf, WPT_DIR ++ "{s}", .{path});
|
const file_path = try std.fmt.bufPrint(&buf, WPT_DIR ++ "{s}", .{path});
|
||||||
return TestHTTPServer.sendFile(req, file_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);
|
||||||
|
|||||||
Reference in New Issue
Block a user