Add failure summary to ConsoleOutputRecorder#1420
Add failure summary to ConsoleOutputRecorder#1420tienquocbui wants to merge 1 commit intoswiftlang:mainfrom
Conversation
|
Would it make sense to factor the new code into a dedicated |
Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift
Outdated
Show resolved
Hide resolved
Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift
Outdated
Show resolved
Hide resolved
Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift
Outdated
Show resolved
Hide resolved
Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift
Outdated
Show resolved
Hide resolved
d533995 to
29c448f
Compare
|
@grynspan thanks for the suggestion! I discussed that with Stuart and I've refactored the failure summary logic into a dedicated |
stmontgomery
left a comment
There was a problem hiding this comment.
We met about this offline, and I made a handful of commits of my own which I've just pushed to the PR branch after discussion. Beyond that, there is one problem in how the fully-qualified name is formed for parameterized test functions, and cases within them, in the failure summary section, and @tienquocbui it sounds like you will address that (thanks!)
Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift
Outdated
Show resolved
Hide resolved
|
@stmontgomery I've addressed the parameterized test display issue. Here's what changed: Before: After: |
44e71d4 to
dd6105b
Compare
Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift
Outdated
Show resolved
Hide resolved
Sources/Testing/Events/Recorder/Event.ConsoleOutputRecorder.swift
Outdated
Show resolved
Hide resolved
a3ddbc0 to
a371a1e
Compare
Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift
Outdated
Show resolved
Hide resolved
Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift
Outdated
Show resolved
Hide resolved
Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift
Outdated
Show resolved
Hide resolved
Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift
Outdated
Show resolved
Hide resolved
Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift
Outdated
Show resolved
Hide resolved
|
|
||
| // Store individual issue information for failure summary, but only for | ||
| // issues whose severity is error or greater. | ||
| if issue.severity >= .error { |
There was a problem hiding this comment.
If we only store for error or greater, do we need to store the severity in the data structure?
There was a problem hiding this comment.
I've kept it in the struct for now since Stuart had asked to track it, it could be useful if we later want to include warnings in the summary or format issues differently by severity. Happy to remove it if you both agree it's not needed.
…#9646) This adds a note in the console output after Swift Testing tests finish if one or more XCTests failed, so the user knows to look earlier in the log output for those details. Fixes rdar://168311253 ### Motivation: Swift Package Manager runs XCTests followed by Swift Testing tests, and they are separate subprocess invocations. Each test framework prints its own output to the console and each has a summary at the end, which includes the total number of failures. Since Swift Testing finishes second (assuming both frameworks are enabled), its summary always appears at the bottom and it can potentially be misleading to a user if there were one or more XCTest failures but zero Swift Testing failures because they may incorrectly believe zero tests failed overall. Long-term, we are planning to unify the console output between these testing frameworks so that they present a consolidated summary. However, that remains an ambition that is still being planned and will likely take time to arrive. Another motivator for this is that soon, I anticipate we'll land an enhancement in Swift Testing which will expand its failure summary to span more lines and make it easier for users to locate which Swift Testing tests failed. (For details, see swiftlang/swift-testing#1420.) This will be helpful, but also has the potential to exacerbate the pre-existing confusion situation if (say) a mixture of Swift Testing and XCTests failed. ### Modifications: Modify the `swift test` command such that if Swift Testing is enabled, it will keep track of whether any XCTests failed before running Swift Testing, and if any did, emit a note at the very end (after Swift Testing finishes) indicating that to the user. ### Result: When relevant, the new note described above will be included in the console output.
ace7078 to
5a0a451
Compare
Overview
This PR implements a failure summary section for
ConsoleOutputRecorderto help users quickly locate and review test failures in large test suites.Fixes #1355
Fixes rdar://168698184
Architectural Changes Implemented
HumanReadableOutputRecorderstate with singleLocked<Context>Graphtraversal logicConsoleOutputRecorder(stateless design preserved)TestData.IssueInfostruct with:sourceLocation,description,isKnown,severityTestData.issues(each issue has its own source location)displayName,testCaseArguments) stored once per test inTestDataissueCountdictionary preserved for efficient parallel trackingheader(),formatFailedTest(),fullyQualifiedName(),formatIssue()Graphand formats them independentlyfileprivateinitializer usesHumanReadableOutputRecorder.ContexttypesgenerateFailureSummary()returnsOptional<String>(nil when no failures)expandedDescription()for normal output,expandedDebugDescription()when verboseConsoleOutputRecordercalls this atrunEndedevent with blank line spacing"Custom Display Name")value → 7))Example Output
Regular Test Failure:
Parameterized Test Failure (shows which argument failed):
Test with Custom Display Name:
Complete Test Output
Click to expand full test run output