11
11
import XCTest
12
12
import Foundation
13
13
import TSCBasic
14
+ import Build
14
15
import Commands
15
16
import SPMTestSupport
16
17
@@ -28,20 +29,20 @@ final class APIDiffTests: XCTestCase {
28
29
}
29
30
30
31
func skipIfApiDigesterUnsupported( ) throws {
31
- guard let tool = try ? Resources . default. toolchain. getSwiftAPIDigester ( ) else {
32
+ // swift-api-digester is required to run tests.
33
+ guard ( try ? Resources . default. toolchain. getSwiftAPIDigester ( ) ) != nil else {
32
34
throw XCTSkip ( " swift-api-digester unavailable " )
33
35
}
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.
36
+ // SwiftPM's swift-api-digester integration relies on post-5.5 bugfixes and features,
37
+ // not all of which can be tested for easily. Fortunately, we can test for the
38
+ // `-disable-fail-on-error` option, and any version which supports this flag
39
+ // will meet the other requirements.
40
+ guard SwiftTargetBuildDescription . checkSupportedFrontendFlags ( flags: [ " disable-fail-on-error " ] , fs: localFileSystem) else {
38
41
throw XCTSkip ( " swift-api-digester is too old " )
39
42
}
40
43
}
41
44
42
45
func testSimpleAPIDiff( ) throws {
43
- throw XCTSkip ( " Fix this test " )
44
-
45
46
try skipIfApiDigesterUnsupported ( )
46
47
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
47
48
let packageRoot = prefix. appending ( component: " Foo " )
@@ -61,8 +62,6 @@ final class APIDiffTests: XCTestCase {
61
62
}
62
63
63
64
func testMultiTargetAPIDiff( ) throws {
64
- throw XCTSkip ( " Fix this test " )
65
-
66
65
try skipIfApiDigesterUnsupported ( )
67
66
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
68
67
let packageRoot = prefix. appending ( component: " Bar " )
@@ -87,12 +86,7 @@ final class APIDiffTests: XCTestCase {
87
86
}
88
87
89
88
func testBreakageAllowlist( ) throws {
90
- throw XCTSkip ( " Fix this test " )
91
-
92
- #if os(macOS)
93
- guard ( try ? Resources . default. toolchain. getSwiftAPIDigester ( ) ) != nil else {
94
- throw XCTSkip ( " swift-api-digester not available " )
95
- }
89
+ try skipIfApiDigesterUnsupported ( )
96
90
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
97
91
let packageRoot = prefix. appending ( component: " Bar " )
98
92
try localFileSystem. writeFileContents ( packageRoot. appending ( components: " Sources " , " Baz " , " Baz.swift " ) ) {
@@ -120,14 +114,9 @@ final class APIDiffTests: XCTestCase {
120
114
}
121
115
122
116
}
123
- #else
124
- throw XCTSkip ( " Test unsupported on current platform " )
125
- #endif
126
117
}
127
118
128
119
func testCheckVendedModulesOnly( ) throws {
129
- throw XCTSkip ( " Fix this test " )
130
-
131
120
try skipIfApiDigesterUnsupported ( )
132
121
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
133
122
let packageRoot = prefix. appending ( component: " NonAPILibraryTargets " )
@@ -164,8 +153,6 @@ final class APIDiffTests: XCTestCase {
164
153
}
165
154
166
155
func testFilters( ) throws {
167
- throw XCTSkip ( " Fix this test " )
168
-
169
156
try skipIfApiDigesterUnsupported ( )
170
157
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
171
158
let packageRoot = prefix. appending ( component: " NonAPILibraryTargets " )
@@ -238,8 +225,6 @@ final class APIDiffTests: XCTestCase {
238
225
}
239
226
240
227
func testAPIDiffOfModuleWithCDependency( ) throws {
241
- throw XCTSkip ( " Fix this test " )
242
-
243
228
try skipIfApiDigesterUnsupported ( )
244
229
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
245
230
let packageRoot = prefix. appending ( component: " CTargetDep " )
@@ -338,12 +323,7 @@ final class APIDiffTests: XCTestCase {
338
323
}
339
324
340
325
func testBaselineDirOverride( ) throws {
341
- throw XCTSkip ( " Fix this test " )
342
-
343
- #if os(macOS)
344
- guard ( try ? Resources . default. toolchain. getSwiftAPIDigester ( ) ) != nil else {
345
- throw XCTSkip ( " swift-api-digester not available " )
346
- }
326
+ try skipIfApiDigesterUnsupported ( )
347
327
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
348
328
let packageRoot = prefix. appending ( component: " Foo " )
349
329
// Overwrite the existing decl.
@@ -365,18 +345,10 @@ final class APIDiffTests: XCTestCase {
365
345
XCTAssertTrue ( localFileSystem. exists ( baselineDir. appending ( components: " 1.2.3 " , " Foo.json " ) ) )
366
346
}
367
347
}
368
- #else
369
- throw XCTSkip ( " Test unsupported on current platform " )
370
- #endif
371
348
}
372
349
373
350
func testRegenerateBaseline( ) throws {
374
- throw XCTSkip ( " Fix this test " )
375
-
376
- #if os(macOS)
377
- guard ( try ? Resources . default. toolchain. getSwiftAPIDigester ( ) ) != nil else {
378
- throw XCTSkip ( " swift-api-digester not available " )
379
- }
351
+ try skipIfApiDigesterUnsupported ( )
380
352
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
381
353
let packageRoot = prefix. appending ( component: " Foo " )
382
354
// Overwrite the existing decl.
@@ -406,8 +378,5 @@ final class APIDiffTests: XCTestCase {
406
378
XCTAssertNotEqual ( ( try ! localFileSystem. readFileContents ( fooBaselinePath) ) . description, " Old Baseline " )
407
379
}
408
380
}
409
- #else
410
- throw XCTSkip ( " Test unsupported on current platform " )
411
- #endif
412
381
}
413
382
}
0 commit comments