Skip to content

Commit

Permalink
Added a make file in order to distribute using brew
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex da Franca committed Dec 23, 2021
1 parent d5b6184 commit 9977b9f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 26 deletions.
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
prefix ?= /usr/local
bindir = $(prefix)/bin

build:
swift build -c release --disable-sandbox

install: build
install -d "$(bindir)"
install ".build/release/xcresultparser" "$(bindir)"

uninstall:
rm -rf "$(bindir)/xcresultparser"

clean:
rm -rf .build

.PHONY: build install uninstall clean
21 changes: 7 additions & 14 deletions xcresultparser/JunitXML.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,25 +141,20 @@ struct JunitXML {
testDirectory: String = ""
) -> [XMLElement] {
guard group.identifierString.hasSuffix(".xctest") || group.subtestGroups.isEmpty else {
var combined = [XMLElement]()
for subGroup in group.subtestGroups {
combined = combined + createTestSuite(subGroup, failureSummaries: failureSummaries, testDirectory: subGroup.identifierString)
return group.subtestGroups.reduce([XMLElement]()) { rslt, subGroup in
return rslt + createTestSuite(subGroup, failureSummaries: failureSummaries, testDirectory: subGroup.identifierString)
}
return combined
}
if group.subtestGroups.isEmpty {
return [
createTestSuiteFinally(group, tests: group.subtests, failureSummaries: failureSummaries, testDirectory: testDirectory)
]
} else {
var combined = [XMLElement]()
for subGroup in group.subtestGroups {
combined = combined + createTestCases(for: subGroup.nameString, tests: subGroup.subtests, failureSummaries: failureSummaries)
let combined = group.subtestGroups.reduce([XMLElement]()) { rslt, subGroup in
return rslt + createTestCases(for: subGroup.nameString, tests: subGroup.subtests, failureSummaries: failureSummaries)
}
let node = testReportFormat == .sonar ? group.sonarFileXML: group.testSuiteXML
for element in combined {
node.addChild(element)
}
combined.forEach { node.addChild($0) }
return [node]
}
}
Expand Down Expand Up @@ -193,10 +188,8 @@ struct JunitXML {
for thisTest in tests {
let testcase = thisTest.xmlNode(classname: name)
if thisTest.isFailed {
let summary = failureSummaries.first { summary in
return summary.testCaseName == thisTest.identifier.replacingOccurrences(of: "/", with: ".")
}
if let summary = summary {
let identifier = thisTest.identifier.replacingOccurrences(of: "/", with: ".")
if let summary = failureSummaries.first(where: { $0.testCaseName == identifier }) {
testcase.addChild(summary.failureXML(projectRoot: projectRoot))
} else {
testcase.addChild(failureWithoutSummary)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation

struct CLIResultFormatter: XCResultFormatting {
private let style = CLIFormat()
private let cliStyle = CLIFormat()
private let indentWidth = " "

func documentPrefix(title: String) -> String {
Expand All @@ -33,29 +33,29 @@ struct CLIResultFormatter: XCResultFormatting {
return "-----------------\n"
}
func resultSummaryLine(_ item: String, failed: Bool) -> String {
return color(for: failed) + indentWidth + item + style.reset
return color(for: failed) + indentWidth + item + cliStyle.reset
}
func resultSummaryLineWarning(_ item: String, hasWarnings: Bool) -> String {
return warningColor(for: hasWarnings) + indentWidth + item + style.reset
return warningColor(for: hasWarnings) + indentWidth + item + cliStyle.reset
}
func testConfiguration(_ item: String) -> String {
return style.bold + item + style.reset
return cliStyle.bold + item + cliStyle.reset
}
func testTarget(_ item: String, failed: Bool) -> String {
return color(for: failed) + indentWidth + item + style.reset
return color(for: failed) + indentWidth + item + cliStyle.reset
}
func testClass(_ item: String, failed: Bool) -> String {
return color(for: failed) + String(repeating: indentWidth, count: 2) + item + style.reset
return color(for: failed) + String(repeating: indentWidth, count: 2) + item + cliStyle.reset
}
func singleTestItem(_ item: String, failed: Bool) -> String {
return singleItemColor(for: failed) + String(repeating: indentWidth, count: 3) + item + style.reset
return singleItemColor(for: failed) + String(repeating: indentWidth, count: 3) + item + cliStyle.reset
}
func failedTestItem(_ item: String, message: String) -> String {
return singleItemColor(for: true) + String(repeating: indentWidth, count: 3) + item + "\n" +
String(repeating: indentWidth, count: 4) + message + style.reset
String(repeating: indentWidth, count: 4) + message + cliStyle.reset
}
func codeCoverageTargetSummary(_ item: String) -> String {
return indentWidth + style.bold + item + style.reset
return indentWidth + cliStyle.bold + item + cliStyle.reset
}
func codeCoverageFileSummary(_ item: String) -> String {
return String(repeating: indentWidth, count: 2) + item
Expand All @@ -68,14 +68,14 @@ struct CLIResultFormatter: XCResultFormatting {

// Red <-> Black
private func color(for failure: Bool) -> String {
return failure ? style.red: ""
return failure ? cliStyle.red: ""
}
// Yellow <-> Black
private func warningColor(for failure: Bool) -> String {
return failure ? style.yellow: ""
return failure ? cliStyle.yellow: ""
}
// Red <-> Green
private func singleItemColor(for failure: Bool) -> String {
return failure ? style.red: style.green
return failure ? cliStyle.red: cliStyle.green
}
}

0 comments on commit 9977b9f

Please sign in to comment.