| ... | @@ -4,6 +4,7 @@ const build = std.build; | ... | @@ -4,6 +4,7 @@ const build = std.build; |
| 4 | const fs = std.fs; | 4 | const fs = std.fs; |
| 5 | const macho = std.macho; | 5 | const macho = std.macho; |
| 6 | const mem = std.mem; | 6 | const mem = std.mem; |
| | 7 | const testing = std.testing; |
| 7 | | 8 | |
| 8 | const CheckObjectStep = @This(); | 9 | const CheckObjectStep = @This(); |
| 9 | | 10 | |
| ... | @@ -179,13 +180,16 @@ fn make(step: *Step) !void { | ... | @@ -179,13 +180,16 @@ fn make(step: *Step) !void { |
| 179 | switch (act) { | 180 | switch (act) { |
| 180 | .match => |match_act| { | 181 | .match => |match_act| { |
| 181 | while (it.next()) |line| { | 182 | while (it.next()) |line| { |
| 182 | if (try match_act.match(line, &vars)) { | 183 | if (try match_act.match(line, &vars)) break; |
| 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 | } | | |
| 188 | } else { | 184 | } 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 }); |
| 189 | return error.TestFailed; | 193 | return error.TestFailed; |
| 190 | } | 194 | } |
| 191 | }, | 195 | }, |
| ... | @@ -193,7 +197,17 @@ fn make(step: *Step) !void { | ... | @@ -193,7 +197,17 @@ fn make(step: *Step) !void { |
| 193 | var values = std.ArrayList(u64).init(gpa); | 197 | var values = std.ArrayList(u64).init(gpa); |
| 194 | try values.ensureTotalCapacity(c_eq.var_stack.items.len); | 198 | try values.ensureTotalCapacity(c_eq.var_stack.items.len); |
| 195 | for (c_eq.var_stack.items) |vv| { | 199 | 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 | }; |
| 197 | values.appendAssumeCapacity(val); | 211 | values.appendAssumeCapacity(val); |
| 198 | } | 212 | } |
| 199 | | 213 | |
| ... | @@ -208,17 +222,22 @@ fn make(step: *Step) !void { | ... | @@ -208,17 +222,22 @@ fn make(step: *Step) !void { |
| 208 | } | 222 | } |
| 209 | } | 223 | } |
| 210 | | 224 | |
| 211 | const expected = vars.get(c_eq.expected) orelse return error.TestFailed; | 225 | const expected = vars.get(c_eq.expected) orelse { |
| 212 | if (reduced != expected) return error.TestFailed; | 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); |
| 213 | }, | 237 | }, |
| 214 | } | 238 | } |
| 215 | } | 239 | } |
| 216 | } | 240 | } |
| 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 | } | | |
| 222 | } | 241 | } |
| 223 | | 242 | |
| 224 | const Opts = struct { | 243 | const Opts = struct { |