Skip to content

Commit 5781ede

Browse files
committed
Fix a race in tests on a clean build dir
1 parent 8ee9ebd commit 5781ede

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/tests/git.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::fs;
22
use std::env;
33
use std::thread;
44
use std::path::PathBuf;
5+
use std::sync::{Once, ONCE_INIT};
56

67
use git2;
78
use url::Url;
@@ -14,8 +15,14 @@ pub fn checkout() -> PathBuf { root().join("checkout") }
1415
pub fn bare() -> PathBuf { root().join("bare") }
1516

1617
pub fn init() {
18+
static INIT: Once = ONCE_INIT;
1719
let _ = fs::remove_dir_all(&checkout());
1820
let _ = fs::remove_dir_all(&bare());
21+
22+
INIT.call_once(|| {
23+
fs::create_dir_all(root().parent().unwrap()).unwrap();
24+
});
25+
1926
// Prepare a bare remote repo
2027
{
2128
let bare = git2::Repository::init_bare(&bare()).unwrap();

0 commit comments

Comments
 (0)