Skip to content

Commit

Permalink
Update Parser.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
cpisciotta committed Jun 19, 2024
1 parent d9e8acf commit 277da2a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Sources/XcbeautifyLib/Parser.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Foundation

package class Parser {
private let colored: Bool

Expand Down Expand Up @@ -157,6 +159,12 @@ package class Parser {
return nil
}

#if DEBUG
if ProcessInfo.processInfo.environment["XCB_RECORD_UNCAPTURED"] == true {
recordUncapturedOutput(line: line)
}
#endif

// Nothing found?
outputType = OutputType.undefined
return preserveUnbeautifiedLines ? line : nil
Expand All @@ -180,6 +188,23 @@ package class Parser {
return formattedOutput
}

#if DEBUG
private func recordUncapturedOutput(line: String) {
assert(ProcessInfo.processInfo.environment["XCB_RECORD_UNCAPTURED"] == true)

let filePath = FileManager.default.currentDirectoryPath.appending("/uncaptured.txt")

if !FileManager.default.fileExists(atPath: filePath) {
FileManager.default.createFile(atPath: filePath, contents: nil)
}

let handle = FileHandle(forWritingAtPath: filePath)!
handle.seekToEndOfFile()
handle.write(line.appending("\n").data(using: .utf8)!)
handle.closeFile()
}
#endif

package func formattedSummary() -> String? {
guard let summary else { return nil }
return renderer.format(testSummary: summary)
Expand Down

0 comments on commit 277da2a

Please sign in to comment.