Skip to content

Commit 6737db1

Browse files
authored
make failed output after ... matching easier to read
1 parent 657480a commit 6737db1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Tests/JExtractSwiftTests/Asserts/TextAssertions.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,17 @@ func assertOutput(
186186
print("==== ---------------------------------------------------------------")
187187
print("Got output:")
188188
let printFromLineNo = matchingOutputOffset
189-
let printToLineNo = matchingOutputOffset + expectedLines.count
190-
for (n, g) in gotLines.enumerated() where n >= printFromLineNo && n <= printToLineNo {
191-
print("\(n): \(g)".red(if: diffLineNumbers.contains(n)))
189+
for (n, g) in gotLines.enumerated() where n >= printFromLineNo {
190+
let baseLine = "\(n): \(g)"
191+
var line = baseLine
192+
if diffLineNumbers.contains(n) {
193+
line += "\n"
194+
let leadingCount = "\(n): ".count
195+
let message = "\(String(repeating: " ", count: leadingCount))\(String(repeating: "^", count: 8)) EXPECTED MATCH OR SEARCHING FROM HERE "
196+
line += "\(message)\(String(repeating: "^", count: max(0, line.count - message.count)))"
197+
line = line.red
198+
}
199+
print(line)
192200
}
193201
print("==== ---------------------------------------------------------------\n")
194202
}

0 commit comments

Comments
 (0)