From 6158a713bf285b7817f74e4d4844cc00ee840a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sat, 11 Jan 2025 11:34:49 +0100 Subject: [PATCH] test: add `online_tests` feature to control Internet use Add an `online_tests` feature that specifically covers tests accessing the Internet. It is enabled by default to preserve the existing behavior, but can be explicitly disabled when running the test suite entirely offline. I have not added the respective feature checks to `slow_integration_tests`, as they all seem to require Internet, so that seems redundant. Fixes #2880 --- Cargo.toml | 4 +++- tests/integration_rust/solve_group_tests.rs | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 26a527eb..ddcc4602 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -167,7 +167,7 @@ repository.workspace = true version = "0.39.5" [features] -default = ["rustls-tls"] +default = ["online_tests", "rustls-tls"] native-tls = [ "reqwest/native-tls", "reqwest/native-tls-alpn", @@ -175,6 +175,8 @@ native-tls = [ "rattler/native-tls", "pixi_utils/native-tls", ] +# run tests connecting to remote Internet services +online_tests = [] rustls-tls = [ "reqwest/rustls-tls", "reqwest/rustls-tls-native-roots", diff --git a/tests/integration_rust/solve_group_tests.rs b/tests/integration_rust/solve_group_tests.rs index 5f945bfd..efc5e9e9 100644 --- a/tests/integration_rust/solve_group_tests.rs +++ b/tests/integration_rust/solve_group_tests.rs @@ -163,6 +163,7 @@ async fn test_purl_are_added_for_pypi() { } #[tokio::test] +#[cfg_attr(not(feature = "online_tests"), ignore)] async fn test_purl_are_missing_for_non_conda_forge() { let pixi = PixiControl::new().unwrap(); pixi.init().await.unwrap(); @@ -206,6 +207,7 @@ async fn test_purl_are_missing_for_non_conda_forge() { } #[tokio::test] +#[cfg_attr(not(feature = "online_tests"), ignore)] async fn test_purl_are_generated_using_custom_mapping() { let pixi = PixiControl::new().unwrap(); pixi.init().await.unwrap(); @@ -250,6 +252,7 @@ async fn test_purl_are_generated_using_custom_mapping() { } #[tokio::test] +#[cfg_attr(not(feature = "online_tests"), ignore)] async fn test_compressed_mapping_catch_not_pandoc_not_a_python_package() { let pixi = PixiControl::new().unwrap(); pixi.init().await.unwrap(); @@ -290,6 +293,7 @@ async fn test_compressed_mapping_catch_not_pandoc_not_a_python_package() { } #[tokio::test] +#[cfg_attr(not(feature = "online_tests"), ignore)] async fn test_dont_record_not_present_package_as_purl() { let pixi = PixiControl::new().unwrap(); pixi.init().await.unwrap(); -- 2.47.1