From 0912ed00580342cf49b7911d45369934bcfce8c2 Mon Sep 17 00:00:00 2001 From: David Knaack Date: Fri, 14 Aug 2020 18:58:53 +0200 Subject: [PATCH] fix(test/dir): make lock thread-safe (#1575) * fix(test/dir): make lock thread-safe * stronger ordering --- src/modules/directory.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/modules/directory.rs b/src/modules/directory.rs index a80fc0352..3b977ff08 100644 --- a/src/modules/directory.rs +++ b/src/modules/directory.rs @@ -430,8 +430,7 @@ mod tests { #[test] #[ignore] fn symlinked_subdirectory_git_repo_out_of_tree() -> io::Result<()> { - while LOCK.load(Ordering::Relaxed) {} - LOCK.store(true, Ordering::Relaxed); + while LOCK.swap(true, Ordering::Acquire) {} let tmp_dir = TempDir::new_in(home_dir().unwrap().as_path())?; let repo_dir = tmp_dir.path().join("above-repo").join("rocket-controls"); let src_dir = repo_dir.join("src/meters/fuel-gauge"); @@ -452,7 +451,7 @@ mod tests { assert_eq!(expected, actual); - LOCK.store(false, Ordering::Relaxed); + LOCK.store(false, Ordering::Release); tmp_dir.close() } @@ -460,8 +459,7 @@ mod tests { #[test] #[ignore] fn git_repo_in_home_directory_truncate_to_repo_true() -> io::Result<()> { - while LOCK.load(Ordering::Relaxed) {} - LOCK.store(true, Ordering::Relaxed); + while LOCK.swap(true, Ordering::Acquire) {} let tmp_dir = TempDir::new_in(home_dir().unwrap().as_path())?; let dir = tmp_dir.path().join("src/fuel-gauge"); fs::create_dir_all(&dir)?; @@ -487,7 +485,7 @@ mod tests { assert_eq!(expected, actual); - LOCK.store(false, Ordering::Relaxed); + LOCK.store(false, Ordering::Release); tmp_dir.close() }