Skip to content

Commit e0afabb

Browse files
Factor the working directory skip into a common function (#8561)
Also skips on OpenBSD, which has the same issue.
1 parent 6965245 commit e0afabb

File tree

4 files changed

+24
-25
lines changed

4 files changed

+24
-25
lines changed

Sources/_InternalTestSupport/XCTAssertHelpers.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,21 @@ public struct CommandExecutionError: Error {
268268
public let stdout: String
269269
public let stderr: String
270270
}
271+
272+
/// Skips the test if running on a platform which lacks the ability for build tasks to set a working directory due to lack of requisite system API.
273+
///
274+
/// Presently, relevant platforms include Amazon Linux 2 and OpenBSD.
275+
///
276+
/// - seealso: https://github.com/swiftlang/swift-package-manager/issues/8560
277+
public func XCTSkipIfWorkingDirectoryUnsupported() throws {
278+
func unavailable() throws {
279+
throw XCTSkip("Thread-safe process working directory support is unavailable on this platform.")
280+
}
281+
#if os(Linux)
282+
if FileManager.default.contents(atPath: "/etc/system-release").map({ String(decoding: $0, as: UTF8.self) == "Amazon Linux release 2 (Karoo)\n" }) ?? false {
283+
try unavailable()
284+
}
285+
#elseif os(OpenBSD)
286+
try unavailable()
287+
#endif
288+
}

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7069,14 +7069,11 @@ class BuildPlanSwiftBuildTests: BuildPlanTestCase {
70697069
}
70707070

70717071
override func testPackageNameFlag() async throws {
7072+
try XCTSkipIfWorkingDirectoryUnsupported()
70727073
#if os(Windows)
70737074
throw XCTSkip("Skip until there is a resolution to the partial linking with Windows that results in a 'subsystem must be defined' error.")
70747075
#endif
7075-
70767076
#if os(Linux)
7077-
if FileManager.default.contents(atPath: "/etc/system-release").map { String(decoding: $0, as: UTF8.self) == "Amazon Linux release 2 (Karoo)\n" } ?? false {
7078-
throw XCTSkip("Skipping Swift Build testing on Amazon Linux because of platform issues.")
7079-
}
70807077
// Linking error: "/usr/bin/ld.gold: fatal error: -pie and -static are incompatible".
70817078
// Tracked by GitHub issue: https://github.com/swiftlang/swift-package-manager/issues/8499
70827079
throw XCTSkip("Skipping Swift Build testing on Linux because of linking issues.")

Tests/CommandsTests/BuildCommandTests.swift

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -859,12 +859,7 @@ class BuildCommandSwiftBuildTests: BuildCommandTestCases {
859859
}
860860

861861
override func testParseableInterfaces() async throws {
862-
#if os(Linux)
863-
if FileManager.default.contents(atPath: "/etc/system-release")
864-
.map { String(decoding: $0, as: UTF8.self) == "Amazon Linux release 2 (Karoo)\n" } ?? false {
865-
throw XCTSkip("https://github.com/swiftlang/swift-package-manager/issues/8545: Test currently fails on Amazon Linux 2")
866-
}
867-
#endif
862+
try XCTSkipIfWorkingDirectoryUnsupported()
868863
try await fixture(name: "Miscellaneous/ParseableInterfaces") { fixturePath in
869864
do {
870865
let result = try await build(["--enable-parseable-module-interfaces"], packagePath: fixturePath)
@@ -944,11 +939,7 @@ class BuildCommandSwiftBuildTests: BuildCommandTestCases {
944939
#endif
945940

946941
override func testBuildSystemDefaultSettings() async throws {
947-
#if os(Linux)
948-
if FileManager.default.contents(atPath: "/etc/system-release").map( { String(decoding: $0, as: UTF8.self) == "Amazon Linux release 2 (Karoo)\n" } ) ?? false {
949-
throw XCTSkip("Skipping SwiftBuild testing on Amazon Linux because of platform issues.")
950-
}
951-
#endif
942+
try XCTSkipIfWorkingDirectoryUnsupported()
952943

953944
if ProcessInfo.processInfo.environment["SWIFTPM_NO_SWBUILD_DEPENDENCY"] != nil {
954945
throw XCTSkip("SWIFTPM_NO_SWBUILD_DEPENDENCY is set so skipping because SwiftPM doesn't have the swift-build capability built inside.")
@@ -958,11 +949,7 @@ class BuildCommandSwiftBuildTests: BuildCommandTestCases {
958949
}
959950

960951
override func testBuildCompleteMessage() async throws {
961-
#if os(Linux)
962-
if FileManager.default.contents(atPath: "/etc/system-release").map { String(decoding: $0, as: UTF8.self) == "Amazon Linux release 2 (Karoo)\n" } ?? false {
963-
throw XCTSkip("Skipping Swift Build testing on Amazon Linux because of platform issues.")
964-
}
965-
#endif
952+
try XCTSkipIfWorkingDirectoryUnsupported()
966953

967954
try await super.testBuildCompleteMessage()
968955
}

Tests/CommandsTests/PackageCommandTests.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3906,11 +3906,8 @@ class PackageCommandSwiftBuildTests: PackageCommandTestCase {
39063906

39073907
#if !os(macOS)
39083908
override func testCommandPluginTestingCallbacks() async throws {
3909-
#if os(Linux)
3910-
if FileManager.default.contents(atPath: "/etc/system-release").map { String(decoding: $0, as: UTF8.self) == "Amazon Linux release 2 (Karoo)\n" } ?? false {
3911-
throw XCTSkip("Skipping Swift Build testing on Amazon Linux because of platform issues.")
3912-
}
3913-
#endif
3909+
try XCTSkipIfWorkingDirectoryUnsupported()
3910+
39143911
try await super.testCommandPluginTestingCallbacks()
39153912
}
39163913
#endif

0 commit comments

Comments
 (0)