From a1e1f720edc322b1c68fe9bc925f663ae5308cb9 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Fri, 4 Apr 2025 21:14:36 -0700 Subject: [PATCH] Bump WebKit (#18784) Co-authored-by: Ben Grant Co-authored-by: Dylan Conway --- cmake/tools/SetupWebKit.cmake | 2 +- src/cli/test_command.zig | 4 +--- src/fmt.zig | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/cmake/tools/SetupWebKit.cmake b/cmake/tools/SetupWebKit.cmake index 05c3c74784..53bf34d890 100644 --- a/cmake/tools/SetupWebKit.cmake +++ b/cmake/tools/SetupWebKit.cmake @@ -2,7 +2,7 @@ option(WEBKIT_VERSION "The version of WebKit to use") option(WEBKIT_LOCAL "If a local version of WebKit should be used instead of downloading") if(NOT WEBKIT_VERSION) - set(WEBKIT_VERSION 76e7e4177b87b24361a8ed8c08777b2bba7a891a) + set(WEBKIT_VERSION 12d2dfab74b34a50c8544c59f8a9454ce2e06e06) endif() string(SUBSTRING ${WEBKIT_VERSION} 0 16 WEBKIT_VERSION_PREFIX) diff --git a/src/cli/test_command.zig b/src/cli/test_command.zig index 1994d3f23c..0a715c9242 100644 --- a/src/cli/test_command.zig +++ b/src/cli/test_command.zig @@ -352,9 +352,7 @@ pub const JunitReporter = struct { try this.contents.appendSlice(bun.default_allocator, "\""); const elapsed_seconds = elapsed_ms / std.time.ms_per_s; - var time_buf: [32]u8 = undefined; - const time_str = try std.fmt.bufPrint(&time_buf, " time=\"{d}\"", .{elapsed_seconds}); - try this.contents.appendSlice(bun.default_allocator, time_str); + try this.contents.writer(bun.default_allocator).print(" time=\"{}\"", .{bun.fmt.trimmedPrecision(elapsed_seconds, 6)}); try this.contents.appendSlice(bun.default_allocator, " file=\""); try escapeXml(file, this.contents.writer(bun.default_allocator)); diff --git a/src/fmt.zig b/src/fmt.zig index 447928ebd2..f82be8702f 100644 --- a/src/fmt.zig +++ b/src/fmt.zig @@ -1575,6 +1575,33 @@ pub fn hexIntUpper(value: anytype) HexIntFormatter(@TypeOf(value), false) { return Formatter{ .value = value }; } +/// Equivalent to `{d:.}` but trims trailing zeros +/// if decimal part is less than `precision` digits. +fn TrimmedPrecisionFormatter(comptime precision: usize) type { + return struct { + num: f64, + precision: usize, + + pub fn format(self: @This(), comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { + const whole = @trunc(self.num); + try writer.print("{d}", .{whole}); + const rem = self.num - whole; + if (rem != 0) { + var buf: [2 + precision]u8 = undefined; + var formatted = std.fmt.bufPrint(&buf, "{d:." ++ std.fmt.comptimePrint("{d}", .{precision}) ++ "}", .{rem}) catch unreachable; + formatted = formatted[2..]; + const trimmed = std.mem.trimRight(u8, formatted, "0"); + try writer.print(".{s}", .{trimmed}); + } + } + }; +} + +pub fn trimmedPrecision(value: f64, comptime precision: usize) TrimmedPrecisionFormatter(precision) { + const Formatter = TrimmedPrecisionFormatter(precision); + return Formatter{ .num = value, .precision = precision }; +} + const FormatDurationData = struct { ns: u64, negative: bool = false,