Skip to content

Commit 0f5aac0

Browse files
committed
[Tests] Convert InitTests to Swift Testing
1 parent ab60142 commit 0f5aac0

File tree

2 files changed

+361
-397
lines changed

2 files changed

+361
-397
lines changed

Sources/_InternalTestSupport/SwiftTesting+Helpers.swift

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,30 @@
1111
import Basics
1212
import Testing
1313

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.
1421
public func expectFileExists(
1522
at path: AbsolutePath,
16-
_ comment: Comment? = nil,
1723
sourceLocation: SourceLocation = #_sourceLocation,
1824
) {
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-
}
3125
#expect(
3226
localFileSystem.exists(path),
33-
"\(commentPrefix)File '\(path)' does not exist. \(msgSuffix)",
27+
"Files '\(path)' does not exist.",
3428
sourceLocation: sourceLocation,
3529
)
3630
}
3731

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.
3838
public func expectFileDoesNotExists(
3939
at path: AbsolutePath,
4040
_ comment: Comment? = nil,
@@ -59,6 +59,12 @@ public func expectFileDoesNotExists(
5959
)
6060
}
6161

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.
6268
public func expectFileIsExecutable(
6369
at fixturePath: AbsolutePath,
6470
_ comment: Comment? = nil,
@@ -77,6 +83,11 @@ public func expectFileIsExecutable(
7783
)
7884
}
7985

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.
8091
public func expectDirectoryExists(
8192
at path: AbsolutePath,
8293
sourceLocation: SourceLocation = #_sourceLocation,
@@ -94,6 +105,11 @@ let msgSuffix: String
94105
)
95106
}
96107

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.
97113
public func expectDirectoryDoesNotExist(
98114
at path: AbsolutePath,
99115
sourceLocation: SourceLocation = #_sourceLocation,

0 commit comments

Comments
 (0)