Skip to content

Commit 61295e4

Browse files
committed
Add Swift Testing helper functions
In the process of converted XCTests to Swift Testing, add a few Swift Testing helper functions equivalent to the XCTest equivalents. Unfortunately, the Swift Testing framework does not currently allow writing tests that verify an issue was recorded. swiftlang/swift-testing#155
1 parent ad2fc22 commit 61295e4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Testing
2+
3+
import TSCBasic
4+
5+
public func assertFileExists(_ path: AbsolutePath) {
6+
print("localFileSystem.isFile(path) ==> \(localFileSystem.isFile(path))")
7+
#expect(localFileSystem.isFile(path), "Expected file doesn't exist: \(path)")
8+
}
9+
public func assertDirectoryExists(_ path: AbsolutePath) {
10+
#expect(localFileSystem.isDirectory(path), "Expected directory doesn't exist: \(path)")
11+
}
12+
13+
public func assertNoDiagnostics(_ engine: DiagnosticsEngine) {
14+
let diagnostics = engine.diagnostics
15+
let diags = diagnostics.map({ "- " + $0.description }).joined(separator: "\n")
16+
#expect(diagnostics.isEmpty, "Found unexpected diagnostics: \n\(diags)")
17+
}

0 commit comments

Comments
 (0)