@@ -267,6 +267,7 @@ import Testing
267
267
/// Verify that progress information is written to the progress file when specified.
268
268
@Test ( . testHomeMockedToolchain( ) ) func installProgressFile( ) async throws {
269
269
let progressFile = fs. mktemp ( ext: " .json " )
270
+ try await fs. create ( . mode( 0o644 ) , file: progressFile)
270
271
271
272
try await SwiftlyTests . runCommand ( Install . self, [
272
273
" install " , " 5.7.0 " ,
@@ -276,20 +277,27 @@ import Testing
276
277
277
278
#expect( try await fs. exists ( atPath: progressFile) )
278
279
280
+ let decoder = JSONDecoder ( )
279
281
let progressContent = try String ( contentsOfFile: progressFile. string)
280
- let lines = progressContent. components ( separatedBy: . newlines) . filter { !$0. isEmpty }
282
+ let progressInfo = try progressContent. split ( separator: " \n " )
283
+ . filter { !$0. isEmpty }
284
+ . map { line in
285
+ try decoder. decode ( ProgressInfo . self, from: Data ( line. utf8) )
286
+ }
281
287
282
- #expect( !lines . isEmpty, " Progress file should contain progress entries " )
288
+ #expect( !progressInfo . isEmpty, " Progress file should contain progress entries " )
283
289
284
- // Verify that at least one progress entry exists
285
- let hasProgressEntry = lines. contains { line in
286
- line. contains ( " \" step \" " ) && line. contains ( " \" percent \" " ) && line. contains ( " \" timestamp \" " )
290
+ // Verify that at least one step progress entry exists
291
+ let hasStepEntry = progressInfo. contains { info in
292
+ if case . step = info { return true }
293
+ return false
287
294
}
288
- #expect( hasProgressEntry , " Progress file should contain step progress entries " )
295
+ #expect( hasStepEntry , " Progress file should contain step progress entries " )
289
296
290
297
// Verify that a completion entry exists
291
- let hasCompletionEntry = lines. contains { line in
292
- line. contains ( " \" complete \" " ) && line. contains ( " \" success \" " )
298
+ let hasCompletionEntry = progressInfo. contains { info in
299
+ if case . complete = info { return true }
300
+ return false
293
301
}
294
302
#expect( hasCompletionEntry, " Progress file should contain completion entry " )
295
303
0 commit comments