11
11
import Basics
12
12
import Testing
13
13
14
+ // MARK: File System Helpers
15
+
16
+ /// Verifies that a file exists at the specified path.
17
+ ///
18
+ /// - Parameters:
19
+ /// - path: The absolute path to check for file existence.
20
+ /// - sourceLocation: The source location where the expectation is made.
14
21
public func expectFileExists(
15
22
at path: AbsolutePath ,
16
- _ comment: Comment ? = nil ,
17
23
sourceLocation: SourceLocation = #_sourceLocation,
18
24
) {
19
- let commentPrefix =
20
- if let comment {
21
- " \( comment) : "
22
- } else {
23
- " "
24
- }
25
- let msgSuffix : String
26
- do {
27
- msgSuffix = try " Directory contents: \( localFileSystem. getDirectoryContents ( path. parentDirectory) ) "
28
- } catch {
29
- msgSuffix = " "
30
- }
31
25
#expect(
32
26
localFileSystem. exists ( path) ,
33
- " \( commentPrefix ) File '\( path) ' does not exist. \( msgSuffix ) " ,
27
+ " Files '\( path) ' does not exist. " ,
34
28
sourceLocation: sourceLocation,
35
29
)
36
30
}
37
31
32
+ /// Verifies that a file does not exist at the specified path.
33
+ ///
34
+ /// - Parameters:
35
+ /// - fixturePath: The absolute path to check for file non-existence.
36
+ /// - comment: An optional comment to include in the failure message.
37
+ /// - sourceLocation: The source location where the expectation is made.
38
38
public func expectFileDoesNotExists (
39
39
at path: AbsolutePath,
40
40
_ comment: Comment? = nil ,
@@ -59,6 +59,12 @@ public func expectFileDoesNotExists(
59
59
)
60
60
}
61
61
62
+ /// Verifies that a file exists and is executable at the specified path.
63
+ ///
64
+ /// - Parameters:
65
+ /// - fixturePath: The absolute path to check for executable file existence.
66
+ /// - comment: An optional comment to include in the failure message.
67
+ /// - sourceLocation: The source location where the expectation is made.
62
68
public func expectFileIsExecutable(
63
69
at fixturePath: AbsolutePath,
64
70
_ comment: Comment? = nil ,
@@ -77,6 +83,11 @@ public func expectFileIsExecutable(
77
83
)
78
84
}
79
85
86
+ /// Verifies that a directory exists at the specified path.
87
+ ///
88
+ /// - Parameters:
89
+ /// - path: The absolute path to check for directory existence.
90
+ /// - sourceLocation: The source location where the expectation is made.
80
91
public func expectDirectoryExists (
81
92
at path: AbsolutePath,
82
93
sourceLocation: SourceLocation = #_sourceLocation,
@@ -94,6 +105,11 @@ let msgSuffix: String
94
105
)
95
106
}
96
107
108
+ /// Verifies that a directory does not exist at the specified path.
109
+ ///
110
+ /// - Parameters:
111
+ /// - path: The absolute path to check for directory non-existence.
112
+ /// - sourceLocation: The source location where the expectation is made.
97
113
public func expectDirectoryDoesNotExist (
98
114
at path: AbsolutePath,
99
115
sourceLocation: SourceLocation = #_sourceLocation,
0 commit comments