Fix dependencies for unit tests

This commit is contained in:
jaina heartles 2023-01-08 15:35:13 -08:00
parent da558ac40e
commit 2571043580

View file

@ -99,10 +99,16 @@ pub fn build(b: *std.build.Builder) !void {
exe.addSystemIncludePath("/usr/include/"); exe.addSystemIncludePath("/usr/include/");
exe.addSystemIncludePath("/usr/include/postgresql"); // HACK 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_cmd = b.step("unit:http", "Run tests for http package");
const unittest_http = b.addTest("src/http/lib.zig"); const unittest_http = b.addTest("src/http/lib.zig");
unittest_http_cmd.dependOn(&unittest_http.step); 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_cmd = b.step("unit:util", "Run tests for util package");
const unittest_util = b.addTest("src/util/lib.zig"); 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_cmd = b.step("unit:sql", "Run tests for sql package");
const unittest_sql = b.addTest("src/sql/lib.zig"); const unittest_sql = b.addTest("src/sql/lib.zig");
unittest_sql_cmd.dependOn(&unittest_sql.step); 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_cmd = b.step("unit:template", "Run tests for template package");
const unittest_template = b.addTest("src/template/lib.zig"); 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_cmd = b.step("unit:api", "Run tests for api package");
const unittest_api = b.addTest("src/api/lib.zig"); const unittest_api = b.addTest("src/api/lib.zig");
unittest_api_cmd.dependOn(&unittest_api.step); unittest_api_cmd.dependOn(&unittest_api.step);
unittest_api.addPackage(pkgs.util); unittest_api.addPackage(unittest_pkgs.util);
unittest_api.addPackage(pkgs.sql); unittest_api.addPackage(unittest_pkgs.sql);
//unittest_api.linkLibC();
//const util_tests = b.addTest("src/util/lib.zig"); //const util_tests = b.addTest("src/util/lib.zig");
//const sql_tests = b.addTest("src/sql/lib.zig"); //const sql_tests = b.addTest("src/sql/lib.zig");