authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-25 00:11:53-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 17:51:21-07:00
log4c07d41b52d3acdfe81e4712526e60cef78484ab
tree046d2de2285c754f538c85303b18337dc8155a62
parentb36659c972fb7d75b1e34cb668770353de27db7d

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.

1 files changed, 4 insertions(+), 4 deletions(-)

src/main.zig+4-4
...@@ -2522,10 +2522,6 @@ fn buildOutputType(...@@ -2522,10 +2522,6 @@ fn buildOutputType(
2522 fatal("translate-c expects exactly 1 source file (found {d})", .{create_module.c_source_files.items.len});2522 fatal("translate-c expects exactly 1 source file (found {d})", .{create_module.c_source_files.items.len});
2523 }2523 }
25242524
2525 if (root_src_file == null and arg_mode == .zig_test) {
2526 fatal("`zig test` expects a zig source file argument", .{});
2527 }
2528
2529 if (show_builtin and root_src_file == null) {2525 if (show_builtin and root_src_file == null) {
2530 // Without this, there will be no main module created and no zig2526 // Without this, there will be no main module created and no zig
2531 // compilation unit, and therefore also no builtin.zig contents2527 // compilation unit, and therefore also no builtin.zig contents
...@@ -2616,6 +2612,10 @@ fn buildOutputType(...@@ -2616,6 +2612,10 @@ fn buildOutputType(
2616 rc_source_files_owner_index = create_module.rc_source_files.items.len;2612 rc_source_files_owner_index = create_module.rc_source_files.items.len;
2617 }2613 }
26182614
2615 if (!create_module.opts.have_zcu and arg_mode == .zig_test) {
2616 fatal("`zig test` expects a zig source file argument", .{});
2617 }
2618
2619 if (c_source_files_owner_index != create_module.c_source_files.items.len) {2619 if (c_source_files_owner_index != create_module.c_source_files.items.len) {
2620 fatal("C source file '{s}' has no parent module", .{2620 fatal("C source file '{s}' has no parent module", .{
2621 create_module.c_source_files.items[c_source_files_owner_index].src_path,2621 create_module.c_source_files.items[c_source_files_owner_index].src_path,