Skip to content

Commit 06ea324

Browse files
committed
Fix ups based on review.
* Add test conditional Trait for detecting thread safe working directories. Issue present on Amazon linux * Get rid of 'nil' parameter to @test macro. * Remove all XCTest calls from Helpers.swift * Add known issues to the binaryTargets() test, which was previously unconditionally skipped. * Remove unused XCTest imports
1 parent d173abe commit 06ea324

File tree

5 files changed

+187
-153
lines changed

5 files changed

+187
-153
lines changed

Diff for: IntegrationTests/Sources/IntegrationTestSupport/Helpers.swift

+16-13
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
*/
1010

1111
import Foundation
12+
import Testing
1213
import TSCBasic
1314
import TSCTestSupport
14-
import XCTest
15-
1615
import enum TSCUtility.Git
1716

1817
public let sdkRoot: AbsolutePath? = {
@@ -136,10 +135,12 @@ public func sh(
136135
let stderr = try result.utf8stderrOutput()
137136

138137
if result.exitStatus != .terminated(code: 0) {
139-
XCTFail(
140-
"Command failed with exit code: \(result.exitStatus) - \(result.integrationTests_debugDescription)",
141-
file: file, line: line
142-
)
138+
Issue
139+
.record(
140+
Comment(
141+
"Command failed with exit code: \(result.exitStatus) - \(result.integrationTests_debugDescription)"
142+
)
143+
)
143144
}
144145

145146
return (stdout, stderr)
@@ -157,10 +158,12 @@ public func shFails(
157158
let stderr = try result.utf8stderrOutput()
158159

159160
if result.exitStatus == .terminated(code: 0) {
160-
XCTFail(
161-
"Command unexpectedly succeeded with exit code: \(result.exitStatus) - \(result.integrationTests_debugDescription)",
162-
file: file, line: line
163-
)
161+
Issue
162+
.record(
163+
Comment(
164+
"Command unexpectedly succeeded with exit code: \(result.exitStatus) - \(result.integrationTests_debugDescription)"
165+
)
166+
)
164167
}
165168

166169
return (stdout, stderr)
@@ -222,7 +225,7 @@ public func fixture(
222225

223226
// Check that the fixture is really there.
224227
guard localFileSystem.isDirectory(fixtureDir) else {
225-
XCTFail("No such fixture: \(fixtureDir)", file: file, line: line)
228+
Issue.record(Comment("No such fixture: \(fixtureDir)"))
226229
return
227230
}
228231

@@ -257,7 +260,7 @@ public func fixture(
257260
}
258261
}
259262
} catch {
260-
XCTFail("\(error)", file: file, line: line)
263+
Issue.record(error)
261264
}
262265
}
263266

@@ -302,7 +305,7 @@ public func initGitRepo(
302305
try systemQuietly([Git.tool, "-C", dir.pathString, "tag", tag])
303306
}
304307
} catch {
305-
XCTFail("\(error)", file: file, line: line)
308+
Issue.record(error)
306309
}
307310
}
308311

Diff for: IntegrationTests/Sources/IntegrationTestSupport/SkippedTestSupport.swift

+17-6
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,55 @@
99
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
1010
*/
1111

12+
import class Foundation.FileManager
1213
import class Foundation.ProcessInfo
1314
import Testing
1415

1516
extension Trait where Self == Testing.ConditionTrait {
16-
// Skip test if the host operating system does not match the running OS.
17+
/// Skip test if the host operating system does not match the running OS.
1718
public static func requireHostOS(_ os: OperatingSystem, when condition: Bool = true) -> Self {
1819
enabled("This test requires a \(os) host OS.") {
1920
ProcessInfo.hostOperatingSystem == os && condition
2021
}
2122
}
2223

23-
// Skip test if the host operating system matches the running OS.
24+
/// Skip test if the host operating system matches the running OS.
2425
public static func skipHostOS(_ os: OperatingSystem, _ comment: Comment? = nil) -> Self {
2526
disabled(comment ?? "This test cannot run on a \(os) host OS.") {
2627
ProcessInfo.hostOperatingSystem == os
2728
}
2829
}
2930

30-
// Skip test unconditionally
31+
/// Skip test unconditionally
3132
public static func skip(_ comment: Comment? = nil) -> Self {
3233
disabled(comment ?? "Unconditional skip, a comment should be added for the reason") { true }
3334
}
3435

35-
// Skip test if the environment is self hosted.
36+
/// Skip test if the environment is self hosted.
3637
public static func skipSwiftCISelfHosted(_ comment: Comment? = nil) -> Self {
3738
disabled(comment ?? "SwiftCI is self hosted") {
3839
ProcessInfo.processInfo.environment["SWIFTCI_IS_SELF_HOSTED"] != nil
3940
}
4041
}
4142

42-
// Skip test if built by XCode.
43+
/// Skip test if built by XCode.
4344
public static func skipIfXcodeBuilt() -> Self {
44-
disabled {
45+
disabled("Tests built by Xcode") {
4546
#if Xcode
4647
true
4748
#else
4849
false
4950
#endif
5051
}
5152
}
53+
54+
/// Constructs a condition trait that causes a test to be disabled if the Foundation process spawning implementation
55+
/// is not using `posix_spawn_file_actions_addchdir`.
56+
public static var requireThreadSafeWorkingDirectory: Self {
57+
disabled("Thread-safe process working directory support is unavailable.") {
58+
// Amazon Linux 2 has glibc 2.26, and glibc 2.29 is needed for posix_spawn_file_actions_addchdir_np support
59+
FileManager.default.contents(atPath: "/etc/system-release")
60+
.map { String(decoding: $0, as: UTF8.self) == "Amazon Linux release 2 (Karoo)\n" } ?? false
61+
}
62+
}
5263
}

Diff for: IntegrationTests/Sources/IntegrationTestSupport/StringChecker.swift

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
import Foundation
1212
import TSCTestSupport
13-
import XCTest
14-
1513
public class StringChecker {
1614
private let string: String
1715
private let lines: [Substring]

0 commit comments

Comments
 (0)