Skip to content

Commit

Permalink
Replace MarkupSafe for no-binary tests (#1296)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh authored Feb 14, 2024
1 parent 3678374 commit 40b74fb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 166 deletions.
144 changes: 16 additions & 128 deletions crates/puffin/tests/pip_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,127 +662,14 @@ 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() {
let context = TestContext::new("3.12");

// 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
Expand All @@ -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");
Expand All @@ -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) {
Expand All @@ -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
Expand All @@ -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
Expand Down
38 changes: 0 additions & 38 deletions crates/puffin/tests/pip_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand Down

0 comments on commit 40b74fb

Please sign in to comment.