@@ -76,22 +76,26 @@ enum RunLineParser {
76
76
pattern: " \( escapedPrefix) \\ s*([ \\ w-]+):(.*)$ " ,
77
77
options: [ . anchorsMatchLines] )
78
78
var lines = [ RunLine] ( )
79
- let contents = try String ( contentsOf: file, encoding: . utf8)
80
- let nsString = NSString ( string: contents)
81
- let range = NSRange ( location: 0 , length: nsString. length)
82
- for match in regex. matches ( in: contents, range: range) {
83
- let command = nsString. substring ( with: match. range ( at: 1 ) )
84
- let runLine = nsString. substring ( with: match. range ( at: 2 ) )
85
- . trimmingCharacters ( in: . whitespaces)
86
- if runLine. isEmpty { continue }
87
- let mode : RunLine . Mode
88
- switch command {
89
- case " RUN " : mode = . run
90
- case " RUN-NOT " : mode = . runNot
91
- case " RUN-XFAIL " : mode = . runXfail
92
- default : continue
79
+ switch Result ( catching: { try String ( contentsOf: file, encoding: . utf8) } ) {
80
+ case . failure( _) :
81
+ print ( " ⚠️ could not open ' \( file. path) '; skipping test " )
82
+ case let . success( contents) :
83
+ let nsString = NSString ( string: contents)
84
+ let range = NSRange ( location: 0 , length: nsString. length)
85
+ for match in regex. matches ( in: contents, range: range) {
86
+ let command = nsString. substring ( with: match. range ( at: 1 ) )
87
+ let runLine = nsString. substring ( with: match. range ( at: 2 ) )
88
+ . trimmingCharacters ( in: . whitespaces)
89
+ if runLine. isEmpty { continue }
90
+ let mode : RunLine . Mode
91
+ switch command {
92
+ case " RUN " : mode = . run
93
+ case " RUN-NOT " : mode = . runNot
94
+ case " RUN-XFAIL " : mode = . runXfail
95
+ default : continue
96
+ }
97
+ lines. append ( RunLine ( mode: mode, commandLine: runLine) )
93
98
}
94
- lines. append ( RunLine ( mode: mode, commandLine: runLine) )
95
99
}
96
100
return lines
97
101
}
0 commit comments