| author | |
| committer | |
| log | 7a92d878ee9739b7c67be09904f332fad1f1fdaa |
| tree | d20ae5e58cec3989118fafbd2e1d704cc2ba4bc2 |
| parent | a16a1a608262e9881e127922c8f27921c4af8407 |
prevents leak logs in test results2 files changed, 8 insertions(+), 4 deletions(-)
generate.ts+4-2| ... | @@ -61,10 +61,11 @@ const E = stringEscape; | ... | @@ -61,10 +61,11 @@ const E = stringEscape; |
| 61 | w.write(` | 61 | w.write(` |
| 62 | pub fn parseFail(input: []const u8, base: ?[]const u8) !void { | 62 | pub fn parseFail(input: []const u8, base: ?[]const u8) !void { |
| 63 | const allocator = std.testing.allocator; | 63 | const allocator = std.testing.allocator; |
| 64 | _ = url.URL.parse(allocator, input, base) catch |err| switch (err) { | 64 | const u = url.URL.parse(allocator, input, base) catch |err| switch (err) { |
| 65 | error.InvalidURL => return, | 65 | error.InvalidURL => return, |
| 66 | error.OutOfMemory => return error.OutOfMemory, | 66 | error.OutOfMemory => return error.OutOfMemory, |
| 67 | }; | 67 | }; |
| 68 | defer allocator.free(u.href); | ||
| 68 | return error.FailZigTest; | 69 | return error.FailZigTest; |
| 69 | } | 70 | } |
| 70 | 71 | ||
| ... | @@ -87,10 +88,11 @@ pub fn parsePass(input: []const u8, base: ?[]const u8, href: []const u8, origin: | ... | @@ -87,10 +88,11 @@ pub fn parsePass(input: []const u8, base: ?[]const u8, href: []const u8, origin: |
| 87 | 88 | ||
| 88 | pub fn parseIDNAFail(comptime input: []const u8) !void { | 89 | pub fn parseIDNAFail(comptime input: []const u8) !void { |
| 89 | const allocator = std.testing.allocator; | 90 | const allocator = std.testing.allocator; |
| 90 | _ = url.URL.parse(allocator, "https://" ++ input ++ "/x", null) catch |err| switch (err) { | 91 | const u = url.URL.parse(allocator, "https://" ++ input ++ "/x", null) catch |err| switch (err) { |
| 91 | error.InvalidURL => return, | 92 | error.InvalidURL => return, |
| 92 | error.OutOfMemory => return error.OutOfMemory, | 93 | error.OutOfMemory => return error.OutOfMemory, |
| 93 | }; | 94 | }; |
| 95 | defer allocator.free(u.href); | ||
| 94 | return error.FailZigTest; | 96 | return error.FailZigTest; |
| 95 | } | 97 | } |
| 96 | 98 |
zig-out/test.zig+4-2| ... | @@ -6,10 +6,11 @@ const expect = @import("expect").expect; | ... | @@ -6,10 +6,11 @@ const expect = @import("expect").expect; |
| 6 | 6 | ||
| 7 | pub fn parseFail(input: []const u8, base: ?[]const u8) !void { | 7 | pub fn parseFail(input: []const u8, base: ?[]const u8) !void { |
| 8 | const allocator = std.testing.allocator; | 8 | const allocator = std.testing.allocator; |
| 9 | _ = url.URL.parse(allocator, input, base) catch |err| switch (err) { | 9 | const u = url.URL.parse(allocator, input, base) catch |err| switch (err) { |
| 10 | error.InvalidURL => return, | 10 | error.InvalidURL => return, |
| 11 | error.OutOfMemory => return error.OutOfMemory, | 11 | error.OutOfMemory => return error.OutOfMemory, |
| 12 | }; | 12 | }; |
| 13 | defer allocator.free(u.href); | ||
| 13 | return error.FailZigTest; | 14 | return error.FailZigTest; |
| 14 | } | 15 | } |
| 15 | 16 | ||
| ... | @@ -32,10 +33,11 @@ pub fn parsePass(input: []const u8, base: ?[]const u8, href: []const u8, origin: | ... | @@ -32,10 +33,11 @@ pub fn parsePass(input: []const u8, base: ?[]const u8, href: []const u8, origin: |
| 32 | 33 | ||
| 33 | pub fn parseIDNAFail(comptime input: []const u8) !void { | 34 | pub fn parseIDNAFail(comptime input: []const u8) !void { |
| 34 | const allocator = std.testing.allocator; | 35 | const allocator = std.testing.allocator; |
| 35 | _ = url.URL.parse(allocator, "https://" ++ input ++ "/x", null) catch |err| switch (err) { | 36 | const u = url.URL.parse(allocator, "https://" ++ input ++ "/x", null) catch |err| switch (err) { |
| 36 | error.InvalidURL => return, | 37 | error.InvalidURL => return, |
| 37 | error.OutOfMemory => return error.OutOfMemory, | 38 | error.OutOfMemory => return error.OutOfMemory, |
| 38 | }; | 39 | }; |
| 40 | defer allocator.free(u.href); | ||
| 39 | return error.FailZigTest; | 41 | return error.FailZigTest; |
| 40 | } | 42 | } |
| 41 | 43 |