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.
This commit is contained in:
Andrew Kelley 2023-12-25 00:11:53 -07:00
parent b36659c972
commit 4c07d41b52

View File

@ -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,