diff --git a/Cargo.lock b/Cargo.lock index 394d6960c..3be4dff70 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -793,13 +793,14 @@ dependencies = [ ] [[package]] -name = "fs2" -version = "0.4.3" +name = "fs4" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +checksum = "e871a4cfa68bb224863b53149d973df1ac8d1ed2fa1d1bfc37ac1bb65dd37207" dependencies = [ - "libc", - "winapi", + "fs-err", + "rustix", + "windows-sys 0.52.0", ] [[package]] @@ -1233,7 +1234,7 @@ dependencies = [ "fat-macho", "flate2", "fs-err", - "fs2", + "fs4", "glob", "goblin", "ignore", diff --git a/Cargo.toml b/Cargo.toml index 0d379eadb..25e7ae94d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -135,7 +135,7 @@ pretty_assertions = { version = "1.3.0", optional = true } [dev-dependencies] expect-test = "1.4.1" -fs2 = "0.4.3" +fs4 = { version = "0.11.1", features = ["fs-err"] } indoc = "2.0.3" pretty_assertions = "1.3.0" rstest = "0.22.0" diff --git a/tests/common/integration.rs b/tests/common/integration.rs index 73bcec0a9..5e300efb5 100644 --- a/tests/common/integration.rs +++ b/tests/common/integration.rs @@ -1,11 +1,11 @@ use crate::common::{ - check_installed, create_virtualenv, create_virtualenv_name, maybe_mock_cargo, test_python_path, + check_installed, create_named_virtualenv, create_virtualenv, maybe_mock_cargo, test_python_path, }; use anyhow::{bail, Context, Result}; #[cfg(feature = "zig")] use cargo_zigbuild::Zig; use clap::Parser; -use fs2::FileExt; +use fs4::fs_err::FileExt; use fs_err::File; use maturin::{BuildOptions, PlatformTag, PythonInterpreter, Target}; use normpath::PathExt; @@ -92,29 +92,34 @@ pub fn test_integration( // All tests try to use this venv at the same time, so we need to make sure only one // modifies it at a time and that during that time, no other test reads it. let file = File::create(venvs_dir.join("cffi-provider.lock"))?; - file.file().lock_exclusive()?; - if !dbg!(venvs_dir.join(cffi_provider)).is_dir() { - dbg!(create_virtualenv_name( - cffi_provider, - python_interp.clone().map(PathBuf::from) - )?); + file.lock_exclusive()?; + if !python.is_file() { + create_named_virtualenv(cffi_provider, python_interp.clone().map(PathBuf::from))?; + assert!(python.is_file(), "cffi venv not created correctly"); let pip_install_cffi = [ "-m", "pip", "--disable-pip-version-check", + "--no-cache-dir", "install", "cffi", ]; let output = Command::new(&python) .args(pip_install_cffi) - .status() - //.output() - .context(format!("pip install cffi failed with {python:?}"))?; - if !output.success() { - bail!("Installing cffi into {} failed", cffi_venv.display()); + .output() + .with_context(|| format!("pip install cffi failed with {python:?}"))?; + if !output.status.success() { + let stderr = String::from_utf8_lossy(&output.stderr); + let stdout = String::from_utf8_lossy(&output.stdout); + bail!( + "Installing cffi into {} failed.\nstdout: {}\nstderr: {}", + cffi_venv.display(), + stdout, + stderr + ); } } - file.file().unlock()?; + file.unlock()?; cli.push("--interpreter"); cli.push( python diff --git a/tests/common/mod.rs b/tests/common/mod.rs index e4d658123..55aa65c89 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -126,14 +126,14 @@ pub fn create_virtualenv(name: &str, python_interp: Option) -> Result<( Err(_) => name.to_string(), }; - let venv_dir = create_virtualenv_name(&venv_name, interp)?; + let venv_dir = create_named_virtualenv(&venv_name, interp)?; let target = Target::from_target_triple(None)?; let python = target.get_venv_python(&venv_dir); Ok((venv_dir, python)) } -pub fn create_virtualenv_name(venv_name: &str, interp: Option) -> Result { +pub fn create_named_virtualenv(venv_name: &str, interp: Option) -> Result { let venv_dir = PathBuf::from("test-crates") .normalize()? .into_path_buf()