Skip to content

Commit

Permalink
Feature-gate tests to fix cargo test --no-default-features
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Jan 9, 2023
1 parent 772f7a8 commit a05635e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
17 changes: 17 additions & 0 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
8 changes: 7 additions & 1 deletion tests/common/integration.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit a05635e

Please sign in to comment.