@@ -9,38 +9,37 @@ import Testing
99
1010 /// Tests that the `run` command can switch between installed toolchains.
1111 @Test ( . mockedSwiftlyVersion( ) , . mockHomeToolchains( ) ) func runSelection( ) async throws {
12- // GIVEN: a set of installed toolchains
13- // WHEN: invoking the run command with a selector argument for that toolchain
14- var output = try await SwiftlyTests . runWithMockedIO ( Run . self, [ " run " , " swift " , " --version " , " + \( ToolchainVersion . newStable. name) " ] )
15- // THEN: the output confirms that it ran with the selected toolchain
16- #expect( output. contains ( ToolchainVersion . newStable. name) )
12+ // GIVEN: a set of installed toolchains
13+ // WHEN: invoking the run command with a selector argument for that toolchain
14+ var output = try await SwiftlyTests . runWithMockedIO ( Run . self, [ " run " , " swift " , " --version " , " + \( ToolchainVersion . newStable. name) " ] )
15+ // THEN: the output confirms that it ran with the selected toolchain
16+ #expect( output. contains ( ToolchainVersion . newStable. name) )
1717
18- // GIVEN: a set of installed toolchains and one is selected with a .swift-version file
19- let versionFile = SwiftlyTests . ctx. currentDirectory / " .swift-version "
20- try ToolchainVersion . oldStable. name. write ( to: versionFile, atomically: true , encoding: . utf8)
21- // WHEN: invoking the run command without any selector arguments for toolchains
22- output = try await SwiftlyTests . runWithMockedIO ( Run . self, [ " run " , " swift " , " --version " ] )
23- // THEN: the output confirms that it ran with the selected toolchain
24- #expect( output. contains ( ToolchainVersion . oldStable. name) )
18+ // GIVEN: a set of installed toolchains and one is selected with a .swift-version file
19+ let versionFile = SwiftlyTests . ctx. currentDirectory / " .swift-version "
20+ try ToolchainVersion . oldStable. name. write ( to: versionFile, atomically: true , encoding: . utf8)
21+ // WHEN: invoking the run command without any selector arguments for toolchains
22+ output = try await SwiftlyTests . runWithMockedIO ( Run . self, [ " run " , " swift " , " --version " ] )
23+ // THEN: the output confirms that it ran with the selected toolchain
24+ #expect( output. contains ( ToolchainVersion . oldStable. name) )
2525
26- // GIVEN: a set of installed toolchains
27- // WHEN: invoking the run command with a selector argument for a toolchain that isn't installed
28- do {
29- try await SwiftlyTests . runCommand ( Run . self, [ " run " , " swift " , " +1.2.3 " , " --version " ] )
30- #expect( false )
31- } catch let e as SwiftlyError {
32- #expect( e. message. contains ( " didn't match any of the installed toolchains " ) )
33- }
34- // THEN: an error is shown because there is no matching toolchain that is installed
26+ // GIVEN: a set of installed toolchains
27+ // WHEN: invoking the run command with a selector argument for a toolchain that isn't installed
28+ do {
29+ try await SwiftlyTests . runCommand ( Run . self, [ " run " , " swift " , " +1.2.3 " , " --version " ] )
30+ #expect( false )
31+ } catch let e as SwiftlyError {
32+ #expect( e. message. contains ( " didn't match any of the installed toolchains " ) )
33+ }
34+ // THEN: an error is shown because there is no matching toolchain that is installed
3535 }
3636
3737 /// Tests the `run` command verifying that the environment is as expected
3838 @Test ( . mockedSwiftlyVersion( ) , . mockHomeToolchains( ) ) func runEnvironment( ) async throws {
39-
40- // The toolchains directory should be the fist entry on the path
41- let output = try await SwiftlyTests . runWithMockedIO ( Run . self, [ " run " , try await Swiftly . currentPlatform. getShell ( ) , " -c " , " echo $PATH " ] )
42- #expect( output. count == 1 )
43- #expect( output [ 0 ] . contains ( Swiftly . currentPlatform. swiftlyToolchainsDir ( SwiftlyTests . ctx) . string) )
39+ // The toolchains directory should be the fist entry on the path
40+ let output = try await SwiftlyTests . runWithMockedIO ( Run . self, [ " run " , try await Swiftly . currentPlatform. getShell ( ) , " -c " , " echo $PATH " ] )
41+ #expect( output. count == 1 )
42+ #expect( output [ 0 ] . contains ( Swiftly . currentPlatform. swiftlyToolchainsDir ( SwiftlyTests . ctx) . string) )
4443 }
4544
4645 /// Tests the extraction of proxy arguments from the run command arguments.
0 commit comments