-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.zig
27 lines (23 loc) · 919 Bytes
/
build.zig
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
const std = @import("std");
pub fn build(b: *std.Build) void {
const test_step = b.step("test", "Run all the samples");
testAllSamples(b, test_step) catch |e| {
std.debug.print("Error: {}", .{e});
};
}
const samples_dir = "source/processed/samples/";
fn testAllSamples(b: *std.Build, test_step: *std.Build.Step) !void {
var samples = try std.fs.cwd().openDir(samples_dir, .{ .iterate = true });
defer samples.close();
var iterator = samples.iterate();
var child = try iterator.next();
var buffer: [1024]u8 = undefined;
while (child) |c| : (child = try iterator.next()) {
const path = try std.fmt.bufPrint(&buffer, "{s}{s}", .{ samples_dir, c.name });
const sample = b.addTest(.{
.root_source_file = .{ .path = path },
});
const run_unit_test = b.addRunArtifact(sample);
test_step.dependOn(&run_unit_test.step);
}
}