@@ -38,7 +38,7 @@ class TestNSFileManager : XCTestCase {
38
38
39
39
func test_createDirectory( ) {
40
40
let fm = NSFileManager . defaultManager ( )
41
- let path = " /tmp/testdir "
41
+ let path = " /tmp/testdir \( NSUUID ( ) . UUIDString ) "
42
42
43
43
ignoreError { try fm. removeItem ( atPath: path) }
44
44
@@ -63,7 +63,7 @@ class TestNSFileManager : XCTestCase {
63
63
64
64
func test_createFile( ) {
65
65
let fm = NSFileManager . defaultManager ( )
66
- let path = " /tmp/testfile "
66
+ let path = " /tmp/testfile \( NSUUID ( ) . UUIDString ) "
67
67
68
68
ignoreError { try fm. removeItem ( atPath: path) }
69
69
@@ -83,8 +83,8 @@ class TestNSFileManager : XCTestCase {
83
83
84
84
func test_moveFile( ) {
85
85
let fm = NSFileManager . defaultManager ( )
86
- let path = " /tmp/testfile "
87
- let path2 = " /tmp/testfile2 "
86
+ let path = " /tmp/testfile \( NSUUID ( ) . UUIDString ) "
87
+ let path2 = " /tmp/testfile2 \( NSUUID ( ) . UUIDString ) "
88
88
89
89
func cleanup( ) {
90
90
ignoreError { try fm. removeItem ( atPath: path) }
@@ -179,14 +179,21 @@ class TestNSFileManager : XCTestCase {
179
179
XCTAssert ( ( attributes [ NSFilePosixPermissions] as? NSNumber ) ? . int16Value == 0o0600 )
180
180
}
181
181
catch { XCTFail ( " \( error) " ) }
182
+
183
+ do {
184
+ try fm. removeItem ( atPath: path)
185
+ } catch {
186
+ XCTFail ( " Failed to clean up files " )
187
+ }
182
188
}
183
189
184
190
func test_pathEnumerator( ) {
185
191
let fm = NSFileManager . defaultManager ( )
186
- let basePath = " /tmp/testdir "
187
- let itemPath = " /tmp/testdir/item "
188
- let basePath2 = " /tmp/testdir/path2 "
189
- let itemPath2 = " /tmp/testdir/path2/item "
192
+ let testDirName = " testdir \( NSUUID ( ) . UUIDString) "
193
+ let basePath = " /tmp/ \( testDirName) "
194
+ let itemPath = " /tmp/ \( testDirName) /item "
195
+ let basePath2 = " /tmp/ \( testDirName) /path2 "
196
+ let itemPath2 = " /tmp/ \( testDirName) /path2/item "
190
197
191
198
ignoreError { try fm. removeItem ( atPath: basePath) }
192
199
@@ -215,8 +222,9 @@ class TestNSFileManager : XCTestCase {
215
222
216
223
func test_directoryEnumerator( ) {
217
224
let fm = NSFileManager . defaultManager ( )
218
- let path = " /tmp/testdir "
219
- let itemPath = " /tmp/testdir/item "
225
+ let testDirName = " testdir \( NSUUID ( ) . UUIDString) "
226
+ let path = " /tmp/ \( testDirName) "
227
+ let itemPath = " /tmp/ \( testDirName) /item "
220
228
221
229
ignoreError { try fm. removeItem ( atPath: path) }
222
230
@@ -239,8 +247,8 @@ class TestNSFileManager : XCTestCase {
239
247
XCTFail ( )
240
248
}
241
249
242
- let subDirPath = " /tmp/testdir /testdir2 "
243
- let subDirItemPath = " /tmp/testdir /testdir2/item "
250
+ let subDirPath = " /tmp/ \( testDirName ) /testdir2 "
251
+ let subDirItemPath = " /tmp/ \( testDirName ) /testdir2/item "
244
252
do {
245
253
try fm. createDirectory ( atPath: subDirPath, withIntermediateDirectories: false , attributes: nil )
246
254
fm. createFile ( atPath: subDirItemPath, contents: NSData ( ) , attributes: nil )
@@ -320,9 +328,10 @@ class TestNSFileManager : XCTestCase {
320
328
321
329
func test_contentsOfDirectoryAtPath( ) {
322
330
let fm = NSFileManager . defaultManager ( )
323
- let path = " /tmp/testdir "
324
- let itemPath1 = " /tmp/testdir/item "
325
- let itemPath2 = " /tmp/testdir/item2 "
331
+ let testDirName = " testdir \( NSUUID ( ) . UUIDString) "
332
+ let path = " /tmp/ \( testDirName) "
333
+ let itemPath1 = " /tmp/ \( testDirName) /item "
334
+ let itemPath2 = " /tmp/ \( testDirName) /item2 "
326
335
327
336
ignoreError { try fm. removeItem ( atPath: path) }
328
337
0 commit comments