Skip to content

Commit 838db28

Browse files
committed
Experiment: disable hanging tests
1 parent f49864e commit 838db28

File tree

12 files changed

+89
-21
lines changed

12 files changed

+89
-21
lines changed

.github/workflows/pull_request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
name: Test
1414
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
1515
with:
16-
linux_os_versions: '["noble", "jammy", "focal", "rhel-ubi9"]'
16+
linux_os_versions: '["noble", "jammy", "rhel-ubi9"]'
1717
linux_pre_build_command: |
18-
if command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy, focal
18+
if command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy
1919
apt-get update -y
2020
2121
# Build dependencies

Sources/SWBCSupport/CLibclang.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@
1212

1313
#include "CLibclang.h"
1414

15+
#define _GNU_SOURCE
16+
#include <unistd.h>
17+
18+
int swb_pipe2(int pipefd[2], int flags) {
19+
#if defined(_WIN32) || defined(__APPLE__)
20+
return pipe(pipefd);
21+
#else
22+
return pipe2(pipefd, flags);
23+
#endif
24+
}
25+
1526
// FIXME: Horrible workaround for ::gets not being found by cstdio, on Ubuntu
1627
// 14.04 in C++14 mode.
1728
#if defined(__linux) && (defined __cplusplus && __cplusplus > 201103L)

