Skip to content

TestFoundation: make test_fileDescriptor more portable #2244

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

Merged
merged 1 commit into from
May 10, 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
16 changes: 8 additions & 8 deletions TestFoundation/TestFileHandle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -356,17 +356,17 @@ class TestFileHandle : XCTestCase {
Thread.sleep(forTimeInterval: 0.001)
}
}


#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
func test_fileDescriptor() throws {
let handle = createFileHandle()
#if !os(Windows)
XCTAssertTrue(handle.fileDescriptor > 0, "File descriptor after opening should be valid (is \(handle.fileDescriptor))")
#endif

XCTAssertTrue(handle._isPlatformHandleValid, "File descriptor after opening should be valid")

try handle.close()
XCTAssertEqual(handle.fileDescriptor, -1, "File descriptor after closing should not be valid")
XCTAssertFalse(handle._isPlatformHandleValid, "File descriptor after closing should not be valid")
}

#endif

func test_availableData() {
let handle = createFileHandle()

Expand Down Expand Up @@ -498,7 +498,6 @@ class TestFileHandle : XCTestCase {
("test_truncateFile", test_truncateFile),
("test_readabilityHandlerCloseFileRace", test_readabilityHandlerCloseFileRace),
("test_readabilityHandlerCloseFileRaceWithError", test_readabilityHandlerCloseFileRaceWithError),
("test_fileDescriptor", test_fileDescriptor),
("test_availableData", test_availableData),
("test_readToEndOfFileInBackgroundAndNotify", test_readToEndOfFileInBackgroundAndNotify),
("test_readToEndOfFileAndNotify", test_readToEndOfFileAndNotify),
Expand All @@ -509,6 +508,7 @@ class TestFileHandle : XCTestCase {

#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
tests.append(contentsOf: [
("test_fileDescriptor", test_fileDescriptor),
("testHandleCreationAndCleanup", testHandleCreationAndCleanup),
("testOffset", testOffset),
])
Expand Down