Commit
+17 -1 +/-1 browse
1 | diff --git a/tests/common/mod.rs b/tests/common/mod.rs |
2 | index 8c4faf9..d7f955c 100644 |
3 | --- a/tests/common/mod.rs |
4 | +++ b/tests/common/mod.rs |
5 | @@ -24,6 +24,7 @@ use std::net::IpAddr; |
6 | use std::net::Ipv4Addr; |
7 | use std::net::SocketAddr; |
8 | use std::path::Path; |
9 | + use std::sync::Mutex; |
10 | |
11 | use duct::cmd; |
12 | use rand::Rng; |
13 | @@ -46,7 +47,9 @@ impl GitRepo { |
14 | let path = repo.path(); |
15 | |
16 | cmd!("git", "init", ".").dir(path).run()?; |
17 | - cmd!("git", "lfs", "install").dir(path).run()?; |
18 | + |
19 | + git_lfs_install(path)?; |
20 | + |
21 | cmd!("git", "remote", "add", "origin", "fake_remote") |
22 | .dir(path) |
23 | .run()?; |
24 | @@ -167,3 +170,16 @@ pub fn init_logger() { |
25 | // Ignore errors initializing the logger if tests race to configure it |
26 | .try_init(); |
27 | } |
28 | + |
29 | + /// Runs `git lfs install`, but serializes it across unit tests. Tests are flaky |
30 | + /// if this is not done because it tries to overwrite `~/.gitconfig` and races |
31 | + /// with itself. |
32 | + fn git_lfs_install(path: &Path) -> io::Result<()> { |
33 | + static LFS_INSTALL: Mutex<()> = Mutex::new(()); |
34 | + |
35 | + let _guard = LFS_INSTALL.lock().unwrap(); |
36 | + |
37 | + cmd!("git", "lfs", "install").dir(path).run()?; |
38 | + |
39 | + Ok(()) |
40 | + } |