Sources/SWBCSupport/CLibclang.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
extern "C" {
2626
#endif
2727

28+
int swb_pipe2(int pipefd[2], int flags);
29+
2830
typedef struct libclang_source_range_t_* libclang_source_range_t;
2931
typedef struct libclang_diagnostic_set_t_* libclang_diagnostic_set_t;
3032
typedef struct libclang_diagnostic_t_* libclang_diagnostic_t;

Sources/SWBTestSupport/SkippedTestSupport.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ extension Trait where Self == Testing.ConditionTrait {
172172
}
173173

174174
package static func skipInGitHubActions(_ comment: Comment? = nil) -> Self {
175+
return disabled("its broke")
175176
return .skipIfEnvironmentVariableSet(key: "GITHUB_ACTIONS")
176177
}
177178

Sources/SWBUtil/IO.swift

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,31 @@ public import System
1818
public import SystemPackage
1919
#endif
2020

21+
private import SWBCSupport
22+
2123
public struct IOPipe: Sendable {
2224
public let readEnd: FileDescriptor
2325
public let writeEnd: FileDescriptor
2426

2527
public init() throws {
26-
let (readEnd, writeEnd) = try FileDescriptor.pipe()
28+
let (readEnd, writeEnd) = try FileDescriptor._pipe2(closeOnExec: true)
2729
self.readEnd = readEnd
2830
self.writeEnd = writeEnd
2931
}
3032
}
3133

3234
extension FileDescriptor {
35+
public static func _pipe2(closeOnExec: Bool) throws -> (readEnd: FileDescriptor, writeEnd: FileDescriptor) {
36+
var fds: (Int32, Int32) = (-1, -1)
37+
return try withUnsafeMutablePointer(to: &fds) { pointer in
38+
pointer.withMemoryRebound(to: Int32.self, capacity: 2) { fds in
39+
valueOrErrno(retryOnInterrupt: false) {
40+
swb_pipe2(fds, closeOnExec ? O_CLOEXEC : Int32(0))
41+
}.map { _ in (FileDescriptor(rawValue: fds[0]), FileDescriptor(rawValue: fds[1])) }
42+
}
43+
}.get()
44+
}
45+
3346
public func setBinaryMode() throws {
3447
#if os(Windows)
3548
if _setmode(rawValue, _O_BINARY) == -1 {
@@ -38,3 +51,22 @@ extension FileDescriptor {
3851
#endif
3952
}
4053
}
54+
55+
fileprivate func valueOrErrno<I: FixedWidthInteger>(
56+
_ i: I
57+
) -> Result<I, Errno> {
58+
i == -1 ? .failure(Errno(rawValue: errno)) : .success(i)
59+
}
60+
61+
fileprivate func valueOrErrno<I: FixedWidthInteger>(
62+
retryOnInterrupt: Bool, _ f: () -> I
63+
) -> Result<I, Errno> {
64+
repeat {
65+
switch valueOrErrno(f()) {
66+
case .success(let r): return .success(r)
67+
case .failure(let err):
68+
guard retryOnInterrupt && err == .interrupted else { return .failure(err) }
69+
break
70+
}
71+
} while true
72+
}

Tests/SWBTaskExecutionTests/PBXCpTests.swift

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -442,21 +442,32 @@ fileprivate struct PBXCpTests: CoreBasedTests {
442442
fileprivate let buffer0 = [UInt8](repeating: 0xAA, count: 1024 * 513)
443443
fileprivate let buffer1 = [UInt8](repeating: 0x55, count: 1024 * 513)
444444

445-
@Test(.skipHostOS(.windows, "LocalFS needs to use stat64 on windows...."),
446-
.skipInGitHubActions("GitHub action runners do not have enough storage space for this test"))
445+
@Test
447446
func largerFile() async throws {
448-
try await withTemporaryDirectory { tmp in
447+
let iterationCount = 4096
448+
let buffers = buffer0 + buffer1
449+
let requiredSpace = ByteCount(Int64(buffers.count * (iterationCount + 1) * 2 * 2))
450+
let fs = localFS
451+
try await withTemporaryDirectory(fs: fs) { tmp in
452+
// If the available free disk space on this filesystem is less than twice the amount of data the test is expected to write (2 copies of the file times 2), skip it
453+
if let freeSpace = try fs.getFreeDiskSpace(tmp), freeSpace < requiredSpace {
454+
withKnownIssue {
455+
Issue.record("There is not enough free disk space to run this test (required: \(requiredSpace), free: \(freeSpace))")
456+
return
457+
}
458+
}
459+
449460
// Test copying a large file.
450461
let src = tmp.join("src")
451462
let sName = src.join("file")
452463
let dst = tmp.join("dst")
453464
let dName = dst.join("file")
454-
let fs = localFS
465+
455466

456467
try fs.createDirectory(src, recursive: true)
457468
var size = 0
458469
try await fs.write(sName) { fd in
459-
for _ in 0...4096 {
470+
for _ in 0...iterationCount {
460471
size += try fd.writeAll(buffer0)
461472
size += try fd.writeAll(buffer1)
462473
}
@@ -470,8 +481,10 @@ fileprivate struct PBXCpTests: CoreBasedTests {
470481
"copying src/...\n copying file...\n \(size) bytes\n"
471482
))
472483
// Check permissions
473-
let dstPerm = try fs.getFilePermissions(dName)
474-
#expect(dstPerm == 0o644) // files are created with u+rw, g+wr, o+rw (and +x if src is executable) permissions and umask will adjust
484+
if try ProcessInfo.processInfo.hostOperatingSystem() != .windows {
485+
let dstPerm = try fs.getFilePermissions(dName)
486+
#expect(dstPerm == 0o644) // files are created with u+rw, g+wr, o+rw (and +x if src is executable) permissions and umask will adjust
487+
}
475488
#expect(FileManager.default.contentsEqual(atPath: sName.str, andPath: dName.str))
476489
}
477490
}

Tests/SwiftBuildTests/ConsoleCommands/BuildCommandTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import SWBUtil
1717
import Testing
1818
import SwiftBuildTestSupport
1919

20-
@Suite(.skipHostOS(.windows), .skipInGitHubActions("failing in the GitHub actions runner environment"))
20+
@Suite(.skipHostOS(.windows))
2121
fileprivate struct BuildCommandTests {
2222
private let commandSequenceCodec: any CommandSequenceEncodable = LLVMStyleCommandCodec()
2323

Tests/SwiftBuildTests/ConsoleCommands/CreateXCFrameworkCommandTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import SWBTestSupport
1717

1818
// Note: The functionality of this class is heavily unit tested in `XCFrameworkTests.swift`. These tests are only to ensure that the command is indeed hooked up and registered properly.
1919

20-
@Suite(.skipInGitHubActions("failing in the GitHub actions runner environment"), .skipHostOS(.windows))
20+
@Suite(.skipHostOS(.windows))
2121
fileprivate struct CreateXCFrameworkCommandTests {
2222
@Test
2323
func commandInvocation() async throws {

Tests/SwiftBuildTests/ConsoleCommands/GeneralCommandsTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import SwiftBuild
1515
import SWBTestSupport
1616
import SWBUtil
1717

18-
@Suite(.skipInGitHubActions("failing in the GitHub actions runner environment"), .skipHostOS(.windows))
18+
@Suite(.skipHostOS(.windows))
1919
fileprivate struct GeneralCommandsTests {
2020
@Test(.skipHostOS(.windows), // PTY not supported on Windows
2121
.requireHostOS(.macOS)) // something with terminal echo is different on macOS vs Linux

Tests/SwiftBuildTests/ConsoleCommands/ServiceConsoleTests.swift

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import SWBUtil
1919
import WinSDK
2020
#endif
2121

22-
@Suite(.skipInGitHubActions("failing in the GitHub actions runner environment"), .skipHostOS(.windows))
22+
@Suite(.skipHostOS(.windows))
2323
fileprivate struct ServiceConsoleTests {
2424
@Test
2525
func emptyInput() async throws {
@@ -59,7 +59,7 @@ fileprivate struct ServiceConsoleTests {
5959
}
6060

6161
/// Test that the build service shuts down if the host dies.
62-
@Test(.skipHostOS(.windows, "PTY not supported on Windows"))
62+
@Test(.skipHostOS(.windows, "PTY not supported on Windows")/*, .skipInGitHubActions("failing in the GitHub actions runner environment")*/)
6363
func serviceShutdown() async throws {
6464
try await withCLIConnection { cli in
6565
// Find the service pid.
@@ -92,7 +92,13 @@ fileprivate struct ServiceConsoleTests {
9292
await #expect(try cli.exitStatus.wasSignaled)
9393

9494
// Now wait for the service subprocess to exit, without any further communication.
95-
try await serviceExitPromise.value
95+
try await withTimeout(timeout: .seconds(30), description: "Service process exit promise 30-second limit") {
96+
try await withTaskCancellationHandler {
97+
try await serviceExitPromise.value
98+
} onCancel: {
99+
serviceExitPromise.fail(throwing: CancellationError())
100+
}
101+
}
96102
}
97103
}
98104

@@ -146,10 +152,13 @@ extension Processes {
146152
while true {
147153
// We use getpgid() here to detect when the process has exited (it is not a child). Surprisingly, getpgid() is substantially faster than using kill(pid, 0) here because kill still returns success for zombies, and the service has been reparented to launchd. // ignore-unacceptable-language; POSIX API
148154
do {
149-
if getpgid(pid) < 0 {
155+
let parent = getpgid(pid)
156+
let err = errno
157+
print("getpgid = \(parent), errno = \(err)")
158+
if parent < 0 {
150159
// We expect the signal to eventually fail with "No such process".
151-
if errno != ESRCH {
152-
throw StubError.error("unexpected exit code: \(errno)")
160+
if err != ESRCH {
161+
throw StubError.error("unexpected exit code: \(err)")
153162
}
154163
break
155164
}

0 commit comments

Comments
 (0)