Skip to content

Commit f133dfa

Browse files
committed
Remove workarounds for missing chdir support on Amazon Linux 2
Closes #8560
1 parent 11c1cdf commit f133dfa

File tree

8 files changed

+11
-57
lines changed

8 files changed

+11
-57
lines changed

Sources/Basics/Concurrency/AsyncProcess.swift

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import TSCLibc
1818
import Android
1919
#endif
2020

21-
#if os(Linux)
21+
#if !os(Windows)
2222
#if USE_IMPL_ONLY_IMPORTS
2323
@_implementationOnly
2424
import func TSCclibc.SPM_posix_spawn_file_actions_addchdir_np_supported
@@ -621,24 +621,11 @@ package final class AsyncProcess {
621621
defer { posix_spawn_file_actions_destroy(&fileActions) }
622622

623623
if let workingDirectory = workingDirectory?.pathString {
624-
#if canImport(Darwin)
625-
// The only way to set a workingDirectory is using an availability-gated initializer, so we don't need
626-
// to handle the case where the posix_spawn_file_actions_addchdir_np method is unavailable. This check only
627-
// exists here to make the compiler happy.
628-
if #available(macOS 10.15, *) {
629-
posix_spawn_file_actions_addchdir_np(&fileActions, workingDirectory)
630-
}
631-
#elseif os(FreeBSD)
632-
posix_spawn_file_actions_addchdir_np(&fileActions, workingDirectory)
633-
#elseif os(Linux)
634624
guard SPM_posix_spawn_file_actions_addchdir_np_supported() else {
635625
throw AsyncProcess.Error.workingDirectoryNotSupported
636626
}
637627

638628
SPM_posix_spawn_file_actions_addchdir_np(&fileActions, workingDirectory)
639-
#else
640-
throw AsyncProcess.Error.workingDirectoryNotSupported
641-
#endif
642629
}
643630

644631
var stdinPipe: [Int32] = [-1, -1]

Sources/_InternalTestSupport/SkippedTestSupport.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,4 @@ extension Trait where Self == Testing.ConditionTrait {
5858
#endif
5959
}
6060
}
61-
62-
/// Constructs a condition trait that causes a test to be disabled if the Foundation process spawning implementation
63-
/// is not using `posix_spawn_file_actions_addchdir`.
64-
public static var requireThreadSafeWorkingDirectory: Self {
65-
disabled("Thread-safe process working directory support is unavailable.") {
66-
// Amazon Linux 2 has glibc 2.26, and glibc 2.29 is needed for posix_spawn_file_actions_addchdir_np support
67-
FileManager.default.contents(atPath: "/etc/system-release")
68-
.map { String(decoding: $0, as: UTF8.self) == "Amazon Linux release 2 (Karoo)\n" } ?? false
69-
}
70-
}
7161
}

Sources/_InternalTestSupport/XCTAssertHelpers.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -317,21 +317,3 @@ public struct CommandExecutionError: Error {
317317
public let stdout: String
318318
public let stderr: String
319319
}
320-
321-
/// 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.
322-
///
323-
/// Presently, relevant platforms include Amazon Linux 2 and OpenBSD.
324-
///
325-
/// - seealso: https://github.com/swiftlang/swift-package-manager/issues/8560
326-
public func XCTSkipIfWorkingDirectoryUnsupported() throws {
327-
func unavailable() throws {
328-
throw XCTSkip("https://github.com/swiftlang/swift-package-manager/issues/8560: Thread-safe process working directory support is unavailable on this platform.")
329-
}
330-
#if os(Linux)
331-
if FileManager.default.contents(atPath: "/etc/system-release").map({ String(decoding: $0, as: UTF8.self) == "Amazon Linux release 2 (Karoo)\n" }) ?? false {
332-
try unavailable()
333-
}
334-
#elseif os(OpenBSD)
335-
try unavailable()
336-
#endif
337-
}

Tests/BasicsTests/Archiver/TarArchiverTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ final class TarArchiverTests: XCTestCase {
104104
}
105105

