2 files changed
+25
-13
lines changed@@ -236,7 +236,7 @@ func examineSnaps(
236
236
used []string,
237
237
runOnly string,
238
238
count int,
239
- update,
239
+ shouldUpdate,
240
240
sort bool,
241
241
) ([]string, bool, error) {
242
242
obsoleteTests := []string{}
@@ -251,7 +251,7 @@ func examineSnaps(
251
251
return nil, isDirty, err
252
252
}
253
253
254
- var hasDiffs bool
254
+ var needsUpdating bool
255
255
256
256
registeredTests := occurrences(registry[snapPath], count, snapshotOccurrenceFMT)
257
257
s := snapshotScanner(f)
@@ -267,7 +267,7 @@ func examineSnaps(
267
267
268
268
if !registeredTests.Has(testID) && !testSkipped(testID, runOnly) {
269
269
obsoleteTests = append(obsoleteTests, testID)
270
- hasDiffs = true
270
+ needsUpdating = true
271
271
272
272
removeSnapshot(s)
273
273
continue
@@ -292,13 +292,15 @@ func examineSnaps(
292
292
return nil, isDirty, err
293
293
}
294
294
295
- shouldSort := sort && !slices.IsSortedFunc(testIDs, naturalSort) && update
296
- shouldDelete := hasDiffs && update
295
+ needsSorting := sort && !slices.IsSortedFunc(testIDs, naturalSort)
297
296
298
- isDirty = isDirty || (sort && !slices.IsSortedFunc(testIDs, naturalSort)) || hasDiffs
297
+ // if we're not allowed to update anything, just capture if the snapshot
298
+ // needs cleaning, and then continue to the next snapshot
299
+ if !shouldUpdate {
300
+ if needsUpdating || needsSorting {
301
+ isDirty = true
302
+ }
299
303
300
- // if we don't have to "write" anything on the snap we skip
301
- if !shouldDelete && !shouldSort {
302
304
f.Close()
303
305
304
306
clear(tests)
@@ -308,7 +310,7 @@ func examineSnaps(
308
310
continue
309
311
}
310
312
311
- if shouldSort {
313
+ if needsSorting {
312
314
// sort testIDs
313
315
slices.SortFunc(testIDs, naturalSort)
314
316
}
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
220 | 220 |
| |
221 | 221 |
| |
222 | 222 |
| |
| 223 | + | |
| 224 | + | |
223 | 225 |
| |
224 | 226 |
| |
225 | 227 |
| |
| |||
276 | 278 |
| |
277 | 279 |
| |
278 | 280 |
| |
279 |
| - | |
| 281 | + | |
280 | 282 |
| |
281 | 283 |
| |
282 |
| - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
283 | 287 |
| |
284 | 288 |
| |
285 |
| - | |
| 289 | + | |
286 | 290 |
| |
287 | 291 |
| |
288 | 292 |
| |
| |||
306 | 310 |
| |
307 | 311 |
| |
308 | 312 |
| |
| 313 | + | |
309 | 314 |
| |
310 | 315 |
| |
311 |
| - | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
312 | 319 |
| |
313 | 320 |
| |
314 | 321 |
| |
| |||
347 | 354 |
| |
348 | 355 |
| |
349 | 356 |
| |
| 357 | + | |
350 | 358 |
| |
351 | 359 |
| |
| 360 | + | |
| 361 | + | |
352 | 362 |
| |
353 | 363 |
| |
354 | 364 |
| |
|
0 commit comments