Skip to content

Un-XFAIL TestURL #2166

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
Apr 24, 2019
Merged
Show file tree
Hide file tree
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
17 changes: 15 additions & 2 deletions TestFoundation/TestURL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class TestURL : XCTestCase {

}

static let gBaseTemporaryDirectoryPath = NSTemporaryDirectory()
static let gBaseTemporaryDirectoryPath = (NSTemporaryDirectory() as NSString).appendingPathComponent("org.swift.foundation.TestFoundation.TestURL.\(ProcessInfo.processInfo.processIdentifier)")
static var gBaseCurrentWorkingDirectoryPath : String {
return FileManager.default.currentDirectoryPath
}
Expand All @@ -239,6 +239,19 @@ class TestURL : XCTestCase {
static let gDirectoryExistsPath = gBaseTemporaryDirectoryPath + gDirectoryExistsName
static let gDirectoryDoesNotExistPath = gBaseTemporaryDirectoryPath + gDirectoryDoesNotExistName

override class func tearDown() {
let path = TestURL.gBaseTemporaryDirectoryPath
if (try? FileManager.default.attributesOfItem(atPath: path)) != nil {
do {
try FileManager.default.removeItem(atPath: path)
} catch {
NSLog("Could not remove test directory at path \(path): \(error)")
}
}

super.tearDown()
}

static func setup_test_paths() -> Bool {
_ = FileManager.default.createFile(atPath: gFileExistsPath, contents: nil)

Expand All @@ -255,7 +268,7 @@ class TestURL : XCTestCase {
try FileManager.default.createDirectory(atPath: gDirectoryExistsPath, withIntermediateDirectories: false)
} catch {
// The error code is a CocoaError
if (error as? NSError)?.code != CocoaError.fileNoSuchFile.rawValue {
if (error as? NSError)?.code != CocoaError.fileWriteFileExists.rawValue {
return false
}
}
Expand Down
6 changes: 1 addition & 5 deletions TestFoundation/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ var allTestCases = [
testCase(TestNSTextCheckingResult.allTests),
testCase(TestTimer.allTests),
testCase(TestTimeZone.allTests),
/* ⚠️ */ // testCase(TestURL.allTests),
testCase(TestURL.allTests),
testCase(TestURLComponents.allTests),
testCase(TestURLCredential.allTests),
testCase(TestURLProtectionSpace.allTests),
Expand Down Expand Up @@ -114,8 +114,4 @@ var allTestCases = [
testCase(TestNSLock.allTests),
]

appendTestCaseExpectedToFail("TestURL is not deleting its temporary directory correctly. https://bugs.swift.org/browse/SR-10538",
TestURL.allTests,
into: &allTestCases)

XCTMain(allTestCases)