From 25710435803b7b0edd0f48917790a89144aaace2 Mon Sep 17 00:00:00 2001 From: jaina heartles Date: Sun, 8 Jan 2023 15:35:13 -0800 Subject: [PATCH] Fix dependencies for unit tests --- build.zig | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/build.zig b/build.zig index 26d44c5..df7c55d 100644 --- a/build.zig +++ b/build.zig @@ -99,10 +99,16 @@ pub fn build(b: *std.build.Builder) !void { exe.addSystemIncludePath("/usr/include/"); exe.addSystemIncludePath("/usr/include/postgresql"); // HACK + const unittest_options = b.addOptions(); + unittest_options.addOption(bool, "enable_sqlite", false); + unittest_options.addOption(bool, "enable_postgres", false); + + const unittest_pkgs = makePkgs(b, unittest_options.getPackage("build_options")); + const unittest_http_cmd = b.step("unit:http", "Run tests for http package"); const unittest_http = b.addTest("src/http/lib.zig"); unittest_http_cmd.dependOn(&unittest_http.step); - unittest_http.addPackage(pkgs.util); + unittest_http.addPackage(unittest_pkgs.util); const unittest_util_cmd = b.step("unit:util", "Run tests for util package"); const unittest_util = b.addTest("src/util/lib.zig"); @@ -111,7 +117,8 @@ pub fn build(b: *std.build.Builder) !void { const unittest_sql_cmd = b.step("unit:sql", "Run tests for sql package"); const unittest_sql = b.addTest("src/sql/lib.zig"); unittest_sql_cmd.dependOn(&unittest_sql.step); - unittest_sql.addPackage(pkgs.util); + unittest_sql.addPackage(unittest_pkgs.util); + //unittest_sql.linkLibC(); const unittest_template_cmd = b.step("unit:template", "Run tests for template package"); const unittest_template = b.addTest("src/template/lib.zig"); @@ -120,8 +127,9 @@ pub fn build(b: *std.build.Builder) !void { const unittest_api_cmd = b.step("unit:api", "Run tests for api package"); const unittest_api = b.addTest("src/api/lib.zig"); unittest_api_cmd.dependOn(&unittest_api.step); - unittest_api.addPackage(pkgs.util); - unittest_api.addPackage(pkgs.sql); + unittest_api.addPackage(unittest_pkgs.util); + unittest_api.addPackage(unittest_pkgs.sql); + //unittest_api.linkLibC(); //const util_tests = b.addTest("src/util/lib.zig"); //const sql_tests = b.addTest("src/sql/lib.zig");