authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-10-08 21:57:08-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-10-08 21:57:08-07:00
log22661f3d67251688a1fabf9e5fe65210ce284b9f
tree713dbd96a58ada0527b2668246df813f40a09cf0
parent31d70cb1e11cf480f4a45afdff20e4adf0d6068b

link tests: add a way to check prefix and use it


2 files changed, 13 insertions(+), 1 deletions(-)

lib/std/Build/Step/Compile.zig+12
......@@ -235,6 +235,7 @@ sanitize_coverage_trace_pc_guard: ?bool = null,
235235pub const ExpectedCompileErrors = union(enum) {
236236 contains: []const u8,
237237 exact: []const []const u8,
238 starts_with: []const u8,
238239};
239240
240241pub const Entry = union(enum) {
......@@ -1958,6 +1959,17 @@ fn checkCompileErrors(compile: *Compile) !void {
19581959
19591960 // TODO merge this with the testing.expectEqualStrings logic, and also CheckFile
19601961 switch (expect_errors) {
1962 .starts_with => |expect_starts_with| {
1963 if (std.mem.startsWith(u8, actual_stderr, expect_starts_with)) return;
1964 return compile.step.fail(
1965 \\
1966 \\========= should start with: ============
1967 \\{s}
1968 \\========= but not found: ================
1969 \\{s}
1970 \\=========================================
1971 , .{ expect_starts_with, actual_stderr });
1972 },
19611973 .contains => |expect_line| {
19621974 while (actual_line_it.next()) |actual_line| {
19631975 if (!matchCompileError(actual_line, expect_line)) continue;
test/link/elf.zig+1-1
......@@ -3916,7 +3916,7 @@ fn testUnknownFileTypeError(b: *Build, opts: Options) *Step {
39163916 // "note: while parsing /?/liba.dylib",
39173917 // } });
39183918 expectLinkErrors(exe, test_step, .{
3919 .contains = "error: invalid token in LD script: '\\x00\\x00\\x00\\x0c\\x00\\x00\\x00/usr/lib/dyld\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x0d' (0:1069)",
3919 .starts_with = "error: invalid token in LD script: '\\x00\\x00\\x00\\x0c\\x00\\x00\\x00/usr/lib/dyld\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x0d' (",
39203920 });
39213921
39223922 return test_step;