diff options
| author | Cody Tapscott <topolarity@tapscott.me> | 2022-03-28 14:16:48 -0700 |
|---|---|---|
| committer | Cody Tapscott <topolarity@tapscott.me> | 2022-04-11 10:05:00 -0700 |
| commit | 7851377e95f1a0e9467a7e69dd506b47a4f45b87 (patch) | |
| tree | 5a37939443fc40c09f8eb46e7a544f2fdd79ab79 /src | |
| parent | d2681d2537b630359657e117ed77cf12a15bb7df (diff) | |
| download | zig-7851377e95f1a0e9467a7e69dd506b47a4f45b87.tar.gz zig-7851377e95f1a0e9467a7e69dd506b47a4f45b87.zip | |
Improve whitespace-handling in (compile-error) test manifest parsing
Diffstat (limited to 'src')
| -rw-r--r-- | src/test.zig | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/test.zig b/src/test.zig index a0d0d202d1..e664b0b893 100644 --- a/src/test.zig +++ b/src/test.zig @@ -720,14 +720,17 @@ pub const TestContext = struct { // Move to beginning of line while (cursor > 0 and src[cursor - 1] != '\n') cursor -= 1; - // Check if line is non-empty and does not start with "//" - if (cursor + 1 < src.len and src[cursor + 1] != '\n' and src[cursor + 1] != '\r') { - if (std.mem.startsWith(u8, src[cursor..], "//")) { - manifest_start = cursor; - } else { - break; - } - } else manifest_end = cursor; + if (std.mem.startsWith(u8, src[cursor..], "//")) { + manifest_start = cursor; // Contiguous comment line, include in manifest + } else { + if (manifest_start != null) break; // Encountered non-comment line, end of manifest + + // We ignore all-whitespace lines following the comment block, but anything else + // means that there is no manifest present. + if (std.mem.trim(u8, src[cursor..manifest_end], " \r\n\t").len == 0) { + manifest_end = cursor; + } else break; // If it's not whitespace, there is no manifest + } // Move to previous line if (cursor != 0) cursor -= 1 else break; |
