authorgravatar for topolarity@tapscott.meCody Tapscott <topolarity@tapscott.me> 2022-04-12 10:54:27-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-04-13 01:09:21-04:00
logaaac8eae683172546ce9e018d8c419f62793f8d4
treeb3e2a0a759d7666b143177bd87ca0b7dd6c20b77
parent8ada446b1f69842793321978b4ae796a550d99a9

Use 0-indexing for incremental compile error tests


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

src/test.zig+9-9
...@@ -656,10 +656,10 @@ pub const TestContext = struct {...@@ -656,10 +656,10 @@ pub const TestContext = struct {
656656
657 const Strategy = enum {657 const Strategy = enum {
658 /// Execute tests as independent compilations, unless they are explicitly658 /// Execute tests as independent compilations, unless they are explicitly
659 /// incremental ("foo.1.zig", "foo.2.zig", etc.)659 /// incremental ("foo.0.zig", "foo.1.zig", etc.)
660 independent,660 independent,
661 /// Execute all tests as incremental updates to a single compilation. Explicitly661 /// Execute all tests as incremental updates to a single compilation. Explicitly
662 /// incremental tests ("foo.1.zig", "foo.2.zig", etc.) still execute in order662 /// incremental tests ("foo.0.zig", "foo.1.zig", etc.) still execute in order
663 incremental,663 incremental,
664 };664 };
665665
...@@ -716,8 +716,8 @@ pub const TestContext = struct {...@@ -716,8 +716,8 @@ pub const TestContext = struct {
716 };716 };
717 }717 }
718718
719 /// Sort test filenames in-place, so that incremental test cases ("foo.1.zig",719 /// Sort test filenames in-place, so that incremental test cases ("foo.0.zig",
720 /// "foo.2.zig", etc.) are contiguous and appear in numerical order.720 /// "foo.1.zig", etc.) are contiguous and appear in numerical order.
721 fn sortTestFilenames(721 fn sortTestFilenames(
722 filenames: [][]const u8,722 filenames: [][]const u8,
723 ) void {723 ) void {
...@@ -804,8 +804,8 @@ pub const TestContext = struct {...@@ -804,8 +804,8 @@ pub const TestContext = struct {
804 } else {804 } else {
805805
806 // This is not the same test sequence, so the new file must be the first file806 // This is not the same test sequence, so the new file must be the first file
807 // in a new sequence ("*.1.zig") or an independent test file ("*.zig")807 // in a new sequence ("*.0.zig") or an independent test file ("*.zig")
808 if (new_parts.test_index != null and new_parts.test_index.? != 1) return error.InvalidIncrementalTestIndex;808 if (new_parts.test_index != null and new_parts.test_index.? != 0) return error.InvalidIncrementalTestIndex;
809809
810 if (strategy == .independent)810 if (strategy == .independent)
811 opt_case = null; // Generate a new independent test case for this update811 opt_case = null; // Generate a new independent test case for this update
...@@ -1239,7 +1239,7 @@ pub const TestContext = struct {...@@ -1239,7 +1239,7 @@ pub const TestContext = struct {
1239 if (all_errors.list.len != 0) {1239 if (all_errors.list.len != 0) {
1240 print(1240 print(
1241 "\nCase '{s}': unexpected errors at update_index={d}:\n{s}\n",1241 "\nCase '{s}': unexpected errors at update_index={d}:\n{s}\n",
1242 .{ case.name, update_index + 1, hr },1242 .{ case.name, update_index, hr },
1243 );1243 );
1244 for (all_errors.list) |err_msg| {1244 for (all_errors.list) |err_msg| {
1245 switch (err_msg) {1245 switch (err_msg) {
...@@ -1401,7 +1401,7 @@ pub const TestContext = struct {...@@ -1401,7 +1401,7 @@ pub const TestContext = struct {
1401 }1401 }
14021402
1403 if (any_failed) {1403 if (any_failed) {
1404 print("\nupdate_index={d}\n", .{update_index + 1});1404 print("\nupdate_index={d}\n", .{update_index});
1405 return error.WrongCompileErrors;1405 return error.WrongCompileErrors;
1406 }1406 }
1407 },1407 },
...@@ -1508,7 +1508,7 @@ pub const TestContext = struct {...@@ -1508,7 +1508,7 @@ pub const TestContext = struct {
1508 .cwd = tmp_dir_path,1508 .cwd = tmp_dir_path,
1509 }) catch |err| {1509 }) catch |err| {
1510 print("\nupdate_index={d} The following command failed with {s}:\n", .{1510 print("\nupdate_index={d} The following command failed with {s}:\n", .{
1511 update_index + 1, @errorName(err),1511 update_index, @errorName(err),
1512 });1512 });
1513 dumpArgs(argv.items);1513 dumpArgs(argv.items);
1514 return error.ChildProcessExecution;1514 return error.ChildProcessExecution;