Skip to content

Commit

Permalink
Tests: disable the LogHandle tests on Windows (#634)
Browse files Browse the repository at this point in the history
`FileHandle` transacts in `HANDLE`s on Windows rather than file
descriptors.  This makes it impossible to replace the end point of the
pipe after it has been created as the conversion from a HANDLE to a file
descriptor transfers ownership and as such the FileHandle does not work
with file descriptors at all.  Replicating that behaviour here would
detach the `FileHandle` associated with the `Pipe` and thus cannot be
done inline.
  • Loading branch information
compnerd committed Jun 22, 2023
1 parent 77623b8 commit 4fb746b
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Tests/SwiftDocCUtilitiesTests/Utility/LogHandleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class LogHandleTests: XCTestCase {

/// Test that ``LogHandle`` doesn't append extra newlines to output
/// - Bug: rdar://73462272
func testWriteToStandardOutput() {
func testWriteToStandardOutput() throws {
#if os(Windows)
throw XCTSkip("cannot reassign file handles on Windows")
#else
let pipe = Pipe()

// dup stdout to restore later
Expand Down Expand Up @@ -50,9 +53,13 @@ class LogHandleTests: XCTestCase {
========================================
"""
)
#endif
}

func testFlushesStandardOutput() {
func testFlushesStandardOutput() throws {
#if os(Windows)
throw XCTSkip("cannot reassign file handles on Windows")
#else
let pipe = Pipe()

// dup stdout to restore later
Expand All @@ -67,9 +74,13 @@ class LogHandleTests: XCTestCase {
let data = pipe.fileHandleForReading.availableData
let text = String(data: data, encoding: .utf8)
XCTAssertEqual(text, "No newlines here", "\(LogHandle.self) didn't flush stdout")
#endif
}

func testFlushesStandardError() {
func testFlushesStandardError() throws {
#if os(Windows)
throw XCTSkip("cannot reassign file handles on Windows")
#else
let pipe = Pipe()

// dup stdout to restore later
Expand All @@ -84,5 +95,6 @@ class LogHandleTests: XCTestCase {
let data = pipe.fileHandleForReading.availableData
let text = String(data: data, encoding: .utf8)
XCTAssertEqual(text, "No newlines here", "\(LogHandle.self) didn't flush stderr")
#endif
}
}

0 comments on commit 4fb746b

Please sign in to comment.