File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Sources/generate-swift-format
Tests/swift-formatTests/Utilities Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ protocol FileGenerator {
19
19
func write( into handle: FileHandle ) throws
20
20
}
21
21
22
+ private struct FailedToCreateFileError : Error {
23
+ let url : URL
24
+ }
25
+
22
26
extension FileGenerator {
23
27
/// Generates a file at the given URL, overwriting it if it already exists.
24
28
func generateFile( at url: URL ) throws {
@@ -27,7 +31,9 @@ extension FileGenerator {
27
31
try fm. removeItem ( at: url)
28
32
}
29
33
30
- fm. createFile ( atPath: url. path, contents: nil , attributes: nil )
34
+ if !fm. createFile ( atPath: url. path, contents: nil , attributes: nil ) {
35
+ throw FailedToCreateFileError ( url: url)
36
+ }
31
37
let handle = try FileHandle ( forWritingTo: url)
32
38
defer { handle. closeFile ( ) }
33
39
Original file line number Diff line number Diff line change @@ -70,7 +70,12 @@ extension FileIteratorTests {
70
70
let fileURL = tmpURL ( path)
71
71
try FileManager . default. createDirectory (
72
72
at: fileURL. deletingLastPathComponent ( ) , withIntermediateDirectories: true )
73
- FileManager . default. createFile ( atPath: fileURL. path, contents: Data ( ) )
73
+ struct FailedToCreateFileError : Error {
74
+ let url : URL
75
+ }
76
+ if !FileManager. default. createFile ( atPath: fileURL. path, contents: Data ( ) ) {
77
+ throw FailedToCreateFileError ( url: fileURL)
78
+ }
74
79
}
75
80
76
81
/// Create a symlink between files or directories in the test's temporary space.
You can’t perform that action at this time.
0 commit comments