106106
func testCompress() async throws {
107-
#if os(Linux)
107+
#if !os(Windows)
108108
guard SPM_posix_spawn_file_actions_addchdir_np_supported() else {
109109
throw XCTSkip("working directory not supported on this platform")
110110
}

Tests/BasicsTests/Archiver/UniversalArchiverTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ final class UniversalArchiverTests: XCTestCase {
135135
}
136136

137137
func testCompress() async throws {
138-
#if os(Linux)
138+
#if !os(Windows)
139139
guard SPM_posix_spawn_file_actions_addchdir_np_supported() else {
140140
throw XCTSkip("working directory not supported on this platform")
141141
}

Tests/BasicsTests/Archiver/ZipArchiverTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ final class ZipArchiverTests: XCTestCase {
112112
}
113113

114114
func testCompress() async throws {
115-
#if os(Linux)
115+
#if !os(Windows)
116116
guard SPM_posix_spawn_file_actions_addchdir_np_supported() else {
117117
throw XCTSkip("working directory not supported on this platform")
118118
}
@@ -178,4 +178,4 @@ final class ZipArchiverTests: XCTestCase {
178178
)
179179
}
180180
}
181-
}
181+
}

Tests/BasicsTests/AsyncProcessTests.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,7 @@ final class AsyncProcessTests: XCTestCase {
389389
}
390390

391391
func testWorkingDirectory() throws {
392-
guard #available(macOS 10.15, *) else {
393-
// Skip this test since it's not supported in this OS.
394-
return
395-
}
396-
397-
#if os(Linux) || os(Android)
392+
#if !os(Windows)
398393
guard SPM_posix_spawn_file_actions_addchdir_np_supported() else {
399394
// Skip this test since it's not supported in this OS.
400395
return

Tests/CommandsTests/PackageRegistryCommandTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ final class PackageRegistryCommandTests: CommandsTestCase {
334334
// TODO: Test example with login and password
335335

336336
func testArchiving() async throws {
337-
#if os(Linux)
337+
#if !os(Windows)
338338
// needed for archiving
339339
guard SPM_posix_spawn_file_actions_addchdir_np_supported() else {
340340
throw XCTSkip("working directory not supported on this platform")
@@ -457,7 +457,7 @@ final class PackageRegistryCommandTests: CommandsTestCase {
457457
}
458458

459459
func testPublishingToHTTPRegistry() throws {
460-
#if os(Linux)
460+
#if !os(Windows)
461461
// needed for archiving
462462
guard SPM_posix_spawn_file_actions_addchdir_np_supported() else {
463463
throw XCTSkip("working directory not supported on this platform")
@@ -499,7 +499,7 @@ final class PackageRegistryCommandTests: CommandsTestCase {
499499
}
500500

501501
func testPublishingToAllowedHTTPRegistry() async throws {
502-
#if os(Linux)
502+
#if !os(Windows)
503503
// needed for archiving
504504
guard SPM_posix_spawn_file_actions_addchdir_np_supported() else {
505505
throw XCTSkip("working directory not supported on this platform")
@@ -584,7 +584,7 @@ final class PackageRegistryCommandTests: CommandsTestCase {
584584
}
585585

586586
func testPublishingUnsignedPackage() throws {
587-
#if os(Linux)
587+
#if !os(Windows)
588588
// needed for archiving
589589
guard SPM_posix_spawn_file_actions_addchdir_np_supported() else {
590590
throw XCTSkip("working directory not supported on this platform")
@@ -749,7 +749,7 @@ final class PackageRegistryCommandTests: CommandsTestCase {
749749
"skipping because test environment doesn't support concurrency"
750750
)
751751

752-
#if os(Linux)
752+
#if !os(Windows)
753753
// needed for archiving
754754
guard SPM_posix_spawn_file_actions_addchdir_np_supported() else {
755755
throw XCTSkip("working directory not supported on this platform")

0 commit comments

Comments
 (0)