Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
slow-timeout = { period = "60s", terminate-after = 30 }

[[profile.default.overrides]]
# See https://nexte.st/book/threads-required.html
# Schedule the slowest tests first so they don't serialize at the tail of the
# run: pgo tests build everything twice, conda tests create conda environments,
# uniffi tests build a large dependency tree and uv_multi_python tests build
# for two interpreters.
filter = 'test(/pgo_|_conda|_uniffi_|uv_multi_python/)'
priority = 100

[[profile.default.overrides]]
# uniffi builds are heavy, but claiming the whole machine serialized all uniffi
# tests; two threads keeps them from crowding out other tests while still
# allowing overlap. See https://nexte.st/book/threads-required.html
filter = 'test(/_uniffi_/)'
threads-required = "num-cpus"
threads-required = 2
20 changes: 13 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ jobs:
uv tool install virtualenv
uv tool install twine
uv tool install uniffi-bindgen==0.28.0
# The conda tests create their own conda environments independent of the
# matrix python, so exercising them once per OS (on the non-dev cells) is
# enough; skipping the slow miniconda setup on the -dev cells saves time.
- uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3
if: ${{ matrix.os != 'windows-11-arm' }}
if: ${{ matrix.os != 'windows-11-arm' && !contains(matrix.python-version, '-dev') }}
with:
auto-activate-base: "false"
activate-environment: ""
Expand Down Expand Up @@ -130,17 +133,20 @@ jobs:
- name: Set MATURIN_TEST_PYTHON
shell: bash
run: echo "MATURIN_TEST_PYTHON=${{ steps.setup-python.outputs.python-path }}" >> "${GITHUB_ENV}"
# To save cache disk space
- name: Disable debuginfo on Windows
if: startsWith(matrix.os, 'windows')
# Saves cache disk space and speeds up linking and packing/installing the
# test wheels; the test suite doesn't need debuginfo in the artifacts.
- name: Disable debuginfo
shell: bash
run: echo "RUSTFLAGS=-C debuginfo=0" >> "${GITHUB_ENV}"
- name: Install llvm-tools
run: rustup component add llvm-tools-preview
- name: cargo test
run: cargo nextest run --features password-storage
run: cargo nextest run --features password-storage,faster-tests
# Zig cross compilation mainly exercises host-OS-specific plumbing, so one
# python per OS is enough; macos-latest and windows-11-arm have no 3.9
# cell, so macos-latest falls back to pypy to keep coverage on arm macs.
- name: test cross compiling with zig
if: ${{ !contains(matrix.python-version, '-dev') }}
if: ${{ matrix.python-version == '3.9' || (matrix.os == 'macos-latest' && matrix.python-version == 'pypy3.11') }}
shell: bash
run: |
set -ex
Expand Down Expand Up @@ -326,7 +332,7 @@ jobs:
- name: cargo test
run: |
# unset GITHUB_ACTIONS env var to disable zig related tests
env -u GITHUB_ACTIONS cargo nextest run --features password-storage
env -u GITHUB_ACTIONS cargo nextest run --features password-storage,faster-tests

