Skip to content

Commit

Permalink
Refactor tests into build.zig
Browse files Browse the repository at this point in the history
I like seeing the summary of each module, instead of all tests
grouped together.
  • Loading branch information
arrufat committed Apr 15, 2024
1 parent 20e2aa3 commit 4b99504
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
29 changes: 22 additions & 7 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,29 @@ pub fn build(b: *std.Build) void {

_ = buildModule(b, "zignal", target, optimize);

const unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/tests.zig" },
.target = target,
.optimize = optimize,
const test_step = b.step("test", "Run library tests");
for ([_][]const u8{
"color",
"matrix",
"svd",
}) |module| {
const module_test = b.addTest(.{
.name = module,
.root_source_file = .{ .path = b.fmt("src/{s}.zig", .{module}) },
.target = target,
.optimize = optimize,
});
const module_test_run = b.addRunArtifact(module_test);
test_step.dependOn(&module_test_run.step);
}

const fmt_step = b.step("fmt", "Run zig fmt");
const fmt = b.addFmt(.{
.paths = &.{ "src", "build.zig" },
.check = true,
});
const run_unit_tests = b.addRunArtifact(unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_unit_tests.step);
fmt_step.dependOn(&fmt.step);
b.default_step.dependOn(fmt_step);
}

fn buildModule(
Expand Down
11 changes: 0 additions & 11 deletions src/tests.zig

This file was deleted.

2 changes: 2 additions & 0 deletions src/zignal.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ pub const Point2d = @import("point.zig").Point2d;
pub const Point3d = @import("point.zig").Point3d;

pub const Matrix = @import("matrix.zig").Matrix;

pub const svd = @import("svd.zig").svd;

0 comments on commit 4b99504

Please sign in to comment.