fix 'zig build test' crashing with no tests

fixes #15553
This commit is contained in:
0x5a4 2023-05-06 21:28:08 +02:00 committed by Andrew Kelley
parent 5260657230
commit 11fabc4cbe

View File

@ -822,7 +822,7 @@ fn runCommand(
.zig_test => {
const prefix: []const u8 = p: {
if (result.stdio.test_metadata) |tm| {
if (tm.next_index <= tm.names.len) {
if (tm.next_index > 0 and tm.next_index <= tm.names.len) {
const name = tm.testName(tm.next_index - 1);
break :p b.fmt("while executing test '{s}', ", .{name});
}