Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add End-to-End Tests #287

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,30 @@ jobs:
with:
files: info.lcov
token: ${{ secrets.CODECOV_TOKEN }}

end-to-end:
name: End-to-End Test (${{ matrix.xcode_version }})
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
include:
- xcode_version: "15.3"
uncaptured_output: 255
- xcode_version: "15.4"
uncaptured_output: 255
- xcode_version: "16.0"
uncaptured_output: 255
- xcode_version: "16.1"
uncaptured_output: 255
env:
BUILD_LOG: ${{ matrix.xcode_version }}.log
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: "cpisciotta/GitHub-Issues-Browser"
path: "Demo"
- run: swift build
- run: set -euo pipefail && xcodebuild clean test -project 'Demo/GHIssues.xcodeproj' -scheme GHIssues -destination 'platform=iOS Simulator,name=iPhone 15 Pro' -derivedDataPath DerivedData CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGN_ENTITLEMENTS="" CODE_SIGNING_ALLOWED=NO ONLY_ACTIVE_ARCH=NO > ${{ env.BUILD_LOG }}
- run: ./.build/debug/ParsingCheck --file-path ${{ env.BUILD_LOG }} --uncaptured-output ${{ matrix.uncaptured_output }}
7 changes: 7 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ let package = Package(
"XMLCoder",
]
),
.executableTarget(
name: "ParsingCheck",
dependencies: [
"XcbeautifyLib",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
]
),
.testTarget(
name: "XcbeautifyLibTests",
dependencies: ["XcbeautifyLib"],
Expand Down
48 changes: 48 additions & 0 deletions Sources/ParsingCheck/ParsingCheck.swift
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 {

Check warning on line 7 in Sources/ParsingCheck/ParsingCheck.swift

View workflow job for this annotation

GitHub Actions / SwiftFormat

Remove leading blank line at the start of a scope. (blankLinesAtStartOfScope)

@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)
}
}
}
Loading