diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 431ddcff9..f6ad9fdca 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -99,6 +99,15 @@ pub fn get_python_implementation(python_interp: &Path) -> Result { Ok(python_impl) } +/// Get the current tested Python implementation +pub fn test_python_implementation() -> Result { + let python = test_python_path().map(PathBuf::from).unwrap_or_else(|| { + let target = Target::from_target_triple(None).unwrap(); + target.get_python() + }); + get_python_implementation(&python) +} + /// Create virtualenv pub fn create_virtualenv(name: &str, python_interp: Option) -> Result<(PathBuf, PathBuf)> { let interp = python_interp.or_else(|| test_python_path().map(PathBuf::from)); diff --git a/tests/run.rs b/tests/run.rs index b3e106399..f85c00198 100644 --- a/tests/run.rs +++ b/tests/run.rs @@ -1,13 +1,10 @@ //! To speed up the tests, they are tests all collected in a single module -use common::{ - develop, errors, get_python_implementation, handle_result, integration, other, test_python_path, -}; +use common::{develop, errors, handle_result, integration, other, test_python_implementation}; use expect_test::expect; use maturin::pyproject_toml::SdistGenerator; -use maturin::Target; use std::env; -use std::path::{Path, PathBuf}; +use std::path::Path; use time::macros::datetime; use which::which; @@ -99,6 +96,11 @@ fn develop_pyo3_mixed_src_layout() { #[test] fn develop_cffi_pure() { + let python_implementation = test_python_implementation().unwrap(); + if cfg!(windows) && env::var("GITHUB_ACTIONS").is_ok() && python_implementation == "pypy" { + // PyPy on Windows hangs on cffi test sometimes + return; + } handle_result(develop::test_develop( "test-crates/cffi-pure", None, @@ -109,6 +111,11 @@ fn develop_cffi_pure() { #[test] fn develop_cffi_mixed() { + let python_implementation = test_python_implementation().unwrap(); + if cfg!(windows) && env::var("GITHUB_ACTIONS").is_ok() && python_implementation == "pypy" { + // PyPy on Windows hangs on cffi test sometimes + return; + } handle_result(develop::test_develop( "test-crates/cffi-mixed", None, @@ -173,11 +180,7 @@ fn develop_pyo3_ffi_pure() { #[test] fn integration_pyo3_bin() { - let python = test_python_path().map(PathBuf::from).unwrap_or_else(|| { - let target = Target::from_target_triple(None).unwrap(); - target.get_python() - }); - let python_implementation = get_python_implementation(&python).unwrap(); + let python_implementation = test_python_implementation().unwrap(); if python_implementation == "pypy" || python_implementation == "graalpy" { // PyPy & GraalPy do not support the 'auto-initialize' feature of pyo3 return; @@ -283,6 +286,11 @@ fn integration_pyo3_pure_conda() { #[test] fn integration_cffi_pure() { + let python_implementation = test_python_implementation().unwrap(); + if cfg!(windows) && env::var("GITHUB_ACTIONS").is_ok() && python_implementation == "pypy" { + // PyPy on Windows hangs on cffi test sometimes + return; + } handle_result(integration::test_integration( "test-crates/cffi-pure", None, @@ -294,6 +302,11 @@ fn integration_cffi_pure() { #[test] fn integration_cffi_mixed() { + let python_implementation = test_python_implementation().unwrap(); + if cfg!(windows) && env::var("GITHUB_ACTIONS").is_ok() && python_implementation == "pypy" { + // PyPy on Windows hangs on cffi test sometimes + return; + } handle_result(integration::test_integration( "test-crates/cffi-mixed", None, @@ -399,11 +412,7 @@ fn integration_wasm_hello_world() { Some("wasm32-wasi"), )); - let python = test_python_path().map(PathBuf::from).unwrap_or_else(|| { - let target = Target::from_target_triple(None).unwrap(); - target.get_python() - }); - let python_implementation = get_python_implementation(&python).unwrap(); + let python_implementation = test_python_implementation().unwrap(); let venv_name = format!("integration-wasm-hello-world-py3-wasm32-wasi-{python_implementation}"); // Make sure we're actually running wasm @@ -443,11 +452,7 @@ fn abi3_without_version() { ignore )] fn pyo3_no_extension_module() { - let python = test_python_path().map(PathBuf::from).unwrap_or_else(|| { - let target = Target::from_target_triple(None).unwrap(); - target.get_python() - }); - let python_implementation = get_python_implementation(&python).unwrap(); + let python_implementation = test_python_implementation().unwrap(); if python_implementation == "cpython" { handle_result(errors::pyo3_no_extension_module()) }