ede5dcffea
std.Build.addTest creates a CompileStep as before, however, this kind of step no longer actually runs the unit tests. Instead it only compiles it, and one must additionally create a RunStep from the CompileStep in order to actually run the tests. RunStep gains integration with the default test runner, which now supports the standard --listen=- argument in order to communicate over stdin and stdout. It also reports test statistics; how many passed, failed, and leaked, as well as directly associating the relevant stderr with the particular test name that failed. This separation of CompileStep and RunStep means that `CompileStep.Kind.test_exe` is no longer needed, and therefore has been removed in this commit. * build runner: show unit test statistics in build summary * added Step.writeManifest since many steps want to treat it as a warning and emit the same message if it fails. * RunStep: fixed error message that prints the failed command printing the original argv and not the adjusted argv in case an interpreter was used. * RunStep: fixed not passing the command line arguments to the interpreter. * move src/Server.zig to std.zig.Server so that the default test runner can use it. * the simpler test runner function which is used by work-in-progress backends now no longer prints to stderr, which is necessary in order for the build runner to not print the stderr as a warning message.
40 lines
1.0 KiB
Zig
40 lines
1.0 KiB
Zig
const std = @import("std");
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const test_step = b.step("test", "Test it");
|
|
b.default_step = test_step;
|
|
|
|
add(b, test_step, .Debug);
|
|
add(b, test_step, .ReleaseFast);
|
|
add(b, test_step, .ReleaseSmall);
|
|
add(b, test_step, .ReleaseSafe);
|
|
}
|
|
|
|
fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
|
|
const lib_a = b.addStaticLibrary(.{
|
|
.name = "a",
|
|
.optimize = optimize,
|
|
.target = .{},
|
|
});
|
|
lib_a.addCSourceFile("a.c", &[_][]const u8{});
|
|
lib_a.addIncludePath(".");
|
|
|
|
const lib_b = b.addStaticLibrary(.{
|
|
.name = "b",
|
|
.optimize = optimize,
|
|
.target = .{},
|
|
});
|
|
lib_b.addCSourceFile("b.c", &[_][]const u8{});
|
|
lib_b.addIncludePath(".");
|
|
|
|
const test_exe = b.addTest(.{
|
|
.root_source_file = .{ .path = "main.zig" },
|
|
.optimize = optimize,
|
|
});
|
|
test_exe.linkLibrary(lib_a);
|
|
test_exe.linkLibrary(lib_b);
|
|
test_exe.addIncludePath(".");
|
|
|
|
test_step.dependOn(&test_exe.run().step);
|
|
}
|