From dabfd04da6fe84e87c116514e76b13fb4e674fe0 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Wed, 9 Feb 2022 10:40:51 -0800 Subject: [PATCH] tests: attempt to de-flake operation-merging test We resolve checkouts in favor of the first-committed operation (which is more likely to have managed to update the working copy). The test case has been flaky on GitHub lately. I've run it 1000 times on my machine without failure. I don't know if GitHub's machines are just faster in some way (SSD, maybe) that makes them finish the two operations in the test in the same millisecond. Let's add a 1-millisecond sleep to see if that helps. If it doesn't, then maybe the issue is that the clock has lower precision (or their clocks can go backwards?). --- lib/tests/test_view.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/tests/test_view.rs b/lib/tests/test_view.rs index 4dc6582f6..411ab1403 100644 --- a/lib/tests/test_view.rs +++ b/lib/tests/test_view.rs @@ -210,6 +210,9 @@ fn test_merge_views_checkout() { tx2.mut_repo().remove_checkout(&ws5_id); tx2.mut_repo() .set_checkout(ws7_id.clone(), commit3.id().clone()); + // Make sure the end time different, assuming the clock has sub-millisecond + // precision. + std::thread::sleep(std::time::Duration::from_millis(1)); tx2.commit(); let repo = repo.reload();