@@ -47,89 +47,50 @@ final class PackageToolTests: XCTestCase {
47
47
let stdout = try execute ( [ " --version " ] ) . stdout
48
48
XCTAssert ( stdout. contains ( " Swift Package Manager " ) , " got stdout: \n " + stdout)
49
49
}
50
-
51
- func testNetrcSupportedOS( ) throws {
52
- func verifyUnsupportedOSThrows( ) {
50
+
51
+ func testNetrcFile( ) throws {
52
+ fixture ( name: " DependencyResolution/External/XCFramework " ) { packageRoot in
53
+ let fs = localFileSystem
54
+ let netrcPath = packageRoot. appending ( component: " .netrc " )
55
+ try fs. writeFileContents ( netrcPath) { stream in
56
+ stream
<<< " machine mymachine.labkey.org login [email protected] password mypassword "
57
+ }
58
+
53
59
do {
54
- // should throw and be caught
55
- try execute ( [ " update " , " --netrc-file " , " /Users/me/.hidden/.netrc " ] )
56
- XCTFail ( )
60
+ // file at correct location
61
+ try execute ( [ " --netrc-file " , netrcPath. pathString, " resolve " ] , packagePath: packageRoot)
62
+ // file does not exist, but is optional
63
+ let textOutput = try execute ( [ " --netrc-file " , " /foo " , " --netrc-optional " , " resolve " ] , packagePath: packageRoot) . stderr
64
+ XCTAssert ( textOutput. contains ( " warning: Did not find optional .netrc file at /foo. " ) )
65
+
66
+ // required file does not exist, will throw
67
+ try execute ( [ " --netrc-file " , " /foo " , " resolve " ] , packagePath: packageRoot)
57
68
} catch {
58
- XCTAssert ( true )
69
+ XCTAssert ( String ( describing : error ) . contains ( " Cannot find mandatory .netrc file at /foo " ) , " \( error ) " )
59
70
}
60
71
}
61
- #if os(macOS)
62
- if #available( macOS 10 . 13 , * ) {
63
- // should succeed
64
- XCTAssert ( try execute ( [ " --netrc " ] ) . stdout. contains ( " USAGE: swift package " ) )
65
- XCTAssert ( try execute ( [ " --netrc-file " , " /Users/me/.hidden/.netrc " ] ) . stdout. contains ( " USAGE: swift package " ) )
66
- XCTAssert ( try execute ( [ " --netrc-optional " ] ) . stdout. contains ( " USAGE: swift package " ) )
67
- } else {
68
- verifyUnsupportedOSThrows ( )
69
- }
70
- #else
71
- verifyUnsupportedOSThrows ( )
72
- #endif
73
- }
74
-
75
- func testNetrcFile( ) throws {
76
- #if os(macOS)
77
- if #available( macOS 10 . 13 , * ) {
78
- // SUPPORTED OS
79
- fixture ( name: " DependencyResolution/External/Complex " ) { prefix in
80
- let packageRoot = prefix. appending ( component: " app " )
81
-
82
- let fs = localFileSystem
83
- let netrcPath = prefix. appending ( component: " .netrc " )
84
- try fs. writeFileContents ( netrcPath) { stream in
85
- stream
<<< " machine mymachine.labkey.org login [email protected] password mypassword "
86
- }
87
-
88
- do {
89
- // file at correct location
90
- try execute ( [ " --netrc-file " , netrcPath. pathString, " resolve " ] , packagePath: packageRoot)
91
- XCTAssert ( true )
72
+
73
+ fixture ( name: " DependencyResolution/External/XCFramework " ) { packageRoot in
74
+ do {
75
+ // Developer machine may have .netrc file at NSHomeDirectory; modify test accordingly
76
+ if localFileSystem. exists ( localFileSystem. homeDirectory. appending ( RelativePath ( " .netrc " ) ) ) {
77
+ try execute ( [ " --netrc " , " resolve " ] , packagePath: packageRoot)
78
+ } else {
92
79
// file does not exist, but is optional
93
- let textOutput = try execute ( [ " --netrc-file " , " /foo " , " --netrc-optional " , " resolve " ] , packagePath: packageRoot) . stderr
94
- XCTAssert ( textOutput. contains ( " warning: Did not find optional .netrc file at /foo. " ) )
95
-
80
+ let textOutput = try execute ( [ " --netrc " , " --netrc-optional " , " resolve " ] , packagePath: packageRoot)
81
+ XCTAssert ( textOutput. stderr. contains ( " Did not find optional .netrc file at \( localFileSystem. homeDirectory) /.netrc. " ) )
82
+
83
+ // file does not exist, but is optional
84
+ let textOutput2 = try execute ( [ " --netrc-optional " , " resolve " ] , packagePath: packageRoot)
85
+ XCTAssert ( textOutput2. stderr. contains ( " Did not find optional .netrc file at \( localFileSystem. homeDirectory) /.netrc. " ) )
86
+
96
87
// required file does not exist, will throw
97
- try execute ( [ " --netrc-file " , " /foo " , " resolve " ] , packagePath: packageRoot)
98
-
99
- } catch {
100
- XCTAssert ( String ( describing: error) . contains ( " Cannot find mandatory .netrc file at /foo " ) )
101
- }
102
- }
103
-
104
- fixture ( name: " DependencyResolution/External/Complex " ) { prefix in
105
- let packageRoot = prefix. appending ( component: " app " )
106
- do {
107
- // Developer machine may have .netrc file at NSHomeDirectory; modify test accordingly
108
- if localFileSystem. exists ( localFileSystem. homeDirectory. appending ( RelativePath ( " .netrc " ) ) ) {
109
- try execute ( [ " --netrc " , " resolve " ] , packagePath: packageRoot)
110
- XCTAssert ( true )
111
- } else {
112
- // file does not exist, but is optional
113
- let textOutput = try execute ( [ " --netrc " , " --netrc-optional " , " resolve " ] , packagePath: packageRoot)
114
- XCTAssert ( textOutput. stderr. contains ( " Did not find optional .netrc file at \( localFileSystem. homeDirectory) /.netrc. " ) )
115
-
116
- // file does not exist, but is optional
117
- let textOutput2 = try execute ( [ " --netrc-optional " , " resolve " ] , packagePath: packageRoot)
118
- XCTAssert ( textOutput2. stderr. contains ( " Did not find optional .netrc file at \( localFileSystem. homeDirectory) /.netrc. " ) )
119
-
120
- // required file does not exist, will throw
121
- try execute ( [ " --netrc " , " resolve " ] , packagePath: packageRoot)
122
- }
123
- } catch {
124
- XCTAssert ( String ( describing: error) . contains ( " Cannot find mandatory .netrc file at \( localFileSystem. homeDirectory) /.netrc " ) )
88
+ try execute ( [ " --netrc " , " resolve " ] , packagePath: packageRoot)
125
89
}
90
+ } catch {
91
+ XCTAssert ( String ( describing: error) . contains ( " Cannot find mandatory .netrc file at \( localFileSystem. homeDirectory) /.netrc " ) )
126
92
}
127
- } else {
128
- // UNSUPPORTED OS, HANDLED ELSEWHERE
129
93
}
130
- #else
131
- // UNSUPPORTED OS, HANDLED ELSEWHERE
132
- #endif
133
94
}
134
95
135
96
func testResolve( ) throws {
0 commit comments