Skip to content

Commit

Permalink
Fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
wykurz committed Jun 5, 2024
1 parent 554cd5d commit 0468ee1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions common/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,9 @@ mod cmp_tests {
let tmp_dir = setup_test_dirs(true).await?;
// drop 1 file from src
tokio::fs::remove_file(&tmp_dir.join("foo").join("bar").join("1.txt")).await?;
// drop 1 (other) file from dst
tokio::fs::remove_file(&tmp_dir.join("bar").join("bar").join("2.txt")).await?;
// modify 1 file in dst
// sleep to ensure mtime is different, this acts as a poor-mans barrier
tokio::time::sleep(std::time::Duration::from_millis(1000)).await; // sleep to ensure mtime is different
// modify 1 file in dst
truncate_file(
&tmp_dir
.join("bar")
Expand All @@ -324,6 +323,8 @@ mod cmp_tests {
.unwrap(),
)
.await?;
// drop 1 (other) file from dst
tokio::fs::remove_file(&tmp_dir.join("bar").join("bar").join("2.txt")).await?;
// create one more file in dst -- this will also modify the mtime of the directory
tokio::fs::File::create(&tmp_dir.join("bar").join("baz").join("7.txt")).await?;
let compare_settings = CmpSettings {
Expand Down Expand Up @@ -361,8 +362,8 @@ mod cmp_tests {
CmpResult::DstMissing => 1,
},
ObjType::Dir => enum_map! {
CmpResult::Different => 1,
CmpResult::Same => 2,
CmpResult::Different => 2,
CmpResult::Same => 1,
CmpResult::SrcMissing => 0,
CmpResult::DstMissing => 0,
},
Expand Down

0 comments on commit 0468ee1

Please sign in to comment.