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 {
1919 func write( into handle: FileHandle ) throws
2020}
2121
22+ private struct FailedToCreateFileError : Error {
23+ let url : URL
24+ }
25+
2226extension FileGenerator {
2327 /// Generates a file at the given URL, overwriting it if it already exists.
2428 func generateFile( at url: URL ) throws {
@@ -27,7 +31,9 @@ extension FileGenerator {
2731 try fm. removeItem ( at: url)
2832 }
2933
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+ }
3137 let handle = try FileHandle ( forWritingTo: url)
3238 defer { handle. closeFile ( ) }
3339
Original file line number Diff line number Diff line change @@ -70,7 +70,12 @@ extension FileIteratorTests {
7070 let fileURL = tmpURL ( path)
7171 try FileManager . default. createDirectory (
7272 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+ }
7479 }
7580
7681 /// 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