From 4c07d41b52d3acdfe81e4712526e60cef78484ab Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 25 Dec 2023 00:11:53 -0700 Subject: [PATCH] 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. --- src/main.zig | 8 ++++---- 1 file 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,