test-auditwheel:
name: Test Auditwheel
Expand Down
10 changes: 5 additions & 5 deletions tests/common/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn pyo3_no_extension_module() -> Result<()> {
let options = BuildOptions::try_parse_from(cli)?;
let build_context = options
.into_build_context()
.strip(Some(cfg!(feature = "faster-tests")))
.strip(crate::common::TEST_STRIP)
.editable(false)
.build()?;
let result = BuildOrchestrator::new(&build_context).build_wheels();
Expand Down Expand Up @@ -63,7 +63,7 @@ pub fn locked_doesnt_build_without_cargo_lock() -> Result<()> {
let options = BuildOptions::try_parse_from(cli)?;
let result = options
.into_build_context()
.strip(Some(cfg!(feature = "faster-tests")))
.strip(crate::common::TEST_STRIP)
.editable(false)
.build();
if let Err(err) = result {
Expand Down Expand Up @@ -100,7 +100,7 @@ pub fn invalid_manylinux_does_not_panic() -> Result<()> {
let options: BuildOptions = BuildOptions::try_parse_from(cli)?;
let build_context = options
.into_build_context()
.strip(Some(cfg!(feature = "faster-tests")))
.strip(crate::common::TEST_STRIP)
.editable(false)
.build()?;
let result = BuildOrchestrator::new(&build_context).build_wheels();
Expand Down Expand Up @@ -170,7 +170,7 @@ pub fn pypi_compatibility_unsupported_target() -> Result<()> {
let options: BuildOptions = BuildOptions::try_parse_from(cli)?;
let result = options
.into_build_context()
.strip(Some(cfg!(feature = "faster-tests")))
.strip(crate::common::TEST_STRIP)
.editable(false)
.build();

Expand Down Expand Up @@ -207,7 +207,7 @@ pub fn pypi_compatibility_linux_tag() -> Result<()> {
let options: BuildOptions = BuildOptions::try_parse_from(cli)?;
let build_context = options
.into_build_context()
.strip(Some(cfg!(feature = "faster-tests")))
.strip(crate::common::TEST_STRIP)
.editable(false)
.build()?;
let result = BuildOrchestrator::new(&build_context).build_wheels();
Expand Down
11 changes: 6 additions & 5 deletions tests/common/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ pub fn test_integration(case: &IntegrationCase<'_>) -> Result<()> {
let options: BuildOptions = BuildOptions::try_parse_from(cli)?;
let build_context = options
.into_build_context()
.strip(Some(cfg!(feature = "faster-tests")))
.strip(crate::common::TEST_STRIP)
.editable(false)
.pgo(case.pgo)
.build()?;
Expand Down Expand Up @@ -434,7 +434,7 @@ pub fn test_integration_uv_multi_python(case: &IntegrationCase<'_>) -> Result<()
let options = BuildOptions::try_parse_from(cli)?;
let build_context = options
.into_build_context()
.strip(Some(cfg!(feature = "faster-tests")))
.strip(crate::common::TEST_STRIP)
.editable(false)
.pgo(case.pgo)
.build()?;
Expand Down Expand Up @@ -471,9 +471,10 @@ pub fn test_integration_conda(
let package_string = package.as_ref().join("Cargo.toml").display().to_string();

// Create environments to build against, prepended with "A" to ensure that integration
// tests are executed with these environments
// tests are executed with these environments. Conda env creation is slow, so only cover
// the oldest and newest supported versions instead of every minor release in between.
let mut interpreters = Vec::new();
for minor in 10..=14 {
for minor in [10, 14] {
let (_, venv_python) = create_conda_env(&format!("maturin-{case_id}-3{minor}"), 3, minor)?;
interpreters.push(venv_python);
}
Expand Down Expand Up @@ -504,7 +505,7 @@ pub fn test_integration_conda(

let build_context = options
.into_build_context()
.strip(Some(cfg!(feature = "faster-tests")))
.strip(crate::common::TEST_STRIP)
.editable(false)
.build()?;
let wheels = BuildOrchestrator::new(&build_context).build_wheels()?;
Expand Down
5 changes: 5 additions & 0 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ pub const CFFI_MIXED_SRC_COPY: TestPackageCopy<'static> = TestPackageCopy {
prune_copy_paths: &["test-crates/cffi-mixed-src/src/cffi_mixed_src/cffi_mixed_src"],
};

/// Test builds must not strip symbols: uniffi proc-macro bindings and pyo3
/// stub generation read metadata from the compiled artifact, which
/// `-C strip=symbols` would remove.
pub const TEST_STRIP: Option<bool> = Some(false);

pub fn repo_root() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
}
Expand Down
22 changes: 11 additions & 11 deletions tests/common/other.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub fn test_musl() -> Result<bool> {

let build_context = options
.into_build_context()
.strip(Some(cfg!(feature = "faster-tests")))
.strip(crate::common::TEST_STRIP)
.editable(false)
.build()?;
let built_lib =
Expand Down Expand Up @@ -403,7 +403,7 @@ pub fn abi3_python_interpreter_args() -> Result<()> {
])?;
let result = options
.into_build_context()
.strip(Some(cfg!(feature = "faster-tests")))
.strip(crate::common::TEST_STRIP)
.editable(false)
.build();
assert!(result.is_ok());
Expand All @@ -419,7 +419,7 @@ pub fn abi3_python_interpreter_args() -> Result<()> {
])?;
let result = options
.into_build_context()
.strip(Some(cfg!(feature = "faster-tests")))
.strip(crate::common::TEST_STRIP)
.editable(false)
.build();
assert!(result.is_ok());
Expand All @@ -439,7 +439,7 @@ pub fn abi3_python_interpreter_args() -> Result<()> {
])?;
let result = options
.into_build_context()
.strip(Some(cfg!(feature = "faster-tests")))
.strip(crate::common::TEST_STRIP)
.editable(false)
.build();
assert!(result.is_err());
Expand All @@ -455,7 +455,7 @@ pub fn abi3_python_interpreter_args() -> Result<()> {
])?;
let result = options
.into_build_context()
.strip(Some(cfg!(feature = "faster-tests")))
.strip(crate::common::TEST_STRIP)
.editable(false)
.build();
assert!(result.is_err());
Expand All @@ -481,7 +481,7 @@ pub fn abi3_without_version() -> Result<()> {
let options = BuildOptions::try_parse_from(cli)?;
let result = options
.into_build_context()
.strip(Some(cfg!(feature = "faster-tests")))
.strip(crate::common::TEST_STRIP)
.editable(false)
.build();
assert!(result.is_ok());
Expand Down Expand Up @@ -513,7 +513,7 @@ pub fn pyo3_cffi_build_script() -> Result<()> {
let options = BuildOptions::try_parse_from(cli)?;
let build_context = options
.into_build_context()
.strip(Some(cfg!(feature = "faster-tests")))
.strip(crate::common::TEST_STRIP)
.editable(false)
.build()?;
// Actually build the wheel so the crate's build.rs runs.
Expand All @@ -540,7 +540,7 @@ pub fn abi3t_without_version() -> Result<()> {
let options = BuildOptions::try_parse_from(cli)?;
let result = options
.into_build_context()
.strip(Some(cfg!(feature = "faster-tests")))
.strip(crate::common::TEST_STRIP)
.editable(false)
.build();
assert!(result.is_ok());
Expand Down Expand Up @@ -595,7 +595,7 @@ pub fn combined_stable_abi_wheel_selection(unique_name: &str, features: &[&str])
};
let build_context = options
.into_build_context()
.strip(Some(cfg!(feature = "faster-tests")))
.strip(crate::common::TEST_STRIP)
.editable(false)
.build()?;
let python_interpreter = build_context
Expand Down Expand Up @@ -694,7 +694,7 @@ pub fn test_unreadable_dir() -> Result<()> {

let wheel_context = wheel_options
.into_build_context()
.strip(Some(cfg!(feature = "faster-tests")))
.strip(crate::common::TEST_STRIP)
.editable(false)
.build()?;
let wheel_result = BuildOrchestrator::new(&wheel_context).build_wheels();
Expand Down Expand Up @@ -762,7 +762,7 @@ pub fn test_build_wheels_from_sdist(package: impl AsRef<Path>, unique_name: &str
};
let wheel_context = wheel_options
.into_build_context()
.strip(Some(cfg!(feature = "faster-tests")))
.strip(crate::common::TEST_STRIP)
.editable(false)
.pyproject_toml_path(Some(pyproject_toml))
.build()?;
Expand Down
Loading