Skip to content

Commit 553bd24

Browse files
committed
TestFoundation: make test_nullDevice test more portable
This makes test_nullDevice more portable so that we can run the test on Windows as well.
1 parent 120f749 commit 553bd24

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
@@ -281,10 +281,11 @@ class TestFileHandle : XCTestCase {
281281
"\(FileHandle.readCompletionNotification.rawValue) is not equal to NSFileHandleReadCompletionNotification")
282282
}
283283

284+
#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
284285
func test_nullDevice() {
285286
let fh = FileHandle.nullDevice
286287

287-
XCTAssertEqual(fh.fileDescriptor, -1)
288+
XCTAssertFalse(fh._isPlatformHandleValid)
288289
fh.closeFile()
289290
fh.seek(toFileOffset: 10)
290291
XCTAssertEqual(fh.offsetInFile, 0)
@@ -299,6 +300,7 @@ class TestFileHandle : XCTestCase {
299300
fh.seek(toFileOffset: 0)
300301
XCTAssertEqual(fh.readDataToEndOfFile().count, 0)
301302
}
303+
#endif
302304

303305
func test_truncateFile() {
304306
let url: URL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(ProcessInfo.processInfo.globallyUniqueString, isDirectory: false)
@@ -494,7 +496,6 @@ class TestFileHandle : XCTestCase {
494496
("testWritingWithBuffer", testWritingWithBuffer),
495497
("testWritingWithMultiregionData", testWritingWithMultiregionData),
496498
("test_constants", test_constants),
497-
("test_nullDevice", test_nullDevice),
498499
("test_truncateFile", test_truncateFile),
499500
("test_readabilityHandlerCloseFileRace", test_readabilityHandlerCloseFileRace),
500501
("test_readabilityHandlerCloseFileRaceWithError", test_readabilityHandlerCloseFileRaceWithError),
@@ -509,6 +510,7 @@ class TestFileHandle : XCTestCase {
509510

510511
#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
511512
tests.append(contentsOf: [
513+
("test_nullDevice", test_nullDevice),
512514
("testHandleCreationAndCleanup", testHandleCreationAndCleanup),
513515
("testOffset", testOffset),
514516
])

0 commit comments

Comments
 (0)