@@ -68,6 +68,28 @@ extension SwiftlyCoreContext {
6868 }
6969}
7070
71+ extension ToolchainVersion {
72+ public static let oldStable = ToolchainVersion ( major: 5 , minor: 6 , patch: 0 )
73+ public static let oldStableNewPatch = ToolchainVersion ( major: 5 , minor: 6 , patch: 3 )
74+ public static let newStable = ToolchainVersion ( major: 5 , minor: 7 , patch: 0 )
75+ public static let oldMainSnapshot = ToolchainVersion ( snapshotBranch: . main, date: " 2025-03-10 " )
76+ public static let newMainSnapshot = ToolchainVersion ( snapshotBranch: . main, date: " 2025-03-14 " )
77+ public static let oldReleaseSnapshot = ToolchainVersion ( snapshotBranch: . release( major: 6 , minor: 0 ) , date: " 2025-02-09 " )
78+ public static let newReleaseSnapshot = ToolchainVersion ( snapshotBranch: . release( major: 6 , minor: 0 ) , date: " 2025-02-11 " )
79+ }
80+
81+ extension Set where Element == ToolchainVersion {
82+ static func allToolchains( ) -> Set < ToolchainVersion > { [
83+ . oldStable,
84+ . oldStableNewPatch,
85+ . newStable,
86+ . oldMainSnapshot,
87+ . newMainSnapshot,
88+ . oldReleaseSnapshot,
89+ . newReleaseSnapshot,
90+ ] }
91+ }
92+
7193// Convenience test scoping traits
7294
7395struct TestHomeTrait : TestTrait , TestScoping {
@@ -89,7 +111,7 @@ extension Trait where Self == TestHomeTrait {
89111
90112struct MockHomeToolchainsTrait : TestTrait , TestScoping {
91113 var name : String = " testHome "
92- var toolchains : Set < ToolchainVersion > = SwiftlyTests . allToolchains
114+ var toolchains : Set < ToolchainVersion > = . allToolchains( )
93115
94116 init ( _ name: String , toolchains: Set < ToolchainVersion > ) {
95117 self . name = name
@@ -105,7 +127,7 @@ struct MockHomeToolchainsTrait: TestTrait, TestScoping {
105127
106128extension Trait where Self == MockHomeToolchainsTrait {
107129 /// Run the test with this trait to get a mocked home directory with a predefined collection of toolchains already installed.
108- static func mockHomeToolchains( _ homeName: String = " testHome " , toolchains: Set < ToolchainVersion > = SwiftlyTests . allToolchains) -> Self { Self ( homeName, toolchains: toolchains) }
130+ static func mockHomeToolchains( _ homeName: String = " testHome " , toolchains: Set < ToolchainVersion > = . allToolchains( ) ) -> Self { Self ( homeName, toolchains: toolchains) }
109131}
110132
111133struct TestHomeMockedToolchainTrait : TestTrait , TestScoping {
@@ -136,25 +158,6 @@ public enum SwiftlyTests {
136158 inputProvider: InputProviderFail ( )
137159 )
138160
139- // Below are some constants that can be used to write test cases.
140- public static let oldStable = ToolchainVersion ( major: 5 , minor: 6 , patch: 0 )
141- public static let oldStableNewPatch = ToolchainVersion ( major: 5 , minor: 6 , patch: 3 )
142- public static let newStable = ToolchainVersion ( major: 5 , minor: 7 , patch: 0 )
143- public static let oldMainSnapshot = ToolchainVersion ( snapshotBranch: . main, date: " 2025-03-10 " )
144- public static let newMainSnapshot = ToolchainVersion ( snapshotBranch: . main, date: " 2025-03-14 " )
145- public static let oldReleaseSnapshot = ToolchainVersion ( snapshotBranch: . release( major: 6 , minor: 0 ) , date: " 2025-02-09 " )
146- public static let newReleaseSnapshot = ToolchainVersion ( snapshotBranch: . release( major: 6 , minor: 0 ) , date: " 2025-02-11 " )
147-
148- static let allToolchains : Set < ToolchainVersion > = [
149- oldStable,
150- oldStableNewPatch,
151- newStable,
152- oldMainSnapshot,
153- newMainSnapshot,
154- oldReleaseSnapshot,
155- newReleaseSnapshot,
156- ]
157-
158161 static func baseTestConfig( ) async throws -> Config {
159162 guard let pd = try ? await Swiftly . currentPlatform. detectPlatform ( Self . ctx, disableConfirmation: true , platform: nil ) else {
160163 throw SwiftlyTestError ( message: " Unable to detect the current platform. " )
@@ -515,9 +518,9 @@ public class MockToolchainDownloader: HTTPRequestExecutor {
515518 executables: [ String ] ? = nil ,
516519 latestSwiftlyVersion: SwiftlyVersion = SwiftlyCore . version,
517520 releaseToolchains: [ ToolchainVersion . StableRelease ] = [
518- SwiftlyTests . oldStable. asStableRelease!,
519- SwiftlyTests . newStable. asStableRelease!,
520- SwiftlyTests . oldStableNewPatch. asStableRelease!,
521+ ToolchainVersion . oldStable. asStableRelease!,
522+ ToolchainVersion . newStable. asStableRelease!,
523+ ToolchainVersion . oldStableNewPatch. asStableRelease!,
521524 ToolchainVersion . StableRelease ( major: 5 , minor: 7 , patch: 4 ) , // Some tests look for a patch in the 5.7.x series larger than 5.0.3
522525 ToolchainVersion . StableRelease ( major: 5 , minor: 9 , patch: 0 ) , // Some tests try to update from 5.9.0
523526 ToolchainVersion . StableRelease ( major: 5 , minor: 9 , patch: 1 ) ,
@@ -526,10 +529,10 @@ public class MockToolchainDownloader: HTTPRequestExecutor {
526529 ToolchainVersion . StableRelease ( major: 6 , minor: 0 , patch: 2 ) , // Some tests try to update from 6.0.1
527530 ] ,
528531 snapshotToolchains: [ ToolchainVersion . Snapshot ] = [
529- SwiftlyTests . oldMainSnapshot. asSnapshot!,
530- SwiftlyTests . newMainSnapshot. asSnapshot!,
531- SwiftlyTests . oldReleaseSnapshot. asSnapshot!,
532- SwiftlyTests . newReleaseSnapshot. asSnapshot!,
532+ ToolchainVersion . oldMainSnapshot. asSnapshot!,
533+ ToolchainVersion . newMainSnapshot. asSnapshot!,
534+ ToolchainVersion . oldReleaseSnapshot. asSnapshot!,
535+ ToolchainVersion . newReleaseSnapshot. asSnapshot!,
533536 ]
534537 ) {
535538 self . executables = executables ?? [ " swift " ]
0 commit comments