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

Removed Symbol Capture and Relaxed Test/Suite Name Matching for Better Compatibility #318

Merged
merged 2 commits into from
Oct 18, 2024
Merged
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
262 changes: 78 additions & 184 deletions Sources/XcbeautifyLib/CaptureGroups.swift

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions Sources/XcbeautifyLib/Formatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,6 @@ package struct Formatter {
return renderer.formatSwiftTestingIssueArguments(group: group)
case let group as SwiftTestingPassingArgumentCaptureGroup:
return renderer.formatSwiftTestingPassingArgument(group: group)
case let group as SwiftTestingPassingArgumentMultipleCaptureGroup:
return renderer.formatSwiftTestingPassingArgumentMultiple(group: group)
case let group as SwiftTestingAttributeCaptureGroup:
return renderer.formatSwiftTestingAttribute(group: group)
default:
assertionFailure()
return nil
Expand Down
2 changes: 0 additions & 2 deletions Sources/XcbeautifyLib/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ package final class Parser {
SwiftTestingIssueCaptureGroup.self,
SwiftTestingIssueArgumentCaptureGroup.self,
SwiftTestingPassingArgumentCaptureGroup.self,
SwiftTestingPassingArgumentMultipleCaptureGroup.self,
SwiftTestingAttributeCaptureGroup.self,
]

// MARK: - Init
Expand Down
14 changes: 2 additions & 12 deletions Sources/XcbeautifyLib/Renderers/OutputRendering.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ protocol OutputRendering {
func formatSwiftTestingIssue(group: SwiftTestingIssueCaptureGroup) -> String
func formatSwiftTestingIssueArguments(group: SwiftTestingIssueArgumentCaptureGroup) -> String
func formatSwiftTestingPassingArgument(group: SwiftTestingPassingArgumentCaptureGroup) -> String?
func formatSwiftTestingPassingArgumentMultiple(group: SwiftTestingPassingArgumentMultipleCaptureGroup) -> String?
func formatSwiftTestingAttribute(group: SwiftTestingAttributeCaptureGroup) -> String?
}

extension OutputRendering {
Expand Down Expand Up @@ -635,25 +633,17 @@ extension OutputRendering {

func formatSwiftTestingIssue(group: SwiftTestingIssueCaptureGroup) -> String {
let issueDetails = group.issueDetails.map { " at \($0)" } ?? ""
let message = " Test [\(group.testDescription)] recorded an issue\(issueDetails)"
let message = " Test \(group.testDescription) recorded an issue\(issueDetails)"
return colored ? Format.indent + Symbol.warning.f.Yellow + " " + message : Format.indent + Symbol.asciiWarning + " " + message
}

func formatSwiftTestingIssueArguments(group: SwiftTestingIssueArgumentCaptureGroup) -> String {
let argumentsInfo = group.numberOfArguments.map { " with \($0) argument(s)" } ?? ""
let message = " Test [\(group.testDescription)] recorded an issue\(argumentsInfo)"
let message = " Test \(group.testDescription) recorded an issue\(argumentsInfo)"
return colored ? Format.indent + Symbol.warning.f.Yellow + " " + message : Format.indent + Symbol.asciiWarning + " " + message
}

func formatSwiftTestingPassingArgument(group: SwiftTestingPassingArgumentCaptureGroup) -> String? {
nil
}

func formatSwiftTestingPassingArgumentMultiple(group: SwiftTestingPassingArgumentMultipleCaptureGroup) -> String? {
nil
}

func formatSwiftTestingAttribute(group: SwiftTestingAttributeCaptureGroup) -> String? {
nil
}
}
10 changes: 5 additions & 5 deletions Tests/XcbeautifyLibTests/ParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ final class ParserTests: XCTestCase {
func testMatchSwiftTestingSuiteFailed() throws {
let input = #"􀢄 Suite "AnotherTestSuite" failed after 6.4 seconds with 3 issues."#
let captureGroup = try XCTUnwrap(parser.parse(line: input) as? SwiftTestingSuiteFailedCaptureGroup)
XCTAssertEqual(captureGroup.suiteName, "AnotherTestSuite")
XCTAssertEqual(captureGroup.suiteName, "\"AnotherTestSuite\"")
XCTAssertEqual(captureGroup.timeTaken, "6.4")
XCTAssertEqual(captureGroup.numberOfIssues, 3)
}

func testMatchSwiftTestingTestFailed() throws {
let input = #"􀢄 Test "SomeTest" failed after 2.5 seconds with 1 issue."#
let captureGroup = try XCTUnwrap(parser.parse(line: input) as? SwiftTestingTestFailedCaptureGroup)
XCTAssertEqual(captureGroup.testName, "SomeTest")
XCTAssertEqual(captureGroup.testName, "\"SomeTest\"")
XCTAssertEqual(captureGroup.timeTaken, "2.5")
XCTAssertEqual(captureGroup.numberOfIssues, 1)
}
Expand All @@ -153,20 +153,20 @@ final class ParserTests: XCTestCase {
func testMatchSwiftTestingTestSkipped() throws {
let input = #"􀙟 Test "SkippedTest" skipped."#
let captureGroup = try XCTUnwrap(parser.parse(line: input) as? SwiftTestingTestSkippedCaptureGroup)
XCTAssertEqual(captureGroup.testName, "SkippedTest")
XCTAssertEqual(captureGroup.testName, "\"SkippedTest\"")
}

func testMatchSwiftTestingTestSkippedWithReason() throws {
let input = #"􀙟 Test "SkippedTest" skipped: "Not relevant for this platform.""#
let captureGroup = try XCTUnwrap(parser.parse(line: input) as? SwiftTestingTestSkippedReasonCaptureGroup)
XCTAssertEqual(captureGroup.testName, "SkippedTest")
XCTAssertEqual(captureGroup.testName, "\"SkippedTest\"")
XCTAssertEqual(captureGroup.reason, "Not relevant for this platform.")
}

func testMatchSwiftTestingIssue() throws {
let input = #"􀢄 Test "Selected tests by ID" recorded an issue at PlanTests.swift:43:5: Expectation failed"#
let captureGroup = try XCTUnwrap(parser.parse(line: input) as? SwiftTestingIssueCaptureGroup)
XCTAssertEqual(captureGroup.testDescription, "Selected tests by ID")
XCTAssertEqual(captureGroup.testDescription, "\"Selected tests by ID\"")
XCTAssertEqual(captureGroup.issueDetails, "PlanTests.swift:43:5: Expectation failed")
}

Expand Down
1 change: 1 addition & 0 deletions Tests/XcbeautifyLibTests/ParsingTests/ParsingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ final class ParsingTests: XCTestCase {
while !buildLog.isEmpty {
let line = buildLog.removeFirst()
if !line.isEmpty, parser.parse(line: line) == nil {
print(line)
uncapturedOutput += 1
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,28 +625,28 @@ final class GitHubActionsRendererTests: XCTestCase {
func testSwiftTestingSuiteFailed() {
let input = #"􀢄 Suite "MyTestSuite" failed after 8.456 seconds with 2 issues."#
let formatted = logFormatted(input)
let expectedOutput = "::error ::Suite MyTestSuite failed after 8.456 seconds with 2 issue(s)"
let expectedOutput = "::error ::Suite \"MyTestSuite\" failed after 8.456 seconds with 2 issue(s)"
XCTAssertEqual(formatted, expectedOutput)
}

func testSwiftTestingTestFailed() {
let input = #"􀢄 Test "myTest" failed after 1.234 seconds with 1 issue."#
let formatted = logFormatted(input)
let expectedOutput = "::error ::myTest (1.234 seconds) 1 issue(s)"
let expectedOutput = "::error ::\"myTest\" (1.234 seconds) 1 issue(s)"
XCTAssertEqual(formatted, expectedOutput)
}

func testSwiftTestingTestSkipped() {
let input = #"􀙟 Test "myTest" skipped."#
let input = #"􀙟 Test myTest() skipped."#
let formatted = logFormatted(input)
let expectedOutput = "::notice ::Skipped myTest"
let expectedOutput = "::notice ::Skipped myTest()"
XCTAssertEqual(formatted, expectedOutput)
}

func testSwiftTestingTestSkippedReason() {
let input = #"􀙟 Test "myTest" skipped: "Reason for skipping""#
let input = #"􀙟 Test myTest() skipped: "Reason for skipping""#
let formatted = logFormatted(input)
let expectedOutput = "::notice ::Skipped myTest.(Reason for skipping)"
let expectedOutput = "::notice ::Skipped myTest().(Reason for skipping)"
XCTAssertEqual(formatted, expectedOutput)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,25 +646,25 @@ final class TeamCityRendererTests: XCTestCase {
let input = #"􀢄 Suite "MyTestSuite" failed after 8.456 seconds with 2 issues."#
let formatted = noColoredFormatted(input)

XCTAssertEqual(formatted, "##teamcity[message text=\'Suite failed\' errorDetails=\'MyTestSuite failed after 8.456 seconds with 2 issue(s)\' status=\'ERROR\']\nSuite failed")
XCTAssertEqual(formatted, "##teamcity[message text=\'Suite failed\' errorDetails=\'\"MyTestSuite\" failed after 8.456 seconds with 2 issue(s)\' status=\'ERROR\']\nSuite failed")
}

func testSwiftTestingTestFailed() {
let input = #"􀢄 Test "myTest" failed after 1.234 seconds with 1 issue."#
let formatted = noColoredFormatted(input)
XCTAssertEqual(formatted, "##teamcity[message text=\'Test failed\' errorDetails=\'myTest (1.234 seconds) 1 issue(s)\' status=\'ERROR\']\nTest failed")
XCTAssertEqual(formatted, "##teamcity[message text=\'Test failed\' errorDetails=\'\"myTest\" (1.234 seconds) 1 issue(s)\' status=\'ERROR\']\nTest failed")
}

func testSwiftTestingTestSkipped() {
let input = #"􀙟 Test "myTest" skipped."#
let formatted = noColoredFormatted(input)
XCTAssertEqual(formatted, "##teamcity[message text=\'Test skipped|nmyTest\' status=\'WARNING\']\nTest skipped")
XCTAssertEqual(formatted, "##teamcity[message text=\'Test skipped|n\"myTest\"\' status=\'WARNING\']\nTest skipped")
}

func testSwiftTestingTestSkippedReason() {
let input = #"􀙟 Test "myTest" skipped: "Reason for skipping""#
let formatted = noColoredFormatted(input)
XCTAssertEqual(formatted, "##teamcity[message text=\'Test skipped|nmyTest (Reason for skipping)\' status=\'WARNING\']\nTest skipped")
XCTAssertEqual(formatted, "##teamcity[message text=\'Test skipped|n\"myTest\" (Reason for skipping)\' status=\'WARNING\']\nTest skipped")
}

func testSwiftTestingIssue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,8 @@ final class TerminalRendererTests: XCTestCase {
}

func testSwiftTestingSuiteFailed() {
let input = #"􀢄 Suite "MyTestSuite" failed after 8.456 seconds with 2 issues."#
let output = "Suite MyTestSuite failed after 8.456 seconds with 2 issue(s)"
let input = #"􀢄 Suite "My Test Suite" failed after 8.456 seconds with 2 issues."#
let output = "Suite \"My Test Suite\" failed after 8.456 seconds with 2 issue(s)"
XCTAssertEqual(noColoredFormatted(input), output)
}

Expand All @@ -679,31 +679,31 @@ final class TerminalRendererTests: XCTestCase {

func testSwiftTestingTestFailed() {
let input = #"􀢄 Test "myTest" failed after 1.234 seconds with 1 issue."#
let output = " ✖ myTest (1.234 seconds) 1 issue(s)"
let output = " ✖ \"myTest\" (1.234 seconds) 1 issue(s)"
XCTAssertEqual(noColoredFormatted(input), output)
}

func testSwiftTestingTestSkipped() {
let input = #"􀙟 Test "myTest" skipped."#
let output = " ⊘ myTest skipped"
let output = " ⊘ \"myTest\" skipped"
XCTAssertEqual(noColoredFormatted(input), output)
}

func testSwiftTestingTestSkippedReason() {
let input = #"􀙟 Test "myTest" skipped: "Reason for skipping""#
let output = " ⊘ myTest skipped (Reason for skipping)"
let output = " ⊘ \"myTest\" skipped (Reason for skipping)"
XCTAssertEqual(noColoredFormatted(input), output)
}

func testSwiftTestingIssue() {
let input = #"􀢄 Test "myTest" recorded an issue with 2 arguments."#
let output = " [!] Test [myTest] recorded an issue with 2 argument(s)"
let output = " [!] Test \"myTest\" recorded an issue with 2 argument(s)"
XCTAssertEqual(noColoredFormatted(input), output)
}

func testSwiftTestingIssueDetails() {
let input = #"􀢄 Test "myTest" recorded an issue at PlanTests.swift:43:5: Expectation failed"#
let output = #" [!] Test [myTest] recorded an issue at PlanTests.swift:43:5: Expectation failed"#
let output = #" [!] Test "myTest" recorded an issue at PlanTests.swift:43:5: Expectation failed"#
XCTAssertEqual(noColoredFormatted(input), output)
}
}
Loading