From 42bc1cb3dad77c9d3e010930ba634f7b53004fc4 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sun, 27 Oct 2024 02:55:02 -0700 Subject: [PATCH] get JSONTestSuite_root from deps.zig so the suite can be run from anywhere --- build.zig | 5 +++++ test.zig | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/build.zig b/build.zig index 3d961fd11660e572766dc26923459156c5bfef55..cc3c8cf7d72773ee87e927f191d5a46fba6ccfbf 100644 --- a/build.zig +++ b/build.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const string = []const u8; const deps = @import("./deps.zig"); pub fn build(b: *std.Build) void { @@ -12,6 +13,10 @@ pub fn build(b: *std.Build) void { }); deps.addAllTo(test_exe); + const build_options = b.addOptions(); + build_options.addOption(string, "JSONTestSuite_root", deps.dirs._bebdygynna6k ++ "/test_parsing"); + test_exe.root_module.addImport("build_options", build_options.createModule()); + const test_cmd = b.addRunArtifact(test_exe); test_cmd.has_side_effects = true; test_cmd.step.dependOn(b.getInstallStep()); diff --git a/test.zig b/test.zig index 5c14d037a43261a019079cbb6c5016231a81212c..417cbf2125442c6ecfe6f9bbbfd2773134de3a80 100644 --- a/test.zig +++ b/test.zig @@ -1,5 +1,7 @@ const std = @import("std"); const json = @import("json"); +const build_options = @import("build_options"); +const JSONTestSuite_root = build_options.JSONTestSuite_root; fn parse_full(buffer: []const u8) !void { const alloc = std.testing.allocator; @@ -258,8 +260,6 @@ test { ); } -const JSONTestSuite_root = ".zigmod/deps/v/git/github.com/nst/JSONTestSuite/commit-984defc2deaa653cb73cd29f4144a720ec9efe7c/test_parsing"; - fn expectPass(path: []const u8) !void { const alloc = std.testing.allocator; var file = try std.fs.cwd().openFile(path, .{}); -- 2.54.0