Skip to content

Commit ef5e907

Browse files
authored
Merge pull request #2166 from millenomi/unxfail-testurl
2 parents 221344d + 6f0c537 commit ef5e907

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

TestFoundation/TestURL.swift

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class TestURL : XCTestCase {
225225

226226
}
227227

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

242+
override class func tearDown() {
243+
let path = TestURL.gBaseTemporaryDirectoryPath
244+
if (try? FileManager.default.attributesOfItem(atPath: path)) != nil {
245+
do {
246+
try FileManager.default.removeItem(atPath: path)
247+
} catch {
248+
NSLog("Could not remove test directory at path \(path): \(error)")
249+
}
250+
}
251+
252+
super.tearDown()
253+
}
254+
242255
static func setup_test_paths() -> Bool {
243256
_ = FileManager.default.createFile(atPath: gFileExistsPath, contents: nil)
244257

@@ -255,7 +268,7 @@ class TestURL : XCTestCase {
255268
try FileManager.default.createDirectory(atPath: gDirectoryExistsPath, withIntermediateDirectories: false)
256269
} catch {
257270
// The error code is a CocoaError
258-
if (error as? NSError)?.code != CocoaError.fileNoSuchFile.rawValue {
271+
if (error as? NSError)?.code != CocoaError.fileWriteFileExists.rawValue {
259272
return false
260273
}
261274
}

TestFoundation/main.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ var allTestCases = [
8080
testCase(TestNSTextCheckingResult.allTests),
8181
testCase(TestTimer.allTests),
8282
testCase(TestTimeZone.allTests),
83-
/* ⚠️ */ // testCase(TestURL.allTests),
83+
testCase(TestURL.allTests),
8484
testCase(TestURLComponents.allTests),
8585
testCase(TestURLCredential.allTests),
8686
testCase(TestURLProtectionSpace.allTests),
@@ -114,8 +114,4 @@ var allTestCases = [
114114
testCase(TestNSLock.allTests),
115115
]
116116

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

0 commit comments

Comments
 (0)