Fixed build so test use dependencies

This commit is contained in:
Adrien Bouvais 2024-10-27 15:04:30 +01:00
parent fd21d9bd65
commit 5756e3a530
3 changed files with 27 additions and 23 deletions

View File

@ -4,8 +4,9 @@ pub fn build(b: *std.Build) void {
// Build part
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{ .preferred_optimize_mode = .ReleaseFast });
const exe = b.addExecutable(.{
.name = "zippon",
.name = "ZipponDB",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
@ -14,10 +15,17 @@ pub fn build(b: *std.Build) void {
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
// Import the dtype lib
exe.root_module.addImport("dtype", b.createModule(.{ .root_source_file = b.path("lib/types/out.zig") }));
// Import ZipponData package
exe.root_module.addImport("ZipponData", b.dependency("ZipponData", .{}).module("ZipponData"));
// Run step
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
// All tests
const tests1 = b.addTest(.{
.root_source_file = b.path("src/tokenizers/file.zig"),
.target = target,
@ -52,34 +60,19 @@ pub fn build(b: *std.Build) void {
.name = "Schema tokenizer",
.test_runner = b.path("test_runner.zig"),
});
tests4.root_module.addImport("dtype", b.createModule(.{ .root_source_file = b.path("lib/types/out.zig") }));
const run_tests4 = b.addRunArtifact(tests4);
const tests5 = b.addTest(.{
.root_source_file = b.path("src/types/uuid.zig"),
.target = target,
.optimize = optimize,
.name = "UUID",
.test_runner = b.path("test_runner.zig"),
});
const run_tests5 = b.addRunArtifact(tests5);
const tests6 = b.addTest(.{
.root_source_file = b.path("src/fileEngine.zig"),
.target = target,
.optimize = optimize,
.name = "File Engine",
.test_runner = b.path("test_runner.zig"),
});
const run_tests6 = b.addRunArtifact(tests6);
const tests8 = b.addTest(.{
.root_source_file = b.path("src/ziqlParser.zig"),
.target = target,
.optimize = optimize,
.name = "ZiQL parser",
.test_runner = b.path("test_runner.zig"),
});
const run_tests8 = b.addRunArtifact(tests8);
tests5.root_module.addImport("dtype", b.createModule(.{ .root_source_file = b.path("lib/types/out.zig") }));
tests5.root_module.addImport("ZipponData", b.dependency("ZipponData", .{}).module("ZipponData"));
const run_tests5 = b.addRunArtifact(tests5);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_tests1.step);
@ -87,6 +80,4 @@ pub fn build(b: *std.Build) void {
test_step.dependOn(&run_tests3.step);
test_step.dependOn(&run_tests4.step);
test_step.dependOn(&run_tests5.step);
test_step.dependOn(&run_tests6.step);
test_step.dependOn(&run_tests8.step);
}

13
build.zig.zon Normal file
View File

@ -0,0 +1,13 @@
.{
.name = "ZipponDB",
.version = "0.1.4",
.dependencies = .{
.ZipponData = .{
.url = "git+https://github.com/MrBounty/ZipponData",
.hash = "12200f2c24233d72c195c1daf04d07f3af22418593f7bbe8a75e54fe6817866f4564",
},
},
.paths = .{
"",
},
}

View File

@ -3,7 +3,7 @@ pub const MAX_FILE_SIZE = 5e+6; // 5Mb
pub const CSV_DELIMITER = ';'; // TODO: Delete
// Testing
pub const TEST_DATA_DIR = "test_data/v0.1.2"; // Maybe put that directly in the build
pub const TEST_DATA_DIR = "data"; // Maybe put that directly in the build
// Debug
pub const DONT_SEND = true;