@@ -29,7 +29,16 @@ final class APIDiffTests: XCTestCase {
29
29
environment [ " SWIFTPM_TESTS_PACKAGECACHE " ] = " 1 "
30
30
return try SwiftPMProduct . SwiftPackage. execute ( args, packagePath: packagePath, env: environment)
31
31
}
32
-
32
+
33
+ func skipIfApiDigesterUnsupportedOrUnset( ) throws {
34
+ try skipIfApiDigesterUnsupported ( )
35
+ // The following is added to separate out the integration point testing of the API
36
+ // diff digester with SwiftPM from the functionality tests of the digester itself
37
+ guard ProcessEnv . vars [ " SWIFTPM_TEST_API_DIFF_OUTPUT " ] == " 1 " else {
38
+ throw XCTSkip ( " Env var SWIFTPM_TEST_API_DIFF_OUTPUT must be set to test the output " )
39
+ }
40
+ }
41
+
33
42
func skipIfApiDigesterUnsupported( ) throws {
34
43
// swift-api-digester is required to run tests.
35
44
guard ( try ? UserToolchain . default. getSwiftAPIDigester ( ) ) != nil else {
@@ -44,8 +53,26 @@ final class APIDiffTests: XCTestCase {
44
53
}
45
54
}
46
55
47
- func testSimpleAPIDiff ( ) throws {
56
+ func testInvokeAPIDiffDigester ( ) throws {
48
57
try skipIfApiDigesterUnsupported ( )
58
+ fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
59
+ let packageRoot = prefix. appending ( component: " Foo " )
60
+ // Overwrite the existing decl.
61
+ try localFileSystem. writeFileContents ( packageRoot. appending ( component: " Foo.swift " ) ) {
62
+ $0 <<< " public let foo = 42 "
63
+ }
64
+ XCTAssertThrowsError ( try execute ( [ " diagnose-api-breaking-changes " , " 1.2.3 " ] , packagePath: packageRoot) ) { error in
65
+ guard case SwiftPMProductError . executionFailure( error: _, output: let output, stderr: _) = error else {
66
+ XCTFail ( " Unexpected error " )
67
+ return
68
+ }
69
+ XCTAssertFalse ( output. isEmpty)
70
+ }
71
+ }
72
+ }
73
+
74
+ func testSimpleAPIDiff( ) throws {
75
+ try skipIfApiDigesterUnsupportedOrUnset ( )
49
76
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
50
77
let packageRoot = prefix. appending ( component: " Foo " )
51
78
// Overwrite the existing decl.
@@ -64,7 +91,7 @@ final class APIDiffTests: XCTestCase {
64
91
}
65
92
66
93
func testMultiTargetAPIDiff( ) throws {
67
- try skipIfApiDigesterUnsupported ( )
94
+ try skipIfApiDigesterUnsupportedOrUnset ( )
68
95
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
69
96
let packageRoot = prefix. appending ( component: " Bar " )
70
97
try localFileSystem. writeFileContents ( packageRoot. appending ( components: " Sources " , " Baz " , " Baz.swift " ) ) {
@@ -88,7 +115,7 @@ final class APIDiffTests: XCTestCase {
88
115
}
89
116
90
117
func testBreakageAllowlist( ) throws {
91
- try skipIfApiDigesterUnsupported ( )
118
+ try skipIfApiDigesterUnsupportedOrUnset ( )
92
119
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
93
120
let packageRoot = prefix. appending ( component: " Bar " )
94
121
try localFileSystem. writeFileContents ( packageRoot. appending ( components: " Sources " , " Baz " , " Baz.swift " ) ) {
@@ -119,7 +146,7 @@ final class APIDiffTests: XCTestCase {
119
146
}
120
147
121
148
func testCheckVendedModulesOnly( ) throws {
122
- try skipIfApiDigesterUnsupported ( )
149
+ try skipIfApiDigesterUnsupportedOrUnset ( )
123
150
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
124
151
let packageRoot = prefix. appending ( component: " NonAPILibraryTargets " )
125
152
try localFileSystem. writeFileContents ( packageRoot. appending ( components: " Sources " , " Foo " , " Foo.swift " ) ) {
@@ -155,7 +182,7 @@ final class APIDiffTests: XCTestCase {
155
182
}
156
183
157
184
func testFilters( ) throws {
158
- try skipIfApiDigesterUnsupported ( )
185
+ try skipIfApiDigesterUnsupportedOrUnset ( )
159
186
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
160
187
let packageRoot = prefix. appending ( component: " NonAPILibraryTargets " )
161
188
try localFileSystem. writeFileContents ( packageRoot. appending ( components: " Sources " , " Foo " , " Foo.swift " ) ) {
@@ -227,7 +254,7 @@ final class APIDiffTests: XCTestCase {
227
254
}
228
255
229
256
func testAPIDiffOfModuleWithCDependency( ) throws {
230
- try skipIfApiDigesterUnsupported ( )
257
+ try skipIfApiDigesterUnsupportedOrUnset ( )
231
258
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
232
259
let packageRoot = prefix. appending ( component: " CTargetDep " )
233
260
// Overwrite the existing decl.
@@ -263,7 +290,7 @@ final class APIDiffTests: XCTestCase {
263
290
}
264
291
265
292
func testNoBreakingChanges( ) throws {
266
- try skipIfApiDigesterUnsupported ( )
293
+ try skipIfApiDigesterUnsupportedOrUnset ( )
267
294
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
268
295
let packageRoot = prefix. appending ( component: " Bar " )
269
296
// Introduce an API-compatible change
@@ -277,7 +304,7 @@ final class APIDiffTests: XCTestCase {
277
304
}
278
305
279
306
func testAPIDiffAfterAddingNewTarget( ) throws {
280
- try skipIfApiDigesterUnsupported ( )
307
+ try skipIfApiDigesterUnsupportedOrUnset ( )
281
308
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
282
309
let packageRoot = prefix. appending ( component: " Bar " )
283
310
try localFileSystem. createDirectory ( packageRoot. appending ( components: " Sources " , " Foo " ) )
@@ -311,7 +338,7 @@ final class APIDiffTests: XCTestCase {
311
338
}
312
339
313
340
func testBadTreeish( ) throws {
314
- try skipIfApiDigesterUnsupported ( )
341
+ try skipIfApiDigesterUnsupportedOrUnset ( )
315
342
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
316
343
let packageRoot = prefix. appending ( component: " Foo " )
317
344
XCTAssertThrowsError ( try execute ( [ " diagnose-api-breaking-changes " , " 7.8.9 " ] , packagePath: packageRoot) ) { error in
@@ -325,7 +352,7 @@ final class APIDiffTests: XCTestCase {
325
352
}
326
353
327
354
func testBranchUpdate( ) throws {
328
- try skipIfApiDigesterUnsupported ( )
355
+ try skipIfApiDigesterUnsupportedOrUnset ( )
329
356
try withTemporaryDirectory { baselineDir in
330
357
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
331
358
let packageRoot = prefix. appending ( component: " Foo " )
@@ -363,7 +390,7 @@ final class APIDiffTests: XCTestCase {
363
390
}
364
391
365
392
func testBaselineDirOverride( ) throws {
366
- try skipIfApiDigesterUnsupported ( )
393
+ try skipIfApiDigesterUnsupportedOrUnset ( )
367
394
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
368
395
let packageRoot = prefix. appending ( component: " Foo " )
369
396
// Overwrite the existing decl.
@@ -390,7 +417,7 @@ final class APIDiffTests: XCTestCase {
390
417
}
391
418
392
419
func testRegenerateBaseline( ) throws {
393
- try skipIfApiDigesterUnsupported ( )
420
+ try skipIfApiDigesterUnsupportedOrUnset ( )
394
421
fixture ( name: " Miscellaneous/APIDiff/ " ) { prefix in
395
422
let packageRoot = prefix. appending ( component: " Foo " )
396
423
// Overwrite the existing decl.
0 commit comments