Skip to content

Commit 586856f

Browse files
committed
lib/init-exe, lib/init-lib: ensure tests runs again
After commit ede5dcf (make the build runner and test runner talk to each other), the std.Build.addTest function no longer runs tests, but the build.zig files in init-exe and init-lib where not updated. Rename main_tests to lib_tests in init-lib, for consistency with the exe_tests variable in init-exe. Add a RunStep to exe_tests and lib_tests. Remove an empty line in the addCliTests function in tests/tests.zig. Closes #15009
1 parent 4a5628e commit 586856f

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

lib/init-exe/build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@ pub fn build(b: *std.Build) void {
6363
// the `zig build --help` menu, providing a way for the user to request
6464
// running the unit tests.
6565
const test_step = b.step("test", "Run unit tests");
66-
test_step.dependOn(&exe_tests.step);
66+
test_step.dependOn(&exe_tests.run().step);
6767
}

lib/init-lib/build.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn build(b: *std.Build) void {
3030
lib.install();
3131

3232
// Creates a step for unit testing.
33-
const main_tests = b.addTest(.{
33+
const lib_tests = b.addTest(.{
3434
.root_source_file = .{ .path = "src/main.zig" },
3535
.target = target,
3636
.optimize = optimize,
@@ -40,5 +40,5 @@ pub fn build(b: *std.Build) void {
4040
// and can be selected like this: `zig build test`
4141
// This will evaluate the `test` step rather than the default, which is "install".
4242
const test_step = b.step("test", "Run library tests");
43-
test_step.dependOn(&main_tests.step);
43+
test_step.dependOn(&lib_tests.run().step);
4444
}

test/tests.zig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,6 @@ pub fn addCliTests(b: *std.Build) *Step {
663663
const s = std.fs.path.sep_str;
664664

665665
{
666-
667666
// Test `zig init-lib`.
668667
const tmp_path = b.makeTempPath();
669668
const init_lib = b.addSystemCommand(&.{ b.zig_exe, "init-lib" });

0 commit comments

Comments
 (0)