diff --git a/tests/common/integration.rs b/tests/common/integration.rs index 6bdda1f46..0992e2031 100644 --- a/tests/common/integration.rs +++ b/tests/common/integration.rs @@ -94,7 +94,11 @@ pub fn test_integration( let file = File::create(venvs_dir.join("cffi-provider.lock"))?; file.lock_exclusive()?; if !python.is_file() { - create_named_virtualenv(cffi_provider, python_interp.clone().map(PathBuf::from))?; + create_named_virtualenv( + cffi_provider, + python_interp.clone().map(PathBuf::from), + false, + )?; let pip_install_cffi = [ "-m", "pip", diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 55aa65c89..b9c49bfdb 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -126,21 +126,24 @@ pub fn create_virtualenv(name: &str, python_interp: Option) -> Result<( Err(_) => name.to_string(), }; - let venv_dir = create_named_virtualenv(&venv_name, interp)?; - + let venv_dir = create_named_virtualenv(&venv_name, interp, true)?; let target = Target::from_target_triple(None)?; let python = target.get_venv_python(&venv_dir); Ok((venv_dir, python)) } -pub fn create_named_virtualenv(venv_name: &str, interp: Option) -> Result { +pub fn create_named_virtualenv( + venv_name: &str, + interp: Option, + clear: bool, +) -> Result { let venv_dir = PathBuf::from("test-crates") .normalize()? .into_path_buf() .join("venvs") .join(venv_name); - if venv_dir.is_dir() { + if clear && venv_dir.is_dir() { fs::remove_dir_all(&venv_dir)?; }