@@ -27,20 +27,11 @@ final class APIDiffTests: XCTestCase {
27
27
return try SwiftPMProduct . SwiftPackage. execute ( args, packagePath: packagePath, env: environment)
28
28
}
29
29
30
- func skipIfApiDigesterUnsupported( ) throws {
31
- guard let tool = try ? Resources . default. toolchain. getSwiftAPIDigester ( ) else {
32
- throw XCTSkip ( " swift-api-digester unavailable " )
33
- }
34
- guard localFileSystem. isSymlink ( tool) else {
35
- // The version of Swift with a supported swift-api-digester doesn't have
36
- // a version number yet, so use whether or not the tool is a symlink to
37
- // determine if it's from a recent snapshot.
38
- throw XCTSkip ( " swift-api-digester is too old " )
39
- }
40
- }
41
-
42
30
func testSimpleAPIDiff( ) throws {
43
- try skipIfApiDigesterUnsupported ( )
31
+ #if os(macOS)
32
+ guard ( try ? Resources . default. toolchain. getSwiftAPIDigester ( ) ) != nil else {
33
+ throw XCTSkip ( " swift-api-digester not available " )
34
+ }
44
35
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
45
36
let packageRoot = prefix. appending ( component: " Foo " )
46
37
// Overwrite the existing decl.
@@ -56,10 +47,16 @@ final class APIDiffTests: XCTestCase {
56
47
XCTAssertTrue ( output. contains ( " 💔 API breakage: func foo() has been removed " ) )
57
48
}
58
49
}
50
+ #else
51
+ throw XCTSkip ( " Test unsupported on current platform " )
52
+ #endif
59
53
}
60
54
61
55
func testMultiTargetAPIDiff( ) throws {
62
- try skipIfApiDigesterUnsupported ( )
56
+ #if os(macOS)
57
+ guard ( try ? Resources . default. toolchain. getSwiftAPIDigester ( ) ) != nil else {
58
+ throw XCTSkip ( " swift-api-digester not available " )
59
+ }
63
60
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
64
61
let packageRoot = prefix. appending ( component: " Bar " )
65
62
try localFileSystem. writeFileContents ( packageRoot. appending ( components: " Sources " , " Baz " , " Baz.swift " ) ) {
@@ -80,6 +77,9 @@ final class APIDiffTests: XCTestCase {
80
77
XCTAssertTrue ( output. contains ( " 💔 API breakage: func bar() has been removed " ) )
81
78
}
82
79
}
80
+ #else
81
+ throw XCTSkip ( " Test unsupported on current platform " )
82
+ #endif
83
83
}
84
84
85
85
func testBreakageAllowlist( ) throws {
@@ -120,7 +120,10 @@ final class APIDiffTests: XCTestCase {
120
120
}
121
121
122
122
func testCheckVendedModulesOnly( ) throws {
123
- try skipIfApiDigesterUnsupported ( )
123
+ #if os(macOS)
124
+ guard ( try ? Resources . default. toolchain. getSwiftAPIDigester ( ) ) != nil else {
125
+ throw XCTSkip ( " swift-api-digester not available " )
126
+ }
124
127
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
125
128
let packageRoot = prefix. appending ( component: " NonAPILibraryTargets " )
126
129
try localFileSystem. writeFileContents ( packageRoot. appending ( components: " Sources " , " Foo " , " Foo.swift " ) ) {
@@ -153,10 +156,16 @@ final class APIDiffTests: XCTestCase {
153
156
XCTAssertFalse ( output. contains ( " 💔 API breakage: var Qux.x has been removed " ) )
154
157
}
155
158
}
159
+ #else
160
+ throw XCTSkip ( " Test unsupported on current platform " )
161
+ #endif
156
162
}
157
163
158
164
func testFilters( ) throws {
159
- try skipIfApiDigesterUnsupported ( )
165
+ #if os(macOS)
166
+ guard ( try ? Resources . default. toolchain. getSwiftAPIDigester ( ) ) != nil else {
167
+ throw XCTSkip ( " swift-api-digester not available " )
168
+ }
160
169
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
161
170
let packageRoot = prefix. appending ( component: " NonAPILibraryTargets " )
162
171
try localFileSystem. writeFileContents ( packageRoot. appending ( components: " Sources " , " Foo " , " Foo.swift " ) ) {
@@ -225,10 +234,16 @@ final class APIDiffTests: XCTestCase {
225
234
XCTAssertTrue ( stderr. contains ( " 'Exec' is not a library target " ) )
226
235
}
227
236
}
237
+ #else
238
+ throw XCTSkip ( " Test unsupported on current platform " )
239
+ #endif
228
240
}
229
241
230
242
func testAPIDiffOfModuleWithCDependency( ) throws {
231
- try skipIfApiDigesterUnsupported ( )
243
+ #if os(macOS)
244
+ guard ( try ? Resources . default. toolchain. getSwiftAPIDigester ( ) ) != nil else {
245
+ throw XCTSkip ( " swift-api-digester not available " )
246
+ }
232
247
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
233
248
let packageRoot = prefix. appending ( component: " CTargetDep " )
234
249
// Overwrite the existing decl.
@@ -261,10 +276,16 @@ final class APIDiffTests: XCTestCase {
261
276
XCTAssertTrue ( stderr. contains ( " error: 'Foo' is not a Swift language target " ) )
262
277
}
263
278
}
279
+ #else
280
+ throw XCTSkip ( " Test unsupported on current platform " )
281
+ #endif
264
282
}
265
283
266
284
func testNoBreakingChanges( ) throws {
267
- try skipIfApiDigesterUnsupported ( )
285
+ #if os(macOS)
286
+ guard ( try ? Resources . default. toolchain. getSwiftAPIDigester ( ) ) != nil else {
287
+ throw XCTSkip ( " swift-api-digester not available " )
288
+ }
268
289
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
269
290
let packageRoot = prefix. appending ( component: " Bar " )
270
291
// Introduce an API-compatible change
@@ -275,10 +296,16 @@ final class APIDiffTests: XCTestCase {
275
296
XCTAssertTrue ( output. contains ( " No breaking changes detected in Baz " ) )
276
297
XCTAssertTrue ( output. contains ( " No breaking changes detected in Qux " ) )
277
298
}
299
+ #else
300
+ throw XCTSkip ( " Test unsupported on current platform " )
301
+ #endif
278
302
}
279
303
280
304
func testAPIDiffAfterAddingNewTarget( ) throws {
281
- try skipIfApiDigesterUnsupported ( )
305
+ #if os(macOS)
306
+ guard ( try ? Resources . default. toolchain. getSwiftAPIDigester ( ) ) != nil else {
307
+ throw XCTSkip ( " swift-api-digester not available " )
308
+ }
282
309
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
283
310
let packageRoot = prefix. appending ( component: " Bar " )
284
311
try localFileSystem. createDirectory ( packageRoot. appending ( components: " Sources " , " Foo " ) )
@@ -309,10 +336,16 @@ final class APIDiffTests: XCTestCase {
309
336
XCTAssertTrue ( output. contains ( " No breaking changes detected in Qux " ) )
310
337
XCTAssertTrue ( output. contains ( " Skipping Foo because it does not exist in the baseline " ) )
311
338
}
339
+ #else
340
+ throw XCTSkip ( " Test unsupported on current platform " )
341
+ #endif
312
342
}
313
343
314
344
func testBadTreeish( ) throws {
315
- try skipIfApiDigesterUnsupported ( )
345
+ #if os(macOS)
346
+ guard ( try ? Resources . default. toolchain. getSwiftAPIDigester ( ) ) != nil else {
347
+ throw XCTSkip ( " swift-api-digester not available " )
348
+ }
316
349
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
317
350
let packageRoot = prefix. appending ( component: " Foo " )
318
351
XCTAssertThrowsError ( try execute ( [ " experimental-api-diff " , " 7.8.9 " ] , packagePath: packageRoot) ) { error in
@@ -323,6 +356,9 @@ final class APIDiffTests: XCTestCase {
323
356
XCTAssertTrue ( stderr. contains ( " error: Couldn’t check out revision ‘7.8.9’ " ) )
324
357
}
325
358
}
359
+ #else
360
+ throw XCTSkip ( " Test unsupported on current platform " )
361
+ #endif
326
362
}
327
363
328
364
func testBaselineDirOverride( ) throws {
0 commit comments