From 223f16b89bb1ec600c81c243ddfa1eb6d2c34343 Mon Sep 17 00:00:00 2001 From: messense Date: Tue, 15 Nov 2022 12:33:22 +0800 Subject: [PATCH] Remove unnecessary `editable` tests After #653, `develop` tests already covered `editable` since it uses editable installs internally --- tests/common/editable.rs | 89 ---------------------------------------- tests/common/mod.rs | 1 - tests/run.rs | 39 +----------------- 3 files changed, 1 insertion(+), 128 deletions(-) delete mode 100644 tests/common/editable.rs diff --git a/tests/common/editable.rs b/tests/common/editable.rs deleted file mode 100644 index cf33eb909..000000000 --- a/tests/common/editable.rs +++ /dev/null @@ -1,89 +0,0 @@ -use crate::common::{check_installed, create_virtualenv, maybe_mock_cargo}; -use anyhow::{bail, Context, Result}; -use clap::Parser; -use maturin::BuildOptions; -use std::path::Path; -use std::process::Command; -use std::str; - -/// test PEP 660 editable installs -pub fn test_editable( - package: impl AsRef, - bindings: Option, - unique_name: &str, -) -> Result<()> { - maybe_mock_cargo(); - - let package_string = package.as_ref().join("Cargo.toml").display().to_string(); - - let (venv_dir, python) = create_virtualenv(unique_name, None)?; - let interpreter = python.to_str().expect("invalid interpreter path"); - let target_dir = format!("test-crates/targets/{}", unique_name); - let wheel_dir = format!("test-crates/wheels/{}", unique_name); - - // The first argument is ignored by clap - let mut cli = vec![ - "build", - "--quiet", - "--interpreter", - interpreter, - "--manifest-path", - &package_string, - "--compatibility", - "linux", - "--target-dir", - &target_dir, - "--out", - &wheel_dir, - ]; - - if let Some(ref bindings) = bindings { - cli.push("--bindings"); - cli.push(bindings); - } - - let options: BuildOptions = BuildOptions::try_parse_from(cli)?; - - let build_context = options.into_build_context(false, cfg!(feature = "faster-tests"), true)?; - let wheels = build_context.build_wheels()?; - - for (filename, _supported_version) in wheels.iter() { - // TODO: should add an assertion for .pth file in wheel root for mixed project layout - let command = [ - "-m", - "pip", - "--disable-pip-version-check", - "--no-cache-dir", - "install", - "--force-reinstall", - ]; - let output = Command::new(&python) - .args(command) - .arg(dunce::simplified(filename)) - .output() - .context(format!("pip install failed with {:?}", python))?; - if !output.status.success() { - bail!( - "pip install in {} failed running {:?}: {}\n--- Stdout:\n{}\n--- Stderr:\n{}\n---\n", - venv_dir.display(), - &command, - output.status, - str::from_utf8(&output.stdout)?.trim(), - str::from_utf8(&output.stderr)?.trim(), - ); - } - if !output.stderr.is_empty() { - bail!( - "pip raised a warning running {:?}: {}\n--- Stdout:\n{}\n--- Stderr:\n{}\n---\n", - &command, - output.status, - str::from_utf8(&output.stdout)?.trim(), - str::from_utf8(&output.stderr)?.trim(), - ); - } - - check_installed(package.as_ref(), &python)?; - } - - Ok(()) -} diff --git a/tests/common/mod.rs b/tests/common/mod.rs index bbfb21bcf..2f2f4e23a 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -8,7 +8,6 @@ use std::process::{Command, Stdio}; use std::{env, io, str}; pub mod develop; -pub mod editable; pub mod errors; pub mod integration; pub mod other; diff --git a/tests/run.rs b/tests/run.rs index 78b09fc29..6a021565d 100644 --- a/tests/run.rs +++ b/tests/run.rs @@ -1,8 +1,7 @@ //! To speed up the tests, they are tests all collected in a single module use common::{ - develop, editable, errors, get_python_implementation, handle_result, integration, other, - test_python_path, + develop, errors, get_python_implementation, handle_result, integration, other, test_python_path, }; use indoc::indoc; use maturin::Target; @@ -124,42 +123,6 @@ fn develop_pyo3_ffi_pure() { )); } -#[test] -fn editable_pyo3_pure() { - handle_result(editable::test_editable( - "test-crates/pyo3-pure", - None, - "editable-pyo3-pure", - )); -} - -#[test] -fn editable_pyo3_mixed() { - handle_result(editable::test_editable( - "test-crates/pyo3-mixed", - None, - "editable-pyo3-mixed", - )); -} - -#[test] -fn editable_pyo3_mixed_py_subdir() { - handle_result(editable::test_editable( - "test-crates/pyo3-mixed-py-subdir", - None, - "editable-pyo3-mixed-py-subdir", - )); -} - -#[test] -fn editable_pyo3_ffi_pure() { - handle_result(editable::test_editable( - "test-crates/pyo3-ffi-pure", - None, - "editable-pyo3-ffi-pure", - )); -} - #[test] fn integration_pyo3_bin() { let python = test_python_path().map(PathBuf::from).unwrap_or_else(|| {