-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.zig
More file actions
48 lines (42 loc) · 1.75 KB
/
build.zig
File metadata and controls
48 lines (42 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const module_a = b.addModule("module_a", .{
.root_source_file = b.path("example/module_a/package_a.zig"),
.target = target,
});
const module_b = b.addModule("module_b", .{
.root_source_file = b.path("example/module_b/package_b.zig"),
.target = target,
});
// Prepare our zrunner
const test_runner = std.Build.Step.Compile.TestRunner{
.path = b.path("zrunner.zig"),
.mode = .simple,
};
const tests_module_a = b.addTest(.{
.name = "module_a", // this name is used in the report
.root_module = module_a,
.test_runner = test_runner, // use our runner
});
const run_module_a_tests = b.addRunArtifact(tests_module_a);
// this forces using colors in some cases when they would be omitted otherwise
run_module_a_tests.setEnvironmentVariable("CLICOLOR_FORCE", "true");
const tests_module_b = b.addTest(.{
.name = "module_b", // this name is used in the report
.root_module = module_b,
.test_runner = test_runner, // use our runner
});
const run_module_b_tests = b.addRunArtifact(tests_module_b);
// this forces using colors in some cases when they would be omitted otherwise
run_module_b_tests.setEnvironmentVariable("CLICOLOR_FORCE", "true");
// This is very important configuration!
// Without it the test runner is not able to handle arguments.
if (b.args) |args| {
run_module_a_tests.addArgs(args);
run_module_b_tests.addArgs(args);
}
const test_step = b.step("test", "Run tests");
test_step.dependOn(&run_module_a_tests.step);
test_step.dependOn(&run_module_b_tests.step);
}