|
| 1 | +/* |
| 2 | + This source file is part of the Swift.org open source project |
| 3 | + |
| 4 | + Copyright (c) 2024 Apple Inc. and the Swift project authors |
| 5 | + Licensed under Apache License v2.0 with Runtime Library Exception |
| 6 | + |
| 7 | + See http://swift.org/LICENSE.txt for license information |
| 8 | + See http://swift.org/CONTRIBUTORS.txt for Swift project authors |
| 9 | +*/ |
| 10 | + |
| 11 | +import Testing |
| 12 | + |
| 13 | +import TSCBasic |
| 14 | + |
| 15 | +public func assertFileExists( |
| 16 | + _ path: AbsolutePath, |
| 17 | + sourceLocation: SourceLocation = #_sourceLocation |
| 18 | +) { |
| 19 | + print("localFileSystem.isFile(path) ==> \(localFileSystem.isFile(path))") |
| 20 | + #expect( |
| 21 | + localFileSystem.isFile(path), |
| 22 | + "Expected file doesn't exist: \(path)", |
| 23 | + sourceLocation: sourceLocation |
| 24 | + ) |
| 25 | +} |
| 26 | +public func assertDirectoryExists( |
| 27 | + _ path: AbsolutePath, |
| 28 | + sourceLocation: SourceLocation = #_sourceLocation |
| 29 | +) { |
| 30 | + #expect( |
| 31 | + localFileSystem.isDirectory(path), |
| 32 | + "Expected directory doesn't exist: \(path)", |
| 33 | + sourceLocation: sourceLocation |
| 34 | + ) |
| 35 | +} |
| 36 | + |
| 37 | +public func assertNoDiagnostics( |
| 38 | + _ engine: DiagnosticsEngine, |
| 39 | + sourceLocation: SourceLocation = #_sourceLocation |
| 40 | +) { |
| 41 | + let diagnostics = engine.diagnostics |
| 42 | + let diags = diagnostics.map({ "- " + $0.description }).joined(separator: "\n") |
| 43 | + #expect( |
| 44 | + diagnostics.isEmpty, |
| 45 | + "Found unexpected diagnostics: \n\(diags)", |
| 46 | + sourceLocation: sourceLocation |
| 47 | + ) |
| 48 | +} |
0 commit comments