mirror of https://github.com/astral-sh/uv
Add assertions that `pip compile` scenario test matches expected outcome
This commit is contained in:
parent
5cc4e5d31e
commit
ecba550152
|
|
@ -9,6 +9,7 @@ use std::path::PathBuf;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use assert_cmd::assert::OutputAssertExt;
|
||||||
use assert_fs::fixture::{FileWriteStr, PathChild};
|
use assert_fs::fixture::{FileWriteStr, PathChild};
|
||||||
use common::{create_venv, BIN_NAME, INSTA_FILTERS};
|
use common::{create_venv, BIN_NAME, INSTA_FILTERS};
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
|
@ -17,6 +18,7 @@ use fs_err::os::unix::fs::symlink as symlink_file;
|
||||||
use fs_err::os::windows::fs::symlink_file;
|
use fs_err::os::windows::fs::symlink_file;
|
||||||
use insta_cmd::_macro_support::insta;
|
use insta_cmd::_macro_support::insta;
|
||||||
use insta_cmd::{assert_cmd_snapshot, get_cargo_bin};
|
use insta_cmd::{assert_cmd_snapshot, get_cargo_bin};
|
||||||
|
use predicates::prelude::predicate;
|
||||||
use puffin_interpreter::find_requested_python;
|
use puffin_interpreter::find_requested_python;
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
@ -71,22 +73,25 @@ fn requires_incompatible_python_version_compatible_override() -> Result<()> {
|
||||||
let requirements_in = temp_dir.child("requirements.in");
|
let requirements_in = temp_dir.child("requirements.in");
|
||||||
requirements_in.write_str("a-006fed96==1.0.0")?;
|
requirements_in.write_str("a-006fed96==1.0.0")?;
|
||||||
|
|
||||||
|
let mut inner = Command::new(get_cargo_bin(BIN_NAME));
|
||||||
|
let mut command = inner
|
||||||
|
.arg("pip")
|
||||||
|
.arg("compile")
|
||||||
|
.arg("requirements.in")
|
||||||
|
.arg("--python-version=3.11")
|
||||||
|
.arg("--extra-index-url")
|
||||||
|
.arg("https://test.pypi.org/simple")
|
||||||
|
.arg("--cache-dir")
|
||||||
|
.arg(cache_dir.path())
|
||||||
|
.env("VIRTUAL_ENV", venv.as_os_str())
|
||||||
|
.env("PUFFIN_NO_WRAP", "1")
|
||||||
|
.env("PUFFIN_PYTHON_PATH", bin)
|
||||||
|
.current_dir(&temp_dir);
|
||||||
|
|
||||||
insta::with_settings!({
|
insta::with_settings!({
|
||||||
filters => filters
|
filters => filters
|
||||||
}, {
|
}, {
|
||||||
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
|
assert_cmd_snapshot!(command, @r###"
|
||||||
.arg("pip")
|
|
||||||
.arg("compile")
|
|
||||||
.arg("requirements.in")
|
|
||||||
.arg("--python-version=3.11")
|
|
||||||
.arg("--extra-index-url")
|
|
||||||
.arg("https://test.pypi.org/simple")
|
|
||||||
.arg("--cache-dir")
|
|
||||||
.arg(cache_dir.path())
|
|
||||||
.env("VIRTUAL_ENV", venv.as_os_str())
|
|
||||||
.env("PUFFIN_NO_WRAP", "1")
|
|
||||||
.env("PUFFIN_PYTHON_PATH", bin)
|
|
||||||
.current_dir(&temp_dir), @r###"
|
|
||||||
success: true
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
@ -100,6 +105,11 @@ fn requires_incompatible_python_version_compatible_override() -> Result<()> {
|
||||||
"###);
|
"###);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
command
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.stdout(predicate::str::contains("a-006fed96==1.0.0"));
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,22 +145,25 @@ fn requires_compatible_python_version_incompatible_override() -> Result<()> {
|
||||||
let requirements_in = temp_dir.child("requirements.in");
|
let requirements_in = temp_dir.child("requirements.in");
|
||||||
requirements_in.write_str("a-8c1b0389==1.0.0")?;
|
requirements_in.write_str("a-8c1b0389==1.0.0")?;
|
||||||
|
|
||||||
|
let mut inner = Command::new(get_cargo_bin(BIN_NAME));
|
||||||
|
let mut command = inner
|
||||||
|
.arg("pip")
|
||||||
|
.arg("compile")
|
||||||
|
.arg("requirements.in")
|
||||||
|
.arg("--python-version=3.9")
|
||||||
|
.arg("--extra-index-url")
|
||||||
|
.arg("https://test.pypi.org/simple")
|
||||||
|
.arg("--cache-dir")
|
||||||
|
.arg(cache_dir.path())
|
||||||
|
.env("VIRTUAL_ENV", venv.as_os_str())
|
||||||
|
.env("PUFFIN_NO_WRAP", "1")
|
||||||
|
.env("PUFFIN_PYTHON_PATH", bin)
|
||||||
|
.current_dir(&temp_dir);
|
||||||
|
|
||||||
insta::with_settings!({
|
insta::with_settings!({
|
||||||
filters => filters
|
filters => filters
|
||||||
}, {
|
}, {
|
||||||
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
|
assert_cmd_snapshot!(command, @r###"
|
||||||
.arg("pip")
|
|
||||||
.arg("compile")
|
|
||||||
.arg("requirements.in")
|
|
||||||
.arg("--python-version=3.9")
|
|
||||||
.arg("--extra-index-url")
|
|
||||||
.arg("https://test.pypi.org/simple")
|
|
||||||
.arg("--cache-dir")
|
|
||||||
.arg(cache_dir.path())
|
|
||||||
.env("VIRTUAL_ENV", venv.as_os_str())
|
|
||||||
.env("PUFFIN_NO_WRAP", "1")
|
|
||||||
.env("PUFFIN_PYTHON_PATH", bin)
|
|
||||||
.current_dir(&temp_dir), @r###"
|
|
||||||
success: false
|
success: false
|
||||||
exit_code: 1
|
exit_code: 1
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
@ -163,6 +176,8 @@ fn requires_compatible_python_version_incompatible_override() -> Result<()> {
|
||||||
"###);
|
"###);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
command.assert().failure();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -199,25 +214,25 @@ fn requires_incompatible_python_version_compatible_override_no_wheels() -> Resul
|
||||||
let requirements_in = temp_dir.child("requirements.in");
|
let requirements_in = temp_dir.child("requirements.in");
|
||||||
requirements_in.write_str("a-b8ee1c03==1.0.0")?;
|
requirements_in.write_str("a-b8ee1c03==1.0.0")?;
|
||||||
|
|
||||||
// Since there are no wheels for the package and it is not compatible with the
|
let mut inner = Command::new(get_cargo_bin(BIN_NAME));
|
||||||
// local installation, we cannot build the source distribution to determine its
|
let mut command = inner
|
||||||
// dependencies.
|
.arg("pip")
|
||||||
|
.arg("compile")
|
||||||
|
.arg("requirements.in")
|
||||||
|
.arg("--python-version=3.11")
|
||||||
|
.arg("--extra-index-url")
|
||||||
|
.arg("https://test.pypi.org/simple")
|
||||||
|
.arg("--cache-dir")
|
||||||
|
.arg(cache_dir.path())
|
||||||
|
.env("VIRTUAL_ENV", venv.as_os_str())
|
||||||
|
.env("PUFFIN_NO_WRAP", "1")
|
||||||
|
.env("PUFFIN_PYTHON_PATH", bin)
|
||||||
|
.current_dir(&temp_dir);
|
||||||
|
|
||||||
insta::with_settings!({
|
insta::with_settings!({
|
||||||
filters => filters
|
filters => filters
|
||||||
}, {
|
}, {
|
||||||
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
|
assert_cmd_snapshot!(command, @r###"
|
||||||
.arg("pip")
|
|
||||||
.arg("compile")
|
|
||||||
.arg("requirements.in")
|
|
||||||
.arg("--python-version=3.11")
|
|
||||||
.arg("--extra-index-url")
|
|
||||||
.arg("https://test.pypi.org/simple")
|
|
||||||
.arg("--cache-dir")
|
|
||||||
.arg(cache_dir.path())
|
|
||||||
.env("VIRTUAL_ENV", venv.as_os_str())
|
|
||||||
.env("PUFFIN_NO_WRAP", "1")
|
|
||||||
.env("PUFFIN_PYTHON_PATH", bin)
|
|
||||||
.current_dir(&temp_dir), @r###"
|
|
||||||
success: false
|
success: false
|
||||||
exit_code: 1
|
exit_code: 1
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
@ -230,6 +245,11 @@ fn requires_incompatible_python_version_compatible_override_no_wheels() -> Resul
|
||||||
"###);
|
"###);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Since there are no wheels for the package and it is not compatible with the
|
||||||
|
// local installation, we cannot build the source distribution to determine its
|
||||||
|
// dependencies.
|
||||||
|
command.assert().failure();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -269,24 +289,25 @@ fn requires_incompatible_python_version_compatible_override_no_wheels_available_
|
||||||
let requirements_in = temp_dir.child("requirements.in");
|
let requirements_in = temp_dir.child("requirements.in");
|
||||||
requirements_in.write_str("a-ae5b2665==1.0.0")?;
|
requirements_in.write_str("a-ae5b2665==1.0.0")?;
|
||||||
|
|
||||||
// Since there is a compatible Python version available on the system, it should be
|
let mut inner = Command::new(get_cargo_bin(BIN_NAME));
|
||||||
// used to build the source distributions.
|
let mut command = inner
|
||||||
|
.arg("pip")
|
||||||
|
.arg("compile")
|
||||||
|
.arg("requirements.in")
|
||||||
|
.arg("--python-version=3.11")
|
||||||
|
.arg("--extra-index-url")
|
||||||
|
.arg("https://test.pypi.org/simple")
|
||||||
|
.arg("--cache-dir")
|
||||||
|
.arg(cache_dir.path())
|
||||||
|
.env("VIRTUAL_ENV", venv.as_os_str())
|
||||||
|
.env("PUFFIN_NO_WRAP", "1")
|
||||||
|
.env("PUFFIN_PYTHON_PATH", bin)
|
||||||
|
.current_dir(&temp_dir);
|
||||||
|
|
||||||
insta::with_settings!({
|
insta::with_settings!({
|
||||||
filters => filters
|
filters => filters
|
||||||
}, {
|
}, {
|
||||||
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
|
assert_cmd_snapshot!(command, @r###"
|
||||||
.arg("pip")
|
|
||||||
.arg("compile")
|
|
||||||
.arg("requirements.in")
|
|
||||||
.arg("--python-version=3.11")
|
|
||||||
.arg("--extra-index-url")
|
|
||||||
.arg("https://test.pypi.org/simple")
|
|
||||||
.arg("--cache-dir")
|
|
||||||
.arg(cache_dir.path())
|
|
||||||
.env("VIRTUAL_ENV", venv.as_os_str())
|
|
||||||
.env("PUFFIN_NO_WRAP", "1")
|
|
||||||
.env("PUFFIN_PYTHON_PATH", bin)
|
|
||||||
.current_dir(&temp_dir), @r###"
|
|
||||||
success: true
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
@ -299,6 +320,10 @@ fn requires_incompatible_python_version_compatible_override_no_wheels_available_
|
||||||
"###);
|
"###);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Since there is a compatible Python version available on the system, it should be
|
||||||
|
// used to build the source distributions.
|
||||||
|
command.assert().success();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -335,25 +360,25 @@ fn requires_incompatible_python_version_compatible_override_no_compatible_wheels
|
||||||
let requirements_in = temp_dir.child("requirements.in");
|
let requirements_in = temp_dir.child("requirements.in");
|
||||||
requirements_in.write_str("a-c0ea406a==1.0.0")?;
|
requirements_in.write_str("a-c0ea406a==1.0.0")?;
|
||||||
|
|
||||||
// Since there are no compatible wheels for the package and it is not compatible
|
let mut inner = Command::new(get_cargo_bin(BIN_NAME));
|
||||||
// with the local installation, we cannot build the source distribution to
|
let mut command = inner
|
||||||
// determine its dependencies.
|
.arg("pip")
|
||||||
|
.arg("compile")
|
||||||
|
.arg("requirements.in")
|
||||||
|
.arg("--python-version=3.11")
|
||||||
|
.arg("--extra-index-url")
|
||||||
|
.arg("https://test.pypi.org/simple")
|
||||||
|
.arg("--cache-dir")
|
||||||
|
.arg(cache_dir.path())
|
||||||
|
.env("VIRTUAL_ENV", venv.as_os_str())
|
||||||
|
.env("PUFFIN_NO_WRAP", "1")
|
||||||
|
.env("PUFFIN_PYTHON_PATH", bin)
|
||||||
|
.current_dir(&temp_dir);
|
||||||
|
|
||||||
insta::with_settings!({
|
insta::with_settings!({
|
||||||
filters => filters
|
filters => filters
|
||||||
}, {
|
}, {
|
||||||
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
|
assert_cmd_snapshot!(command, @r###"
|
||||||
.arg("pip")
|
|
||||||
.arg("compile")
|
|
||||||
.arg("requirements.in")
|
|
||||||
.arg("--python-version=3.11")
|
|
||||||
.arg("--extra-index-url")
|
|
||||||
.arg("https://test.pypi.org/simple")
|
|
||||||
.arg("--cache-dir")
|
|
||||||
.arg(cache_dir.path())
|
|
||||||
.env("VIRTUAL_ENV", venv.as_os_str())
|
|
||||||
.env("PUFFIN_NO_WRAP", "1")
|
|
||||||
.env("PUFFIN_PYTHON_PATH", bin)
|
|
||||||
.current_dir(&temp_dir), @r###"
|
|
||||||
success: false
|
success: false
|
||||||
exit_code: 1
|
exit_code: 1
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
@ -366,6 +391,11 @@ fn requires_incompatible_python_version_compatible_override_no_compatible_wheels
|
||||||
"###);
|
"###);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Since there are no compatible wheels for the package and it is not compatible
|
||||||
|
// with the local installation, we cannot build the source distribution to
|
||||||
|
// determine its dependencies.
|
||||||
|
command.assert().failure();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -406,26 +436,25 @@ fn requires_incompatible_python_version_compatible_override_other_wheel() -> Res
|
||||||
let requirements_in = temp_dir.child("requirements.in");
|
let requirements_in = temp_dir.child("requirements.in");
|
||||||
requirements_in.write_str("a-08a4e843")?;
|
requirements_in.write_str("a-08a4e843")?;
|
||||||
|
|
||||||
// Since there are no wheels for the version of the package compatible with the
|
let mut inner = Command::new(get_cargo_bin(BIN_NAME));
|
||||||
// target and it is not compatible with the local installation, we cannot build the
|
let mut command = inner
|
||||||
// source distribution to determine its dependencies. The other version has wheels
|
.arg("pip")
|
||||||
// available, but is not compatible with the target version and cannot be used.
|
.arg("compile")
|
||||||
|
.arg("requirements.in")
|
||||||
|
.arg("--python-version=3.11")
|
||||||
|
.arg("--extra-index-url")
|
||||||
|
.arg("https://test.pypi.org/simple")
|
||||||
|
.arg("--cache-dir")
|
||||||
|
.arg(cache_dir.path())
|
||||||
|
.env("VIRTUAL_ENV", venv.as_os_str())
|
||||||
|
.env("PUFFIN_NO_WRAP", "1")
|
||||||
|
.env("PUFFIN_PYTHON_PATH", bin)
|
||||||
|
.current_dir(&temp_dir);
|
||||||
|
|
||||||
insta::with_settings!({
|
insta::with_settings!({
|
||||||
filters => filters
|
filters => filters
|
||||||
}, {
|
}, {
|
||||||
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
|
assert_cmd_snapshot!(command, @r###"
|
||||||
.arg("pip")
|
|
||||||
.arg("compile")
|
|
||||||
.arg("requirements.in")
|
|
||||||
.arg("--python-version=3.11")
|
|
||||||
.arg("--extra-index-url")
|
|
||||||
.arg("https://test.pypi.org/simple")
|
|
||||||
.arg("--cache-dir")
|
|
||||||
.arg(cache_dir.path())
|
|
||||||
.env("VIRTUAL_ENV", venv.as_os_str())
|
|
||||||
.env("PUFFIN_NO_WRAP", "1")
|
|
||||||
.env("PUFFIN_PYTHON_PATH", bin)
|
|
||||||
.current_dir(&temp_dir), @r###"
|
|
||||||
success: false
|
success: false
|
||||||
exit_code: 1
|
exit_code: 1
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
@ -446,6 +475,12 @@ fn requires_incompatible_python_version_compatible_override_other_wheel() -> Res
|
||||||
"###);
|
"###);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Since there are no wheels for the version of the package compatible with the
|
||||||
|
// target and it is not compatible with the local installation, we cannot build the
|
||||||
|
// source distribution to determine its dependencies. The other version has wheels
|
||||||
|
// available, but is not compatible with the target version and cannot be used.
|
||||||
|
command.assert().failure();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -481,24 +516,25 @@ fn requires_python_patch_version_override_no_patch() -> Result<()> {
|
||||||
let requirements_in = temp_dir.child("requirements.in");
|
let requirements_in = temp_dir.child("requirements.in");
|
||||||
requirements_in.write_str("a-2e1edfd6==1.0.0")?;
|
requirements_in.write_str("a-2e1edfd6==1.0.0")?;
|
||||||
|
|
||||||
// Since the resolver is asked to solve with 3.8, the minimum compatible Python
|
let mut inner = Command::new(get_cargo_bin(BIN_NAME));
|
||||||
// requirement is treated as 3.8.0.
|
let mut command = inner
|
||||||
|
.arg("pip")
|
||||||
|
.arg("compile")
|
||||||
|
.arg("requirements.in")
|
||||||
|
.arg("--python-version=3.8")
|
||||||
|
.arg("--extra-index-url")
|
||||||
|
.arg("https://test.pypi.org/simple")
|
||||||
|
.arg("--cache-dir")
|
||||||
|
.arg(cache_dir.path())
|
||||||
|
.env("VIRTUAL_ENV", venv.as_os_str())
|
||||||
|
.env("PUFFIN_NO_WRAP", "1")
|
||||||
|
.env("PUFFIN_PYTHON_PATH", bin)
|
||||||
|
.current_dir(&temp_dir);
|
||||||
|
|
||||||
insta::with_settings!({
|
insta::with_settings!({
|
||||||
filters => filters
|
filters => filters
|
||||||
}, {
|
}, {
|
||||||
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
|
assert_cmd_snapshot!(command, @r###"
|
||||||
.arg("pip")
|
|
||||||
.arg("compile")
|
|
||||||
.arg("requirements.in")
|
|
||||||
.arg("--python-version=3.8")
|
|
||||||
.arg("--extra-index-url")
|
|
||||||
.arg("https://test.pypi.org/simple")
|
|
||||||
.arg("--cache-dir")
|
|
||||||
.arg(cache_dir.path())
|
|
||||||
.env("VIRTUAL_ENV", venv.as_os_str())
|
|
||||||
.env("PUFFIN_NO_WRAP", "1")
|
|
||||||
.env("PUFFIN_PYTHON_PATH", bin)
|
|
||||||
.current_dir(&temp_dir), @r###"
|
|
||||||
success: false
|
success: false
|
||||||
exit_code: 1
|
exit_code: 1
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
@ -510,6 +546,10 @@ fn requires_python_patch_version_override_no_patch() -> Result<()> {
|
||||||
"###);
|
"###);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Since the resolver is asked to solve with 3.8, the minimum compatible Python
|
||||||
|
// requirement is treated as 3.8.0.
|
||||||
|
command.assert().failure();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -545,22 +585,25 @@ fn requires_python_patch_version_override_patch_compatible() -> Result<()> {
|
||||||
let requirements_in = temp_dir.child("requirements.in");
|
let requirements_in = temp_dir.child("requirements.in");
|
||||||
requirements_in.write_str("a-844899bd==1.0.0")?;
|
requirements_in.write_str("a-844899bd==1.0.0")?;
|
||||||
|
|
||||||
|
let mut inner = Command::new(get_cargo_bin(BIN_NAME));
|
||||||
|
let mut command = inner
|
||||||
|
.arg("pip")
|
||||||
|
.arg("compile")
|
||||||
|
.arg("requirements.in")
|
||||||
|
.arg("--python-version=3.8.0")
|
||||||
|
.arg("--extra-index-url")
|
||||||
|
.arg("https://test.pypi.org/simple")
|
||||||
|
.arg("--cache-dir")
|
||||||
|
.arg(cache_dir.path())
|
||||||
|
.env("VIRTUAL_ENV", venv.as_os_str())
|
||||||
|
.env("PUFFIN_NO_WRAP", "1")
|
||||||
|
.env("PUFFIN_PYTHON_PATH", bin)
|
||||||
|
.current_dir(&temp_dir);
|
||||||
|
|
||||||
insta::with_settings!({
|
insta::with_settings!({
|
||||||
filters => filters
|
filters => filters
|
||||||
}, {
|
}, {
|
||||||
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
|
assert_cmd_snapshot!(command, @r###"
|
||||||
.arg("pip")
|
|
||||||
.arg("compile")
|
|
||||||
.arg("requirements.in")
|
|
||||||
.arg("--python-version=3.8.0")
|
|
||||||
.arg("--extra-index-url")
|
|
||||||
.arg("https://test.pypi.org/simple")
|
|
||||||
.arg("--cache-dir")
|
|
||||||
.arg(cache_dir.path())
|
|
||||||
.env("VIRTUAL_ENV", venv.as_os_str())
|
|
||||||
.env("PUFFIN_NO_WRAP", "1")
|
|
||||||
.env("PUFFIN_PYTHON_PATH", bin)
|
|
||||||
.current_dir(&temp_dir), @r###"
|
|
||||||
success: true
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
@ -574,5 +617,10 @@ fn requires_python_patch_version_override_patch_compatible() -> Result<()> {
|
||||||
"###);
|
"###);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
command
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.stdout(predicate::str::contains("a-844899bd==1.0.0"));
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ use std::path::PathBuf;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use assert_cmd::assert::OutputAssertExt;
|
||||||
use assert_fs::fixture::{FileWriteStr, PathChild};
|
use assert_fs::fixture::{FileWriteStr, PathChild};
|
||||||
use common::{create_venv, BIN_NAME, INSTA_FILTERS};
|
use common::{create_venv, BIN_NAME, INSTA_FILTERS};
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
|
@ -17,6 +18,7 @@ use fs_err::os::unix::fs::symlink as symlink_file;
|
||||||
use fs_err::os::windows::fs::symlink_file;
|
use fs_err::os::windows::fs::symlink_file;
|
||||||
use insta_cmd::_macro_support::insta;
|
use insta_cmd::_macro_support::insta;
|
||||||
use insta_cmd::{assert_cmd_snapshot, get_cargo_bin};
|
use insta_cmd::{assert_cmd_snapshot, get_cargo_bin};
|
||||||
|
use predicates::prelude::predicate;
|
||||||
use puffin_interpreter::find_requested_python;
|
use puffin_interpreter::find_requested_python;
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
@ -33,7 +35,7 @@ pub(crate) fn create_bin_with_executables(
|
||||||
let name = executable
|
let name = executable
|
||||||
.file_name()
|
.file_name()
|
||||||
.expect("Discovered executable must have a filename");
|
.expect("Discovered executable must have a filename");
|
||||||
symlink(&executable, bin.child(name))?;
|
symlink_file(&executable, bin.child(name))?;
|
||||||
}
|
}
|
||||||
Ok(bin.canonicalize()?)
|
Ok(bin.canonicalize()?)
|
||||||
}
|
}
|
||||||
|
|
@ -71,33 +73,49 @@ fn {{module_name}}() -> Result<()> {
|
||||||
requirements_in.write_str("{{requirement}}")?;
|
requirements_in.write_str("{{requirement}}")?;
|
||||||
{{/root.requires}}
|
{{/root.requires}}
|
||||||
|
|
||||||
{{#expected.explanation_lines}}
|
let mut inner = Command::new(get_cargo_bin(BIN_NAME));
|
||||||
// {{.}}
|
let mut command = inner
|
||||||
{{/expected.explanation_lines}}
|
.arg("pip")
|
||||||
|
.arg("compile")
|
||||||
|
.arg("requirements.in")
|
||||||
|
{{#environment.prereleases}}
|
||||||
|
.arg("--prerelease=allow")
|
||||||
|
{{/environment.prereleases}}
|
||||||
|
{{#resolver_options.python}}
|
||||||
|
.arg("--python-version={{.}}")
|
||||||
|
{{/resolver_options.python}}
|
||||||
|
.arg("--extra-index-url")
|
||||||
|
.arg("https://test.pypi.org/simple")
|
||||||
|
.arg("--cache-dir")
|
||||||
|
.arg(cache_dir.path())
|
||||||
|
.env("VIRTUAL_ENV", venv.as_os_str())
|
||||||
|
.env("PUFFIN_NO_WRAP", "1")
|
||||||
|
.env("PUFFIN_PYTHON_PATH", bin)
|
||||||
|
.current_dir(&temp_dir);
|
||||||
|
|
||||||
insta::with_settings!({
|
insta::with_settings!({
|
||||||
filters => filters
|
filters => filters
|
||||||
}, {
|
}, {
|
||||||
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
|
assert_cmd_snapshot!(command, @r###"<snapshot>
|
||||||
.arg("pip")
|
|
||||||
.arg("compile")
|
|
||||||
.arg("requirements.in")
|
|
||||||
{{#environment.prereleases}}
|
|
||||||
.arg("--prerelease=allow")
|
|
||||||
{{/environment.prereleases}}
|
|
||||||
{{#resolver_options.python}}
|
|
||||||
.arg("--python-version={{.}}")
|
|
||||||
{{/resolver_options.python}}
|
|
||||||
.arg("--extra-index-url")
|
|
||||||
.arg("https://test.pypi.org/simple")
|
|
||||||
.arg("--cache-dir")
|
|
||||||
.arg(cache_dir.path())
|
|
||||||
.env("VIRTUAL_ENV", venv.as_os_str())
|
|
||||||
.env("PUFFIN_NO_WRAP", "1")
|
|
||||||
.env("PUFFIN_PYTHON_PATH", bin)
|
|
||||||
.current_dir(&temp_dir), @r###"<snapshot>
|
|
||||||
"###);
|
"###);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
{{#expected.explanation_lines}}
|
||||||
|
// {{.}}
|
||||||
|
{{/expected.explanation_lines}}
|
||||||
|
command
|
||||||
|
.assert()
|
||||||
|
{{#expected.satisfiable}}
|
||||||
|
.success()
|
||||||
|
{{#expected.packages}}
|
||||||
|
.stdout(predicate::str::contains("{{name}}=={{version}}"));
|
||||||
|
{{/expected.packages}}
|
||||||
|
{{/expected.satisfiable}}
|
||||||
|
{{^expected.satisfiable}}
|
||||||
|
.failure()
|
||||||
|
{{/expected.satisfiable}}
|
||||||
|
;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
{{/scenarios}}
|
{{/scenarios}}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue