From 40b74fb0fba4df24a5dd3334fc351b19160b7eca Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 13 Feb 2024 23:44:07 -0500 Subject: [PATCH] Replace `MarkupSafe` for no-binary tests (#1296) --- crates/puffin/tests/pip_install.rs | 144 ++++------------------------- crates/puffin/tests/pip_sync.rs | 38 -------- 2 files changed, 16 insertions(+), 166 deletions(-) diff --git a/crates/puffin/tests/pip_install.rs b/crates/puffin/tests/pip_install.rs index 7d6dc797f..5983c4566 100644 --- a/crates/puffin/tests/pip_install.rs +++ b/crates/puffin/tests/pip_install.rs @@ -662,119 +662,6 @@ fn install_no_index_version() { context.assert_command("import flask").failure(); } -/// Install a package without using pre-built wheels. -#[test] -fn install_no_binary() { - let context = TestContext::new("3.12"); - - let mut command = command(&context); - command - .arg("jinja2") - .arg("--no-binary") - .arg(":all:") - .arg("--strict"); - if cfg!(all(windows, debug_assertions)) { - // TODO(konstin): Reduce stack usage in debug mode enough that the tests pass with the - // default windows stack of 1MB - command.env("PUFFIN_STACK_SIZE", (2 * 1024 * 1024).to_string()); - } - puffin_snapshot!(command, @r###" - success: true - exit_code: 0 - ----- stdout ----- - - ----- stderr ----- - Resolved 2 packages in [TIME] - Downloaded 2 packages in [TIME] - Installed 2 packages in [TIME] - + jinja2==3.1.2 - + markupsafe==2.1.3 - "### - ); - - context.assert_command("import jinja2").success(); -} - -/// Install a package without using pre-built wheels for a subset of packages. -#[test] -fn install_no_binary_subset() { - let context = TestContext::new("3.12"); - - puffin_snapshot!(command(&context) - .arg("jinja2") - .arg("--no-binary") - .arg("jinja2") - .arg("--no-binary") - .arg("markupsafe") - .arg("--strict"), @r###" - success: true - exit_code: 0 - ----- stdout ----- - - ----- stderr ----- - Resolved 2 packages in [TIME] - Downloaded 2 packages in [TIME] - Installed 2 packages in [TIME] - + jinja2==3.1.2 - + markupsafe==2.1.3 - "### - ); - - context.assert_command("import jinja2").success(); -} - -/// Install a package only using pre-built wheels. -#[test] -fn install_only_binary() { - let context = TestContext::new("3.12"); - - puffin_snapshot!(command(&context) - .arg("jinja2") - .arg("--only-binary") - .arg(":all:") - .arg("--strict"), @r###" - success: true - exit_code: 0 - ----- stdout ----- - - ----- stderr ----- - Resolved 2 packages in [TIME] - Downloaded 2 packages in [TIME] - Installed 2 packages in [TIME] - + jinja2==3.1.2 - + markupsafe==2.1.3 - "### - ); - - context.assert_command("import jinja2").success(); -} - -/// Install a package only using pre-built wheels for a subset of packages. -#[test] -fn install_only_binary_subset() { - let context = TestContext::new("3.12"); - - puffin_snapshot!(command(&context) - .arg("jinja2") - .arg("--only-binary") - .arg("markupsafe") - .arg("--strict"), @r###" - success: true - exit_code: 0 - ----- stdout ----- - - ----- stderr ----- - Resolved 2 packages in [TIME] - Downloaded 2 packages in [TIME] - Installed 2 packages in [TIME] - + jinja2==3.1.2 - + markupsafe==2.1.3 - "### - ); - - context.assert_command("import jinja2").success(); -} - /// Install a package without using pre-built wheels. #[test] fn reinstall_no_binary() { @@ -782,7 +669,7 @@ fn reinstall_no_binary() { // The first installation should use a pre-built wheel let mut command = command(&context); - command.arg("jinja2").arg("--strict"); + command.arg("anyio").arg("--strict"); if cfg!(all(windows, debug_assertions)) { // TODO(konstin): Reduce stack usage in debug mode enough that the tests pass with the // default windows stack of 1MB @@ -794,21 +681,22 @@ fn reinstall_no_binary() { ----- stdout ----- ----- stderr ----- - Resolved 2 packages in [TIME] - Downloaded 2 packages in [TIME] - Installed 2 packages in [TIME] - + jinja2==3.1.2 - + markupsafe==2.1.3 + Resolved 3 packages in [TIME] + Downloaded 3 packages in [TIME] + Installed 3 packages in [TIME] + + anyio==4.0.0 + + idna==3.4 + + sniffio==1.3.0 "### ); - context.assert_command("import jinja2").success(); + context.assert_command("import anyio").success(); // Running installation again with `--no-binary` should be a no-op // The first installation should use a pre-built wheel let mut command = crate::command(&context); command - .arg("jinja2") + .arg("anyio") .arg("--no-binary") .arg(":all:") .arg("--strict"); @@ -827,7 +715,7 @@ fn reinstall_no_binary() { "### ); - context.assert_command("import jinja2").success(); + context.assert_command("import anyio").success(); // With `--reinstall`, `--no-binary` should have an affect let filters = if cfg!(windows) { @@ -842,11 +730,11 @@ fn reinstall_no_binary() { }; let mut command = crate::command(&context); command - .arg("jinja2") + .arg("anyio") .arg("--no-binary") .arg(":all:") .arg("--reinstall-package") - .arg("jinja2") + .arg("anyio") .arg("--strict"); if cfg!(all(windows, debug_assertions)) { // TODO(konstin): Reduce stack usage in debug mode enough that the tests pass with the @@ -859,14 +747,14 @@ fn reinstall_no_binary() { ----- stdout ----- ----- stderr ----- - Resolved 2 packages in [TIME] + Resolved 3 packages in [TIME] Installed 1 package in [TIME] - - jinja2==3.1.2 - + jinja2==3.1.2 + - anyio==4.0.0 + + anyio==4.0.0 "### ); - context.assert_command("import jinja2").success(); + context.assert_command("import anyio").success(); } /// Install a package into a virtual environment, and ensuring that the executable permissions diff --git a/crates/puffin/tests/pip_sync.rs b/crates/puffin/tests/pip_sync.rs index 7664f8b10..6fce29042 100644 --- a/crates/puffin/tests/pip_sync.rs +++ b/crates/puffin/tests/pip_sync.rs @@ -808,44 +808,6 @@ fn install_numpy_py38() -> Result<()> { Ok(()) } -/// Install a package without using pre-built wheels. -#[test] -fn install_no_binary() -> Result<()> { - let context = TestContext::new("3.12"); - - let requirements_txt = context.temp_dir.child("requirements.txt"); - requirements_txt.touch()?; - requirements_txt.write_str("MarkupSafe==2.1.3")?; - - let mut command = command(&context); - command - .arg("requirements.txt") - .arg("--no-binary") - .arg(":all:") - .arg("--strict"); - if cfg!(all(windows, debug_assertions)) { - // TODO(konstin): Reduce stack usage in debug mode enough that the tests pass with the - // default windows stack of 1MB - command.env("PUFFIN_STACK_SIZE", (2 * 1024 * 1024).to_string()); - } - puffin_snapshot!(command, @r###" - success: true - exit_code: 0 - ----- stdout ----- - - ----- stderr ----- - Resolved 1 package in [TIME] - Downloaded 1 package in [TIME] - Installed 1 package in [TIME] - + markupsafe==2.1.3 - "### - ); - - context.assert_command("import markupsafe").success(); - - Ok(()) -} - /// Attempt to install a package without using a remote index. #[test] fn install_no_index() -> Result<()> {