@@ -208,6 +208,9 @@ class TestFileManager : XCTestCase {
208
208
func test_isReadableFile( ) {
209
209
let fm = FileManager . default
210
210
let path = NSTemporaryDirectory ( ) + " test_isReadableFile \( NSUUID ( ) . uuidString) "
211
+ defer {
212
+ try ? fm. removeItem ( atPath: path)
213
+ }
211
214
212
215
do {
213
216
// create test file
@@ -233,6 +236,9 @@ class TestFileManager : XCTestCase {
233
236
func test_isWritableFile( ) {
234
237
let fm = FileManager . default
235
238
let path = NSTemporaryDirectory ( ) + " test_isWritableFile \( NSUUID ( ) . uuidString) "
239
+ defer {
240
+ try ? fm. removeItem ( atPath: path)
241
+ }
236
242
237
243
do {
238
244
// create test file
@@ -253,6 +259,9 @@ class TestFileManager : XCTestCase {
253
259
func test_isExecutableFile( ) {
254
260
let fm = FileManager . default
255
261
let path = NSTemporaryDirectory ( ) + " test_isExecutableFile \( NSUUID ( ) . uuidString) "
262
+ defer {
263
+ try ? fm. removeItem ( atPath: path)
264
+ }
256
265
257
266
do {
258
267
// create test file
@@ -280,6 +289,9 @@ class TestFileManager : XCTestCase {
280
289
281
290
do {
282
291
let dir_path = NSTemporaryDirectory ( ) + " /test_isDeletableFile_dir/ "
292
+ defer {
293
+ try ? fm. removeItem ( atPath: dir_path)
294
+ }
283
295
let file_path = dir_path + " test_isDeletableFile \( NSUUID ( ) . uuidString) "
284
296
// create test directory
285
297
try fm. createDirectory ( atPath: dir_path, withIntermediateDirectories: true )
@@ -452,8 +464,9 @@ class TestFileManager : XCTestCase {
452
464
let itemPath = NSTemporaryDirectory ( ) + " \( testDirName) /item "
453
465
let basePath2 = NSTemporaryDirectory ( ) + " \( testDirName) /path2 "
454
466
let itemPath2 = NSTemporaryDirectory ( ) + " \( testDirName) /path2/item "
455
-
456
- try ? fm. removeItem ( atPath: basePath)
467
+ defer {
468
+ try ? fm. removeItem ( atPath: basePath)
469
+ }
457
470
458
471
do {
459
472
try fm. createDirectory ( atPath: basePath, withIntermediateDirectories: false , attributes: nil )
@@ -786,6 +799,10 @@ class TestFileManager : XCTestCase {
786
799
try ? fm. removeItem ( atPath: destPath)
787
800
}
788
801
802
+ defer {
803
+ cleanup ( )
804
+ }
805
+
789
806
func createDirectory( atPath path: String ) {
790
807
do {
791
808
try fm. createDirectory ( atPath: path, withIntermediateDirectories: false , attributes: nil )
0 commit comments