authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-01-11 17:17:59 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-01-11 17:22:04 -08:00
log3ed9f53a9cb6b22789662b171e8a58236a1dd33a
treeb0005e924662d7c2236677aba213df5a2e0cb09e
parent4f702eb6c991e8b11262b3477f1462175d509633

add 'zig build generate' step


6 files changed, 64 insertions(+), 58 deletions(-)

.gitignore-1
......@@ -1,5 +1,4 @@
11.zig-cache
2zig-out
32.zigmod
43deps.zig
54files.zig
build.zig+8
......@@ -5,6 +5,14 @@ pub fn build(b: *std.Build) void {
55 const target = b.standardTargetOptions(.{});
66 const mode = b.option(std.builtin.Mode, "mode", "") orelse .Debug;
77
8 const gen_step = b.step("generate", "");
9 const gen_cmd = b.addSystemCommand(&.{ "bun", "./generate.ts" });
10 const gen_out = gen_cmd.addOutputFileArg("test.zig");
11 const gen_install = b.addInstallFile(gen_out, "test.zig");
12 gen_cmd.setCwd(b.path("."));
13 gen_cmd.addFileInput(b.path("generate.ts"));
14 gen_step.dependOn(&gen_install.step);
15
816 const tests = b.addTest(.{
917 .root_source_file = b.path("test.zig"),
1018 .target = target,
generate.ts+1-2
......@@ -3,8 +3,7 @@ import casesraw from "./urltestdata.json";
33import casesidna from "./IdnaTestV2.json";
44
55const cases = casesraw.filter((v) => typeof v !== "string");
6closeSync(openSync("./test.generated.zig", "w", 0o777));
7const f = Bun.file("./test.generated.zig");
6const f = Bun.file(process.argv[2]!);
87const w = f.writer();
98
109w.write(`const std = @import("std");\n`);
test.generated.zig deleted-54
......@@ -1,54 +0,0 @@
1const std = @import("std");
2const url = @import("url");
3const expect = @import("expect").expect;
4
5// zig fmt: off
6
7pub fn parseFail(input: []const u8, base: ?[]const u8) !void {
8 const allocator = std.testing.allocator;
9 _ = url.URL.parse(allocator, input, base) catch |err| switch (err) {
10 error.SkipZigTest => |e| return e,
11 else => return,
12 };
13 return error.FailZigTest;
14}
15
16pub fn parsePass(input: []const u8, base: ?[]const u8, href: []const u8, origin: []const u8, protocol: []const u8, username: []const u8, password: []const u8, host: []const u8, hostname: []const u8, port: []const u8, pathname: []const u8, search: []const u8, hash: []const u8) !void {
17 _ = input;
18 _ = base;
19 _ = href;
20 _ = origin;
21 _ = protocol;
22 _ = username;
23 _ = password;
24 _ = host;
25 _ = hostname;
26 _ = port;
27 _ = pathname;
28 _ = search;
29 _ = hash;
30 return error.SkipZigTest;
31}
32
33pub fn parseIDNAFail(input: []const u8) !void {
34 _ = input;
35 // new URL('https://{idnaTest.input}/x')
36 return error.SkipZigTest;
37}
38
39pub fn parseIDNAPass(input: []const u8, output: []const u8) !void {
40 _ = input;
41 _ = output;
42 // new URL('https://{idnaTest.input}/x');
43 // assert_equals(url.host, idnaTest.output);
44 // assert_equals(url.hostname, idnaTest.output);
45 // assert_equals(url.pathname, "/x");
46 // assert_equals(url.href, 'https://{idnaTest.output}/x');
47 return error.SkipZigTest;
48}
49
50
51
52
53
54
test.zig+1-1
......@@ -2,5 +2,5 @@ const std = @import("std");
22const url = @import("url");
33
44test {
5 _ = @import("./test.generated.zig");
5 _ = @import("./zig-out/test.zig");
66}
zig-out/test.zig created+54
......@@ -0,0 +1,54 @@
1const std = @import("std");
2const url = @import("url");
3const expect = @import("expect").expect;
4
5// zig fmt: off
6
7pub fn parseFail(input: []const u8, base: ?[]const u8) !void {
8 const allocator = std.testing.allocator;
9 _ = url.URL.parse(allocator, input, base) catch |err| switch (err) {
10 error.SkipZigTest => |e| return e,
11 else => return,
12 };
13 return error.FailZigTest;
14}
15
16pub fn parsePass(input: []const u8, base: ?[]const u8, href: []const u8, origin: []const u8, protocol: []const u8, username: []const u8, password: []const u8, host: []const u8, hostname: []const u8, port: []const u8, pathname: []const u8, search: []const u8, hash: []const u8) !void {
17 _ = input;
18 _ = base;
19 _ = href;
20 _ = origin;
21 _ = protocol;
22 _ = username;
23 _ = password;
24 _ = host;
25 _ = hostname;
26 _ = port;
27 _ = pathname;
28 _ = search;
29 _ = hash;
30 return error.SkipZigTest;
31}
32
33pub fn parseIDNAFail(input: []const u8) !void {
34 _ = input;
35 // new URL('https://{idnaTest.input}/x')
36 return error.SkipZigTest;
37}
38
39pub fn parseIDNAPass(input: []const u8, output: []const u8) !void {
40 _ = input;
41 _ = output;
42 // new URL('https://{idnaTest.input}/x');
43 // assert_equals(url.host, idnaTest.output);
44 // assert_equals(url.hostname, idnaTest.output);
45 // assert_equals(url.pathname, "/x");
46 // assert_equals(url.href, 'https://{idnaTest.output}/x');
47 return error.SkipZigTest;
48}
49
50
51
52
53
54