| ... | @@ -490,9 +490,7 @@ fn getTestFileNameParts(name: []const u8) struct { | ... | @@ -490,9 +490,7 @@ fn getTestFileNameParts(name: []const u8) struct { |
| 490 | | 490 | |
| 491 | /// Sort test filenames in-place, so that incremental test cases ("foo.0.zig", | 491 | /// Sort test filenames in-place, so that incremental test cases ("foo.0.zig", |
| 492 | /// "foo.1.zig", etc.) are contiguous and appear in numerical order. | 492 | /// "foo.1.zig", etc.) are contiguous and appear in numerical order. |
| 493 | fn sortTestFilenames( | 493 | fn sortTestFilenames(filenames: [][]const u8) void { |
| 494 | filenames: [][]const u8, | | |
| 495 | ) void { | | |
| 496 | const Context = struct { | 494 | const Context = struct { |
| 497 | pub fn lessThan(_: @This(), a: []const u8, b: []const u8) bool { | 495 | pub fn lessThan(_: @This(), a: []const u8, b: []const u8) bool { |
| 498 | const a_parts = getTestFileNameParts(a); | 496 | const a_parts = getTestFileNameParts(a); |
| ... | @@ -505,14 +503,20 @@ fn sortTestFilenames( | ... | @@ -505,14 +503,20 @@ fn sortTestFilenames( |
| 505 | .eq => switch (std.mem.order(u8, a_parts.file_ext, b_parts.file_ext)) { | 503 | .eq => switch (std.mem.order(u8, a_parts.file_ext, b_parts.file_ext)) { |
| 506 | .lt => true, | 504 | .lt => true, |
| 507 | .gt => false, | 505 | .gt => false, |
| 508 | .eq => b: { // a and b differ only in their ".X" part | 506 | .eq => { |
| | 507 | // a and b differ only in their ".X" part |
| 509 | | 508 | |
| 510 | // Sort "<base_name>.<file_ext>" before any "<base_name>.X.<file_ext>" | 509 | // Sort "<base_name>.<file_ext>" before any "<base_name>.X.<file_ext>" |
| 511 | if (a_parts.test_index == null) break :b true; | 510 | if (a_parts.test_index) |a_index| { |
| 512 | if (b_parts.test_index == null) break :b false; | 511 | if (b_parts.test_index) |b_index| { |
| 513 | | 512 | // Make sure that incremental tests appear in linear order |
| 514 | // Make sure that incremental tests appear in linear order | 513 | return a_index < b_index; |
| 515 | return a_parts.test_index.? < b_parts.test_index.?; | 514 | } else { |
| | 515 | return false; |
| | 516 | } |
| | 517 | } else { |
| | 518 | return b_parts.test_index != null; |
| | 519 | } |
| 516 | }, | 520 | }, |
| 517 | }, | 521 | }, |
| 518 | }; | 522 | }; |