Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestFoundation: make test_nullDevice test more portable #2243

Merged
merged 1 commit into from
May 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions TestFoundation/TestFileHandle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,11 @@ class TestFileHandle : XCTestCase {
"\(FileHandle.readCompletionNotification.rawValue) is not equal to NSFileHandleReadCompletionNotification")
}

#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
func test_nullDevice() {
let fh = FileHandle.nullDevice

XCTAssertEqual(fh.fileDescriptor, -1)
XCTAssertFalse(fh._isPlatformHandleValid)
fh.closeFile()
fh.seek(toFileOffset: 10)
XCTAssertEqual(fh.offsetInFile, 0)
Expand All @@ -299,6 +300,7 @@ class TestFileHandle : XCTestCase {
fh.seek(toFileOffset: 0)
XCTAssertEqual(fh.readDataToEndOfFile().count, 0)
}
#endif

func test_truncateFile() {
let url: URL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(ProcessInfo.processInfo.globallyUniqueString, isDirectory: false)
Expand Down Expand Up @@ -494,7 +496,6 @@ class TestFileHandle : XCTestCase {
("testWritingWithBuffer", testWritingWithBuffer),
("testWritingWithMultiregionData", testWritingWithMultiregionData),
("test_constants", test_constants),
("test_nullDevice", test_nullDevice),
("test_truncateFile", test_truncateFile),
("test_readabilityHandlerCloseFileRace", test_readabilityHandlerCloseFileRace),
("test_readabilityHandlerCloseFileRaceWithError", test_readabilityHandlerCloseFileRaceWithError),
Expand All @@ -509,6 +510,7 @@ class TestFileHandle : XCTestCase {
#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
tests.append(contentsOf: [
("test_fileDescriptor", test_fileDescriptor),
("test_nullDevice", test_nullDevice),
("testHandleCreationAndCleanup", testHandleCreationAndCleanup),
("testOffset", testOffset),
])
Expand Down