Skip to content

Commit

Permalink
test: add online_tests feature to control Internet use
Browse files Browse the repository at this point in the history
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 prefix-dev#2880
  • Loading branch information
mgorny committed Jan 11, 2025
1 parent 1b15d13 commit 0a84bba
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,16 @@ repository.workspace = true
version = "0.40.0"

[features]
default = ["rustls-tls"]
default = ["online_tests", "rustls-tls"]
native-tls = [
"reqwest/native-tls",
"reqwest/native-tls-alpn",
"rattler_repodata_gateway/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",
Expand Down
4 changes: 4 additions & 0 deletions tests/integration_rust/add_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@ async fn add_dependency_pinning_strategy() {

/// Test adding a git dependency with a specific branch
#[tokio::test]
#[cfg_attr(not(feature = "online_tests"), ignore)]
async fn add_git_deps() {
let pixi = PixiControl::from_manifest(
r#"
Expand Down Expand Up @@ -686,6 +687,7 @@ preview = ['pixi-build']
/// during the CI run
#[cfg(not(windows))]
#[tokio::test]
#[cfg_attr(not(feature = "online_tests"), ignore)]
async fn add_git_deps_with_creds() {
let pixi = PixiControl::from_manifest(
r#"
Expand Down Expand Up @@ -722,6 +724,7 @@ preview = ['pixi-build']

/// Test adding a git dependency with a specific commit
#[tokio::test]
#[cfg_attr(not(feature = "online_tests"), ignore)]
async fn add_git_with_specific_commit() {
let pixi = PixiControl::from_manifest(
r#"
Expand Down Expand Up @@ -755,6 +758,7 @@ preview = ['pixi-build']"#,

/// Test adding a git dependency with a specific tag
#[tokio::test]
#[cfg_attr(not(feature = "online_tests"), ignore)]
async fn add_git_with_tag() {
let pixi = PixiControl::from_manifest(
r#"
Expand Down
4 changes: 4 additions & 0 deletions tests/integration_rust/solve_group_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 0a84bba

Please sign in to comment.