From 2aa3c1afc7509362f8b61e9698326333e03492e5 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Mon, 9 Mar 2026 12:14:14 +0100 Subject: [PATCH] refactor: clean-up empty test targets --- build.zig | 33 +++++++++++---------------------- src/main.zig | 2 -- src/nightwatch_test.zig | 1 + 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/build.zig b/build.zig index 330c996..de74af4 100644 --- a/build.zig +++ b/build.zig @@ -55,28 +55,20 @@ pub fn build(b: *std.Build) void { if (b.args) |args| run_cmd.addArgs(args); - const mod_tests = b.addTest(.{ - .name = "mod_tests", - .root_module = mod, + const main_mod = b.createModule(.{ + .root_source_file = b.path("src/main.zig"), + .target = target, + .optimize = optimize, + .imports = &.{ + .{ .name = "nightwatch", .module = mod }, + .{ .name = "build_options", .module = options_mod }, + }, }); - const run_mod_tests = b.addRunArtifact(mod_tests); - - const exe_tests = b.addTest(.{ - .name = "exe_tests", - .root_module = b.createModule(.{ - .root_source_file = b.path("src/main.zig"), - .target = target, - .optimize = optimize, - .imports = &.{ - .{ .name = "nightwatch", .module = mod }, - .{ .name = "build_options", .module = options_mod }, - }, - }), - }); - const run_exe_tests = b.addRunArtifact(exe_tests); // Integration test suite: exercises the public API by performing real // filesystem operations and verifying Handler callbacks via TestHandler. + // Also imports nightwatch.zig (via the nightwatch module) and main.zig so + // any tests added there are included automatically. const integration_tests = b.addTest(.{ .name = "integration_tests", .root_module = b.createModule(.{ @@ -85,17 +77,14 @@ pub fn build(b: *std.Build) void { .optimize = optimize, .imports = &.{ .{ .name = "nightwatch", .module = mod }, + .{ .name = "main", .module = main_mod }, }, }), }); const run_integration_tests = b.addRunArtifact(integration_tests); const test_step = b.step("test", "Run tests"); - test_step.dependOn(&run_mod_tests.step); - test_step.dependOn(&run_exe_tests.step); test_step.dependOn(&run_integration_tests.step); - b.installArtifact(mod_tests); - b.installArtifact(exe_tests); b.installArtifact(integration_tests); } diff --git a/src/main.zig b/src/main.zig index dbcd8c2..02fc402 100644 --- a/src/main.zig +++ b/src/main.zig @@ -281,5 +281,3 @@ pub fn main() !void { run_posix(); } } - -test "simple test" {} diff --git a/src/nightwatch_test.zig b/src/nightwatch_test.zig index e378447..70f6933 100644 --- a/src/nightwatch_test.zig +++ b/src/nightwatch_test.zig @@ -1,6 +1,7 @@ const std = @import("std"); const builtin = @import("builtin"); const nw = @import("nightwatch"); +const main = @import("main"); // --------------------------------------------------------------------------- // RecordedEvent