From 3d8596ed08bd13520157f0355e35caed215ffbfa Mon Sep 17 00:00:00 2001 From: Honza Dvorsky Date: Wed, 12 Mar 2025 12:48:26 +0100 Subject: [PATCH] Fix building on Fedora 39 and Ubuntu 24.04 (#354) ### Motivation: Fixes https://github.com/apple/swift-log/issues/278. ### Modifications: Fixed tests to successfully compile on Fedora 39 and Ubuntu 24.04, which they previously failed on. ### Result: Ability to run tests on these two platforms again. --- Tests/LoggingTests/LoggingTest.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Tests/LoggingTests/LoggingTest.swift b/Tests/LoggingTests/LoggingTest.swift index 141de3d..b75d7d2 100644 --- a/Tests/LoggingTests/LoggingTest.swift +++ b/Tests/LoggingTests/LoggingTest.swift @@ -1145,13 +1145,19 @@ class LoggingTest: XCTestCase { let err = _pipe($0.baseAddress, 256, _O_BINARY) XCTAssertEqual(err, 0, "_pipe failed \(err)") } - let writeFD = _fdopen(fds[1], "w") + guard let writeFD = _fdopen(fds[1], "w") else { + XCTFail("Failed to open file") + return + } #else fds.withUnsafeMutableBufferPointer { ptr in let err = pipe(ptr.baseAddress!) XCTAssertEqual(err, 0, "pipe failed \(err)") } - let writeFD = fdopen(fds[1], "w") + guard let writeFD = fdopen(fds[1], "w") else { + XCTFail("Failed to open file") + return + } #endif let writeBuffer = UnsafeMutablePointer.allocate(capacity: 256) @@ -1183,7 +1189,7 @@ class LoggingTest: XCTestCase { } // the actual test - body(writeFD!, readFD, readBuffer) + body(writeFD, readFD, readBuffer) for fd in fds { #if os(Windows)