Skip to content

Commit 32ec786

Browse files
authored
Merge pull request swiftlang#2243 from compnerd/rube-goldberg-device
TestFoundation: make `test_nullDevice` test more portable
2 parents e339158 + 82b1744 commit 32ec786

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

TestFoundation/TestFileHandle.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,11 @@ class TestFileHandle : XCTestCase {
289289
"\(FileHandle.readCompletionNotification.rawValue) is not equal to NSFileHandleReadCompletionNotification")
290290
}
291291

292+
#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
292293
func test_nullDevice() {
293294
let fh = FileHandle.nullDevice
294295

295-
XCTAssertEqual(fh.fileDescriptor, -1)
296+
XCTAssertFalse(fh._isPlatformHandleValid)
296297
fh.closeFile()
297298
fh.seek(toFileOffset: 10)
298299
XCTAssertEqual(fh.offsetInFile, 0)
@@ -307,6 +308,7 @@ class TestFileHandle : XCTestCase {
307308
fh.seek(toFileOffset: 0)
308309
XCTAssertEqual(fh.readDataToEndOfFile().count, 0)
309310
}
311+
#endif
310312

311313
func test_truncateFile() {
312314
let url: URL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(ProcessInfo.processInfo.globallyUniqueString, isDirectory: false)
@@ -502,7 +504,6 @@ class TestFileHandle : XCTestCase {
502504
("testWritingWithBuffer", testWritingWithBuffer),
503505
("testWritingWithMultiregionData", testWritingWithMultiregionData),
504506
("test_constants", test_constants),
505-
("test_nullDevice", test_nullDevice),
506507
("test_truncateFile", test_truncateFile),
507508
("test_readabilityHandlerCloseFileRace", test_readabilityHandlerCloseFileRace),
508509
("test_readabilityHandlerCloseFileRaceWithError", test_readabilityHandlerCloseFileRaceWithError),
@@ -518,6 +519,7 @@ class TestFileHandle : XCTestCase {
518519
#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
519520
tests.append(contentsOf: [
520521
("test_fileDescriptor", test_fileDescriptor),
522+
("test_nullDevice", test_nullDevice),
521523
("testHandleCreationAndCleanup", testHandleCreationAndCleanup),
522524
("testOffset", testOffset),
523525
])

0 commit comments

Comments
 (0)