Skip to content

Commit 35a4a08

Browse files
committed
Improve tests (and maybe more) to assure parallel worktree tests are deterministic
At least so that tests deal with hardly avoidable non-determinism and there are no spurious failures.
1 parent ba5ec87 commit 35a4a08

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

gix-worktree/tests/worktree/checkout.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ fn keep_going_collects_results() {
256256
opts,
257257
"make_mixed_without_submodules",
258258
|_id| {
259+
dbg!(_id);
259260
!matches!(
260261
count.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |current| {
261262
(current < 2).then_some(current + 1)
@@ -290,7 +291,11 @@ fn keep_going_collects_results() {
290291
}
291292

292293
if multi_threaded() {
293-
assert_eq!(dir_structure(&destination).len(), 3);
294+
let actual = dir_structure(&destination);
295+
if actual.len() != 3 {
296+
dbg!(destination.into_path());
297+
}
298+
assert_eq!(actual.len(), 3);
294299
} else {
295300
assert_eq!(
296301
stripped_prefix(&destination, &dir_structure(&destination)),
@@ -336,6 +341,7 @@ fn collisions_are_detected_on_a_case_insensitive_filesystem_even_with_delayed_fi
336341
eprintln!("Skipping case-insensitive testing on what would be a case-sensitive file system");
337342
return;
338343
}
344+
assert_eq!(opts.keep_going, false);
339345
setup_filter_pipeline(opts.filters.options_mut());
340346
opts.filter_process_delay = gix_filter::driver::apply::Delay::Allow;
341347
let (source_tree, destination, _index, outcome) =
@@ -350,10 +356,9 @@ fn collisions_are_detected_on_a_case_insensitive_filesystem_even_with_delayed_fi
350356

351357
let dest_files = dir_structure(&destination);
352358
if multi_threaded() {
353-
assert_eq!(
354-
dest_files.len(),
355-
5,
356-
"can only assert on number as it's racily creating files so unclear which one clashes"
359+
assert!(
360+
dest_files.len() <= 6,
361+
"can only assert on vague number as it's racily creating files, with the collision stopping the operation at any time"
357362
);
358363
} else {
359364
assert_eq!(
@@ -370,10 +375,9 @@ fn collisions_are_detected_on_a_case_insensitive_filesystem_even_with_delayed_fi
370375
let error_kind_dir = error_kind;
371376

372377
if multi_threaded() {
373-
assert_eq!(
374-
outcome.collisions.len(),
375-
5,
376-
"can only assert on number as it's racily creating files so unclear which one clashes"
378+
assert!(
379+
outcome.collisions.len() <= 6,
380+
"can only assert on number as it's racily creating files so unclear which one clashes and how many it sees - keep-going is false"
377381
);
378382
} else {
379383
assert_eq!(
@@ -477,6 +481,7 @@ fn checkout_index_in_tmp_dir_opts(
477481
if allow_return_object(oid) {
478482
odb.find_blob(oid, buf)
479483
} else {
484+
dbg!(oid);
480485
Err(gix_odb::find::existing_object::Error::NotFound { oid: oid.to_owned() })
481486
}
482487
},

0 commit comments

Comments
 (0)