-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef6e251
commit 7a67e86
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import ArgumentParser | ||
import Darwin | ||
import Foundation | ||
import XcbeautifyLib | ||
|
||
@main | ||
struct ParsingCheck: ParsableCommand { | ||
|
||
@Option | ||
var filePath: String | ||
|
||
@Option | ||
var uncapturedOutput: Int | ||
|
||
enum ParsingCheckError: Error { | ||
case dataReadError | ||
case noData | ||
case regression(Int) | ||
} | ||
|
||
func run() throws { | ||
guard let data = FileManager.default.contents(atPath: filePath) else { | ||
throw ParsingCheckError.noData | ||
} | ||
|
||
guard !data.isEmpty else { | ||
throw ParsingCheckError.noData | ||
} | ||
|
||
var buildLog: [String] = String(decoding: data, as: UTF8.self) | ||
.components(separatedBy: .newlines) | ||
|
||
let parser = Parser() | ||
|
||
var uncapturedOutput = 0 | ||
|
||
while !buildLog.isEmpty { | ||
let line = buildLog.removeFirst() | ||
if !line.isEmpty, parser.parse(line: line) == nil { | ||
uncapturedOutput += 1 | ||
} | ||
} | ||
|
||
guard self.uncapturedOutput == uncapturedOutput else { | ||
throw ParsingCheckError.regression(uncapturedOutput) | ||
} | ||
} | ||
} |