Skip to content

Commit 48d9b4c

Browse files
authored
Revert "[APIDiff] Enable tests on non-Darwin (#3519)"
This reverts commit e4201de.
1 parent e4201de commit 48d9b4c

File tree

1 file changed

+56
-20
lines changed

1 file changed

+56
-20
lines changed

Tests/CommandsTests/APIDiffTests.swift

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,11 @@ final class APIDiffTests: XCTestCase {
2727
return try SwiftPMProduct.SwiftPackage.execute(args, packagePath: packagePath, env: environment)
2828
}
2929

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-
4230
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+
}
4435
fixture(name: "Miscellaneous/APIDiff/") { prefix in
4536
let packageRoot = prefix.appending(component: "Foo")
4637
// Overwrite the existing decl.
@@ -56,10 +47,16 @@ final class APIDiffTests: XCTestCase {
5647
XCTAssertTrue(output.contains("💔 API breakage: func foo() has been removed"))
5748
}
5849
}
50+
#else
51+
throw XCTSkip("Test unsupported on current platform")
52+
#endif
5953
}
6054

6155
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+
}
6360
fixture(name: "Miscellaneous/APIDiff/") { prefix in
6461
let packageRoot = prefix.appending(component: "Bar")
6562
try localFileSystem.writeFileContents(packageRoot.appending(components: "Sources", "Baz", "Baz.swift")) {
@@ -80,6 +77,9 @@ final class APIDiffTests: XCTestCase {
8077
XCTAssertTrue(output.contains("💔 API breakage: func bar() has been removed"))
8178
}
8279
}
80+
#else
81+
throw XCTSkip("Test unsupported on current platform")
82+
#endif
8383
}
8484

8585
func testBreakageAllowlist() throws {
@@ -120,7 +120,10 @@ final class APIDiffTests: XCTestCase {
120120
}
121121

122122
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+
}
124127
fixture(name: "Miscellaneous/APIDiff/") { prefix in
125128
let packageRoot = prefix.appending(component: "NonAPILibraryTargets")
126129
try localFileSystem.writeFileContents(packageRoot.appending(components: "Sources", "Foo", "Foo.swift")) {
@@ -153,10 +156,16 @@ final class APIDiffTests: XCTestCase {
153156
XCTAssertFalse(output.contains("💔 API breakage: var Qux.x has been removed"))
154157
}
155158
}
159+
#else
160+
throw XCTSkip("Test unsupported on current platform")
161+
#endif
156162
}
157163

158164
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+
}
160169
fixture(name: "Miscellaneous/APIDiff/") { prefix in
161170
let packageRoot = prefix.appending(component: "NonAPILibraryTargets")
162171
try localFileSystem.writeFileContents(packageRoot.appending(components: "Sources", "Foo", "Foo.swift")) {
@@ -225,10 +234,16 @@ final class APIDiffTests: XCTestCase {
225234
XCTAssertTrue(stderr.contains("'Exec' is not a library target"))
226235
}
227236
}
237+
#else
238+
throw XCTSkip("Test unsupported on current platform")
239+
#endif
228240
}
229241

230242
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+
}
232247
fixture(name: "Miscellaneous/APIDiff/") { prefix in
233248
let packageRoot = prefix.appending(component: "CTargetDep")
234249
// Overwrite the existing decl.
@@ -261,10 +276,16 @@ final class APIDiffTests: XCTestCase {
261276
XCTAssertTrue(stderr.contains("error: 'Foo' is not a Swift language target"))
262277
}
263278
}
279+
#else
280+
throw XCTSkip("Test unsupported on current platform")
281+
#endif
264282
}
265283

266284
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+
}
268289
fixture(name: "Miscellaneous/APIDiff/") { prefix in
269290
let packageRoot = prefix.appending(component: "Bar")
270291
// Introduce an API-compatible change
@@ -275,10 +296,16 @@ final class APIDiffTests: XCTestCase {
275296
XCTAssertTrue(output.contains("No breaking changes detected in Baz"))
276297
XCTAssertTrue(output.contains("No breaking changes detected in Qux"))
277298
}
299+
#else
300+
throw XCTSkip("Test unsupported on current platform")
301+
#endif
278302
}
279303

280304
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+
}
282309
fixture(name: "Miscellaneous/APIDiff/") { prefix in
283310
let packageRoot = prefix.appending(component: "Bar")
284311
try localFileSystem.createDirectory(packageRoot.appending(components: "Sources", "Foo"))
@@ -309,10 +336,16 @@ final class APIDiffTests: XCTestCase {
309336
XCTAssertTrue(output.contains("No breaking changes detected in Qux"))
310337
XCTAssertTrue(output.contains("Skipping Foo because it does not exist in the baseline"))
311338
}
339+
#else
340+
throw XCTSkip("Test unsupported on current platform")
341+
#endif
312342
}
313343

314344
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+
}
316349
fixture(name: "Miscellaneous/APIDiff/") { prefix in
317350
let packageRoot = prefix.appending(component: "Foo")
318351
XCTAssertThrowsError(try execute(["experimental-api-diff", "7.8.9"], packagePath: packageRoot)) { error in
@@ -323,6 +356,9 @@ final class APIDiffTests: XCTestCase {
323356
XCTAssertTrue(stderr.contains("error: Couldn’t check out revision ‘7.8.9’"))
324357
}
325358
}
359+
#else
360+
throw XCTSkip("Test unsupported on current platform")
361+
#endif
326362
}
327363

328364
func testBaselineDirOverride() throws {

0 commit comments

Comments
 (0)