authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-06-22 22:24:52+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-06-22 22:24:52+02:00
log51f2442fc4160415796cf6271d1951969ab71c83
tree1ba34f266051183294004a55c7b0cd117d69c6a7
parentba768614aceb486bc387e60a6026f4f48188402e

link-tests: clean up error messages in case of failure


1 files changed, 33 insertions(+), 14 deletions(-)

lib/std/build/CheckObjectStep.zig+33-14
......@@ -4,6 +4,7 @@ const build = std.build;
44const fs = std.fs;
55const macho = std.macho;
66const mem = std.mem;
7const testing = std.testing;
78
89const CheckObjectStep = @This();
910
......@@ -179,13 +180,16 @@ fn make(step: *Step) !void {
179180 switch (act) {
180181 .match => |match_act| {
181182 while (it.next()) |line| {
182 if (try match_act.match(line, &vars)) {
183 std.debug.print("{s} == {s}\n", .{ line, match_act.needle });
184 break;
185 } else {
186 std.debug.print("{s} != {s}\n", .{ line, match_act.needle });
187 }
183 if (try match_act.match(line, &vars)) break;
188184 } else {
185 std.debug.print(
186 \\
187 \\========= Expected to find: ==========================
188 \\{s}
189 \\========= But parsed file does not contain it: =======
190 \\{s}
191 \\
192 , .{ match_act.needle, output });
189193 return error.TestFailed;
190194 }
191195 },
......@@ -193,7 +197,17 @@ fn make(step: *Step) !void {
193197 var values = std.ArrayList(u64).init(gpa);
194198 try values.ensureTotalCapacity(c_eq.var_stack.items.len);
195199 for (c_eq.var_stack.items) |vv| {
196 const val = vars.get(vv) orelse return error.TestFailed;
200 const val = vars.get(vv) orelse {
201 std.debug.print(
202 \\
203 \\========= Variable was not extracted: ===========
204 \\{s}
205 \\========= From parsed file: =====================
206 \\{s}
207 \\
208 , .{ vv, output });
209 return error.TestFailed;
210 };
197211 values.appendAssumeCapacity(val);
198212 }
199213
......@@ -208,17 +222,22 @@ fn make(step: *Step) !void {
208222 }
209223 }
210224
211 const expected = vars.get(c_eq.expected) orelse return error.TestFailed;
212 if (reduced != expected) return error.TestFailed;
225 const expected = vars.get(c_eq.expected) orelse {
226 std.debug.print(
227 \\
228 \\========= Variable was not extracted: ===========
229 \\{s}
230 \\========= From parsed file: =====================
231 \\{s}
232 \\
233 , .{ c_eq.expected, output });
234 return error.TestFailed;
235 };
236 try testing.expectEqual(reduced, expected);
213237 },
214238 }
215239 }
216240 }
217
218 var it = vars.iterator();
219 while (it.next()) |entry| {
220 std.debug.print(" {s} => {x}\n", .{ entry.key_ptr.*, entry.value_ptr.* });
221 }
222241}
223242
224243const Opts = struct {