Skip to content

make test discovery generation output predictable #3436

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

Merged
merged 2 commits into from
Apr 24, 2021
Merged
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
11 changes: 6 additions & 5 deletions Sources/Build/BuildOperationBuildSystemDelegateHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ final class TestDiscoveryCommand: CustomLLBuildCommand {
) throws {
let stream = try LocalFileOutputByteStream(path)

let testsByClass = Dictionary(grouping: tests, by: { $0.name })
let testsByClassNames = Dictionary(grouping: tests, by: { $0.name }).sorted(by: { $0.key < $1.key })

stream <<< "import XCTest" <<< "\n"
stream <<< "@testable import " <<< module <<< "\n"

for classTests in testsByClass {
let className = classTests.key
let testMethods = classTests.value.flatMap{ $0.methods }
for iterator in testsByClassNames {
let className = iterator.key
let testMethods = iterator.value.flatMap{ $0.methods }
stream <<< "\n"
stream <<< "fileprivate extension " <<< className <<< " {" <<< "\n"
stream <<< indent(4) <<< "static let __allTests__\(className) = [" <<< "\n"
Expand All @@ -78,7 +78,8 @@ final class TestDiscoveryCommand: CustomLLBuildCommand {
return [\n
"""

for className in testsByClass.keys {
for iterator in testsByClassNames {
let className = iterator.key
stream <<< indent(8) <<< "testCase(\(className).__allTests__\(className)),\n"
}

Expand Down