aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-12-25 00:11:53 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-01-01 17:51:21 -0700
commit4c07d41b52d3acdfe81e4712526e60cef78484ab (patch)
tree046d2de2285c754f538c85303b18337dc8155a62 /src/main.zig
parentb36659c972fb7d75b1e34cb668770353de27db7d (diff)
downloadzig-4c07d41b52d3acdfe81e4712526e60cef78484ab.tar.gz
zig-4c07d41b52d3acdfe81e4712526e60cef78484ab.zip
CLI: fix logic for zig test error message
When using the build system to do unit testing, it lowers to --mod arguments which were incorrectly tripping a "zig test requires a source file argument" error.
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/main.zig b/src/main.zig
index 8f235e1233..16bd32b45e 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -2522,10 +2522,6 @@ fn buildOutputType(
fatal("translate-c expects exactly 1 source file (found {d})", .{create_module.c_source_files.items.len});
}
- if (root_src_file == null and arg_mode == .zig_test) {
- fatal("`zig test` expects a zig source file argument", .{});
- }
-
if (show_builtin and root_src_file == null) {
// Without this, there will be no main module created and no zig
// compilation unit, and therefore also no builtin.zig contents
@@ -2616,6 +2612,10 @@ fn buildOutputType(
rc_source_files_owner_index = create_module.rc_source_files.items.len;
}
+ if (!create_module.opts.have_zcu and arg_mode == .zig_test) {
+ fatal("`zig test` expects a zig source file argument", .{});
+ }
+
if (c_source_files_owner_index != create_module.c_source_files.items.len) {
fatal("C source file '{s}' has no parent module", .{
create_module.c_source_files.items[c_source_files_owner_index].src_path,