@@ -39,10 +39,10 @@ public class SwiftlyTests: XCTestCase {
3939 public static let oldStable = ToolchainVersion ( major: 5 , minor: 6 , patch: 0 )
4040 public static let oldStableNewPatch = ToolchainVersion ( major: 5 , minor: 6 , patch: 3 )
4141 public static let newStable = ToolchainVersion ( major: 5 , minor: 7 , patch: 0 )
42- public static let oldMainSnapshot = ToolchainVersion ( snapshotBranch: . main, date: " 2022-09 -10" )
43- public static let newMainSnapshot = ToolchainVersion ( snapshotBranch: . main, date: " 2022-10-22 " )
44- public static let oldReleaseSnapshot = ToolchainVersion ( snapshotBranch: . release( major: 5 , minor: 7 ) , date: " 2022-08-27 " )
45- public static let newReleaseSnapshot = ToolchainVersion ( snapshotBranch: . release( major: 5 , minor: 7 ) , date: " 2022-08-30 " )
42+ public static let oldMainSnapshot = ToolchainVersion ( snapshotBranch: . main, date: " 2025-03 -10" )
43+ public static let newMainSnapshot = ToolchainVersion ( snapshotBranch: . main, date: " 2025-03-14 " )
44+ public static let oldReleaseSnapshot = ToolchainVersion ( snapshotBranch: . release( major: 6 , minor: 0 ) , date: " 2025-02-09 " )
45+ public static let newReleaseSnapshot = ToolchainVersion ( snapshotBranch: . release( major: 6 , minor: 0 ) , date: " 2025-02-11 " )
4646
4747 static let allToolchains : Set < ToolchainVersion > = [
4848 oldStable,
@@ -471,6 +471,10 @@ private struct MockHTTPRequestExecutor: HTTPRequestExecutor {
471471 public func getReleaseToolchains( ) async throws -> [ Components . Schemas . Release ] {
472472 throw SwiftlyTestError ( message: " Mocking of fetching the release toolchains is not implemented in MockHTTPRequestExecutor. " )
473473 }
474+
475+ public func getSnapshotToolchains( branch _: Components . Schemas . KnownSourceBranch , platform _: Components . Schemas . KnownPlatformIdentifier ) async throws -> Components . Schemas . DevToolchains {
476+ throw SwiftlyTestError ( message: " Mocking of fetching the snapshot toolchains is not implemented in MockHTTPRequestExecutor. " )
477+ }
474478}
475479
476480/// An `HTTPRequestExecutor` which will return a mocked response to any toolchain download requests.
@@ -491,6 +495,8 @@ public class MockToolchainDownloader: HTTPRequestExecutor {
491495
492496 private let releaseToolchains : [ ToolchainVersion . StableRelease ]
493497
498+ private let snapshotToolchains : [ ToolchainVersion . Snapshot ]
499+
494500 public init (
495501 executables: [ String ] ? = nil ,
496502 latestSwiftlyVersion: SwiftlyVersion = SwiftlyCore . version,
@@ -505,6 +511,12 @@ public class MockToolchainDownloader: HTTPRequestExecutor {
505511 ToolchainVersion . StableRelease ( major: 6 , minor: 0 , patch: 1 ) , // Some tests try to update from 6.0.0
506512 ToolchainVersion . StableRelease ( major: 6 , minor: 0 , patch: 2 ) , // Some tests try to update from 6.0.1
507513 ] ,
514+ snapshotToolchains: [ ToolchainVersion . Snapshot ] = [
515+ SwiftlyTests . oldMainSnapshot. asSnapshot!,
516+ SwiftlyTests . newMainSnapshot. asSnapshot!,
517+ SwiftlyTests . oldReleaseSnapshot. asSnapshot!,
518+ SwiftlyTests . newReleaseSnapshot. asSnapshot!,
519+ ] ,
508520 delegate: HTTPRequestExecutor
509521 ) {
510522 self . executables = executables ?? [ " swift " ]
@@ -514,6 +526,7 @@ public class MockToolchainDownloader: HTTPRequestExecutor {
514526 self . delegate = delegate
515527 self . latestSwiftlyVersion = latestSwiftlyVersion
516528 self . releaseToolchains = releaseToolchains
529+ self . snapshotToolchains = snapshotToolchains
517530 }
518531
519532 public func getCurrentSwiftlyRelease( ) async throws -> Components . Schemas . SwiftlyRelease {
@@ -572,6 +585,42 @@ public class MockToolchainDownloader: HTTPRequestExecutor {
572585 }
573586 }
574587
588+ public func getSnapshotToolchains( branch: Components . Schemas . KnownSourceBranch , platform _: Components . Schemas . KnownPlatformIdentifier ) async throws -> Components . Schemas . DevToolchains {
589+ let currentPlatform = try await Swiftly . currentPlatform. detectPlatform ( disableConfirmation: true , platform: nil )
590+
591+ let releasesForBranch = self . snapshotToolchains. filter { snapshotVersion in
592+ switch snapshotVersion. branch {
593+ case . main:
594+ branch == . main
595+ case let . release( major, minor) :
596+ major == 6 && minor == 0 && branch == . _6_0
597+ }
598+ }
599+
600+ let devToolchainsForArch = releasesForBranch. map { branchSnapshot in
601+ Components . Schemas. DevToolchainForArch (
602+ name: Components . Schemas. DevToolchainKind? . none,
603+ date: " " ,
604+ dir: branch == . main ?
605+ " swift-DEVELOPMENT-SNAPSHOT- \( branchSnapshot. date) " :
606+ " swift-6.0-DEVELOPMENT-SNAPSHOT- \( branchSnapshot. date) " ,
607+ download: " " ,
608+ downloadSignature: nil ,
609+ debugInfo: nil
610+ )
611+ }
612+
613+ if currentPlatform == PlatformDefinition . macOS {
614+ return Components . Schemas. DevToolchains ( universal: devToolchainsForArch)
615+ } else if cpuArch == Components . Schemas. Architecture. x8664 {
616+ return Components . Schemas. DevToolchains ( x8664: devToolchainsForArch)
617+ } else if cpuArch == Components . Schemas. Architecture. aarch64 {
618+ return Components . Schemas. DevToolchains ( aarch64: devToolchainsForArch)
619+ } else {
620+ return Components . Schemas. DevToolchains ( )
621+ }
622+ }
623+
575624 public func execute( _ request: HTTPClientRequest , timeout: TimeAmount ) async throws -> HTTPClientResponse {
576625 guard let url = URL ( string: request. url) else {
577626 throw SwiftlyTestError ( message: " invalid request URL: \( request. url) " )
0 commit comments