Skip to content

Commit 78031c5

Browse files
committed
generate proper JSON
1 parent 9775ceb commit 78031c5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main_wpt.zig

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,12 @@ const Writer = struct {
203203

204204
fn finalize(self: *Writer) !void {
205205
if (self.format == .json) {
206-
try self.out.writeByte(']');
206+
// When we write a test output, we add a trailing comma to act as
207+
// a separator for the next test. We need to add this dummy entry
208+
// to make it valid json.
209+
// Better option could be to change the formatter to work on JSONL:
210+
// https://github.com/lightpanda-io/perf-fmt/blob/main/wpt/wpt.go
211+
try self.out.writeAll("{\"name\":\"trailing-hack\",\"pass\": true}]");
207212
} else {
208213
try self.out.print("\n==Summary==\nTests: {d}/{d}\nCases: {d}/{d}\n", .{
209214
self.pass_count,
@@ -298,6 +303,8 @@ const Writer = struct {
298303
.name = test_file,
299304
.cases = cases.items,
300305
}, .{ .whitespace = .indent_2 }, self.out);
306+
// separator, see `finalize` for the hack we use to terminate this
307+
try self.out.writeByte(',');
301308
},
302309
}
303310
}

0 commit comments

Comments
 (0)