Skip to content

Commit 18ed7b6

Browse files
committed
Tests: empty folder
1 parent 7de7629 commit 18ed7b6

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Tests/SwiftDocCoverageTests/SwiftDocCoverageTests.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import XCTest
22
@testable import SwiftDocCoverage
33

4+
func tempDirectory() -> URL {
5+
let url = URL(fileURLWithPath: NSTemporaryDirectory())
6+
.appendingPathComponent(ProcessInfo.processInfo.globallyUniqueString)
7+
try? FileManager.default.createDirectory(at: url, withIntermediateDirectories: true)
8+
return url
9+
}
410

511
final class DeclarationTests: XCTestCase {
612

@@ -399,7 +405,10 @@ final class FileTests: XCTestCase {
399405
}
400406

401407
func test_empty_directory() throws {
402-
XCTAssertThrowsError(try Coverage(paths: [Self.emptyDirURL.path], minAccessLevel: .public)) { error in
408+
let tempDirectory = tempDirectory()
409+
defer { try? FileManager.default.removeItem(at: tempDirectory) }
410+
411+
XCTAssertThrowsError(try Coverage(paths: [tempDirectory.path], minAccessLevel: .public)) { error in
403412
XCTAssert(error.localizedDescription == "Swift files not found.")
404413
}
405414
}
@@ -492,7 +501,7 @@ final class ToolTests: XCTestCase {
492501
}
493502

494503
func test_file_output() throws {
495-
let tempDirectory = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(ProcessInfo.processInfo.globallyUniqueString)
504+
let tempDirectory = tempDirectory()
496505
let outputFileURL = tempDirectory.appendingPathComponent("report.txt")
497506
defer { try? FileManager.default.removeItem(at: tempDirectory) }
498507

0 commit comments

Comments
 (0)