@@ -36,9 +36,8 @@ public extension XCTestCase {
36
36
///
37
37
/// - Parameters:
38
38
/// - pathComponents: The name of the temporary directory.
39
- /// - fileManager: The file manager that will create the directory.
40
39
/// - Returns: The URL of the newly created directory.
41
- func createTemporaryDirectory( named: String , fileManager : FileManager = . default ) throws -> URL {
40
+ func createTemporaryDirectory( named: String ) throws -> URL {
42
41
try createTemporaryDirectory ( pathComponents: named)
43
42
}
44
43
@@ -48,9 +47,8 @@ public extension XCTestCase {
48
47
///
49
48
/// - Parameters:
50
49
/// - pathComponents: Additional path components to add to the temporary URL.
51
- /// - fileManager: The file manager that will create the directory.
52
50
/// - Returns: The URL of the newly created directory.
53
- func createTemporaryDirectory( pathComponents: String ... , fileManager : FileManager = . default ) throws -> URL {
51
+ func createTemporaryDirectory( pathComponents: String ... ) throws -> URL {
54
52
let bundleParentDir = Bundle ( for: Self . self) . bundleURL. deletingLastPathComponent ( )
55
53
let baseURL = bundleParentDir. appendingPathComponent ( name. replacingWhitespaceAndPunctuation ( with: " - " ) )
56
54
@@ -62,20 +60,20 @@ public extension XCTestCase {
62
60
63
61
addTeardownBlock {
64
62
do {
65
- if fileManager . fileExists ( atPath: baseURL. path) {
66
- try fileManager . removeItem ( at: baseURL)
63
+ if FileManager . default . fileExists ( atPath: baseURL. path) {
64
+ try FileManager . default . removeItem ( at: baseURL)
67
65
}
68
66
} catch {
69
67
XCTFail ( " Failed to remove temporary directory: ' \( error) ' " )
70
68
}
71
69
}
72
70
73
- if !fileManager . fileExists ( atPath: bundleParentDir. path) {
71
+ if !FileManager . default . fileExists ( atPath: bundleParentDir. path) {
74
72
// Create the base URL directory without intermediate directories so that an error is raised if the parent directory doesn't exist.
75
- try fileManager . createDirectory ( at: baseURL, withIntermediateDirectories: false , attributes: nil )
73
+ try FileManager . default . createDirectory ( at: baseURL, withIntermediateDirectories: false , attributes: nil )
76
74
}
77
75
78
- try fileManager . createDirectory ( at: tempURL, withIntermediateDirectories: true , attributes: nil )
76
+ try FileManager . default . createDirectory ( at: tempURL, withIntermediateDirectories: true , attributes: nil )
79
77
80
78
return tempURL
81
79
}
0 commit comments