Skip to content

Commit 72de2f5

Browse files
authored
make test discovery generation output predictable (#3436)
motivation: predictable output will prevent exessive compiles changes: sort keys before iterating on them
1 parent 9dfa7ad commit 72de2f5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Sources/Build/BuildOperationBuildSystemDelegateHandler.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ final class TestDiscoveryCommand: CustomLLBuildCommand {
5454
) throws {
5555
let stream = try LocalFileOutputByteStream(path)
5656

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

5959
stream <<< "import XCTest" <<< "\n"
6060
stream <<< "@testable import " <<< module <<< "\n"
6161

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

81-
for className in testsByClass.keys {
81+
for iterator in testsByClassNames {
82+
let className = iterator.key
8283
stream <<< indent(8) <<< "testCase(\(className).__allTests__\(className)),\n"
8384
}
8485

0 commit comments

Comments
 (0)