From a05635e0cc4dd7bc1e9ff440515f6b19193b55ee Mon Sep 17 00:00:00 2001 From: messense Date: Mon, 9 Jan 2023 12:36:30 +0800 Subject: [PATCH] Feature-gate tests to fix `cargo test --no-default-features` --- tests/cli.rs | 17 +++++++++++++++++ tests/common/integration.rs | 8 +++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/cli.rs b/tests/cli.rs index c5f412266..43457402e 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -3,9 +3,26 @@ fn cli_tests() { let t = trycmd::TestCases::new(); t.default_bin_name("maturin"); t.case("tests/cmd/*.toml"); + #[cfg(not(feature = "upload"))] { t.skip("tests/cmd/upload.toml"); t.skip("tests/cmd/publish.toml"); } + + #[cfg(not(feature = "zig"))] + { + t.skip("tests/cmd/build.toml"); + } + + #[cfg(not(feature = "scaffolding"))] + { + t.skip("tests/cmd/new.toml"); + t.skip("tests/cmd/init.toml"); + } + + #[cfg(not(all(feature = "upload", feature = "zig", feature = "scaffolding")))] + { + t.skip("tests/cmd/maturin.toml"); + } } diff --git a/tests/common/integration.rs b/tests/common/integration.rs index e4355d01d..1aeddeb27 100644 --- a/tests/common/integration.rs +++ b/tests/common/integration.rs @@ -1,5 +1,6 @@ use crate::common::{check_installed, create_virtualenv, maybe_mock_cargo, test_python_path}; use anyhow::{bail, Context, Result}; +#[cfg(feature = "zig")] use cargo_zigbuild::Zig; use clap::Parser; use maturin::{BuildOptions, PythonInterpreter}; @@ -52,7 +53,12 @@ pub fn test_integration( cli.push(target) } - let test_zig = if zig && (env::var("GITHUB_ACTIONS").is_ok() || Zig::find_zig().is_ok()) { + #[cfg(feature = "zig")] + let zig_found = Zig::find_zig().is_ok(); + #[cfg(not(feature = "zig"))] + let zig_found = false; + + let test_zig = if zig && (env::var("GITHUB_ACTIONS").is_ok() || zig_found) { cli.push("--zig"); true } else {