mirror of https://github.com/astral-sh/uv
Use helpers in all editable tests (#2339)
## Summary Improves consistency and helps with the kinds of failures seen in https://github.com/astral-sh/uv/pull/2320.
This commit is contained in:
parent
be00b5b7b7
commit
7fc8087583
|
|
@ -1,6 +1,7 @@
|
|||
#![cfg(all(feature = "python", feature = "pypi"))]
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(clippy::disallowed_types))]
|
||||
|
||||
use std::env::current_dir;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
|
@ -2450,20 +2451,14 @@ fn compile_editable() -> Result<()> {
|
|||
.chain(INSTA_FILTERS.to_vec())
|
||||
.collect();
|
||||
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("compile")
|
||||
.arg(requirements_in.path())
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str()), @r###"
|
||||
uv_snapshot!(filters, context.compile()
|
||||
.arg(requirements_in.path())
|
||||
.current_dir(current_dir()?), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile requirements.in --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z
|
||||
# uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z requirements.in
|
||||
-e ${PROJECT_ROOT}/../../scripts/editable-installs/maturin_editable
|
||||
-e ../../scripts/editable-installs/poetry_editable
|
||||
-e file://../../scripts/editable-installs/black_editable
|
||||
|
|
@ -2574,20 +2569,14 @@ fn compile_editable_url_requirement() -> Result<()> {
|
|||
.chain(INSTA_FILTERS.to_vec())
|
||||
.collect();
|
||||
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("compile")
|
||||
.arg(requirements_in.path())
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str()), @r###"
|
||||
uv_snapshot!(filters, context.compile()
|
||||
.arg(requirements_in.path())
|
||||
.current_dir(current_dir()?), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile requirements.in --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z
|
||||
# uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z requirements.in
|
||||
-e ../../scripts/editable-installs/hatchling_editable
|
||||
iniconfig @ https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl
|
||||
# via hatchling-editable
|
||||
|
|
@ -4050,20 +4039,14 @@ fn editable_invalid_extra() -> Result<()> {
|
|||
.chain(INSTA_FILTERS.to_vec())
|
||||
.collect();
|
||||
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("compile")
|
||||
uv_snapshot!(filters, context.compile()
|
||||
.arg(requirements_in.path())
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str()), @r###"
|
||||
.current_dir(current_dir()?), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile requirements.in --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z
|
||||
# uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z requirements.in
|
||||
-e ../../scripts/editable-installs/black_editable
|
||||
|
||||
----- stderr -----
|
||||
|
|
@ -4235,22 +4218,16 @@ fn override_editable() -> Result<()> {
|
|||
.chain(INSTA_FILTERS.to_vec())
|
||||
.collect();
|
||||
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("compile")
|
||||
uv_snapshot!(filters, context.compile()
|
||||
.arg(requirements_in.path())
|
||||
.arg("--override")
|
||||
.arg(overrides_txt.path())
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str()), @r###"
|
||||
.current_dir(current_dir()?), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile requirements.in --override overrides.txt --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z
|
||||
# uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z requirements.in --override overrides.txt
|
||||
-e ../../scripts/editable-installs/black_editable
|
||||
|
||||
----- stderr -----
|
||||
|
|
@ -4588,22 +4565,16 @@ fn editable_direct_dependency() -> Result<()> {
|
|||
.chain(INSTA_FILTERS.to_vec())
|
||||
.collect();
|
||||
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("compile")
|
||||
uv_snapshot!(filters, context.compile()
|
||||
.arg(requirements_in.path())
|
||||
.arg("--resolution")
|
||||
.arg("lowest-direct")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str()), @r###"
|
||||
.current_dir(current_dir()?), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile requirements.in --resolution lowest-direct --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z
|
||||
# uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z requirements.in --resolution lowest-direct
|
||||
-e ../../scripts/editable-installs/setuptools_editable
|
||||
iniconfig==0.1
|
||||
# via setuptools-editable
|
||||
|
|
|
|||
|
|
@ -23,6 +23,26 @@ fn command(context: &TestContext) -> Command {
|
|||
command
|
||||
}
|
||||
|
||||
/// Create a `pip install` command with options shared across scenarios.
|
||||
fn sync_command(context: &TestContext) -> Command {
|
||||
let mut command = Command::new(get_bin());
|
||||
command
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(&context.temp_dir);
|
||||
|
||||
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("UV_STACK_SIZE", (2 * 1024 * 1024).to_string());
|
||||
}
|
||||
|
||||
command
|
||||
}
|
||||
|
||||
/// List multiple installed packages in a virtual environment.
|
||||
#[test]
|
||||
fn freeze_many() -> Result<()> {
|
||||
|
|
@ -32,13 +52,8 @@ fn freeze_many() -> Result<()> {
|
|||
requirements_txt.write_str("MarkupSafe==2.1.3\ntomli==2.0.1")?;
|
||||
|
||||
// Run `pip sync`.
|
||||
Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
sync_command(&context)
|
||||
.arg(requirements_txt.path())
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
|
|
@ -70,13 +85,8 @@ fn freeze_duplicate() -> Result<()> {
|
|||
requirements_txt.write_str("pip==21.3.1")?;
|
||||
|
||||
// Run `pip sync`.
|
||||
Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
sync_command(&context1)
|
||||
.arg(requirements_txt.path())
|
||||
.arg("--cache-dir")
|
||||
.arg(context1.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context1.venv.as_os_str())
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
|
|
@ -86,13 +96,8 @@ fn freeze_duplicate() -> Result<()> {
|
|||
requirements_txt.write_str("pip==22.1.1")?;
|
||||
|
||||
// Run `pip sync`.
|
||||
Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
sync_command(&context2)
|
||||
.arg(requirements_txt.path())
|
||||
.arg("--cache-dir")
|
||||
.arg(context2.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context2.venv.as_os_str())
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
|
|
@ -148,13 +153,8 @@ fn freeze_url() -> Result<()> {
|
|||
requirements_txt.write_str("anyio\niniconfig @ https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl")?;
|
||||
|
||||
// Run `pip sync`.
|
||||
Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
sync_command(&context)
|
||||
.arg(requirements_txt.path())
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
|
|
|
|||
|
|
@ -516,17 +516,10 @@ fn install_editable() -> Result<()> {
|
|||
.collect::<Vec<_>>();
|
||||
|
||||
// Install the editable package.
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("install")
|
||||
uv_snapshot!(filters, command(&context)
|
||||
.arg("-e")
|
||||
.arg("../../scripts/editable-installs/poetry_editable")
|
||||
.arg("--strict")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.env("CARGO_TARGET_DIR", "../../../target/target_install_editable"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
|
@ -618,16 +611,9 @@ fn install_editable_and_registry() -> Result<()> {
|
|||
.collect();
|
||||
|
||||
// Install the registry-based version of Black.
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("install")
|
||||
uv_snapshot!(filters, command(&context)
|
||||
.arg("black")
|
||||
.arg("--strict")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.env("CARGO_TARGET_DIR", "../../../target/target_install_editable"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
|
@ -647,17 +633,10 @@ fn install_editable_and_registry() -> Result<()> {
|
|||
);
|
||||
|
||||
// Install the editable version of Black. This should remove the registry-based version.
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("install")
|
||||
uv_snapshot!(filters, command(&context)
|
||||
.arg("-e")
|
||||
.arg("../../scripts/editable-installs/black_editable")
|
||||
.arg("--strict")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.env("CARGO_TARGET_DIR", "../../../target/target_install_editable"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
|
@ -674,16 +653,10 @@ fn install_editable_and_registry() -> Result<()> {
|
|||
|
||||
// Re-install the registry-based version of Black. This should be a no-op, since we have a
|
||||
// version of Black installed (the editable version) that satisfies the requirements.
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("install")
|
||||
uv_snapshot!(filters, command(&context)
|
||||
.arg("black")
|
||||
.arg("--strict")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.env("CARGO_TARGET_DIR", "../../../target/target_install_editable"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
|
@ -703,16 +676,9 @@ fn install_editable_and_registry() -> Result<()> {
|
|||
.collect();
|
||||
|
||||
// Re-install Black at a specific version. This should replace the editable version.
|
||||
uv_snapshot!(filters2, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("install")
|
||||
uv_snapshot!(filters2, command(&context)
|
||||
.arg("black==23.10.0")
|
||||
.arg("--strict")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.env("CARGO_TARGET_DIR", "../../../target/target_install_editable"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
|
@ -856,7 +822,6 @@ fn install_extra_index_url_has_priority() {
|
|||
// the fix, `uv` will check pypi.org first since it is given
|
||||
// priority via --extra-index-url.
|
||||
.arg("black==24.2.0")
|
||||
.arg("--no-deps")
|
||||
.arg("--exclude-newer")
|
||||
.arg("2024-03-09"), @r###"
|
||||
success: true
|
||||
|
|
@ -864,10 +829,15 @@ fn install_extra_index_url_has_priority() {
|
|||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
Downloaded 1 package in [TIME]
|
||||
Installed 1 package in [TIME]
|
||||
Resolved 6 packages in [TIME]
|
||||
Downloaded 6 packages in [TIME]
|
||||
Installed 6 packages in [TIME]
|
||||
+ black==24.2.0
|
||||
+ click==8.1.7
|
||||
+ mypy-extensions==1.0.0
|
||||
+ packaging==23.2
|
||||
+ pathspec==0.12.1
|
||||
+ platformdirs==4.2.0
|
||||
"###
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use crate::common::{get_bin, TestContext, EXCLUDE_NEWER, INSTA_FILTERS};
|
|||
mod common;
|
||||
|
||||
/// Create a `pip install` command with options shared across scenarios.
|
||||
fn command(context: &TestContext) -> Command {
|
||||
fn install_command(context: &TestContext) -> Command {
|
||||
let mut command = Command::new(get_bin());
|
||||
command
|
||||
.arg("pip")
|
||||
|
|
@ -23,6 +23,13 @@ fn command(context: &TestContext) -> Command {
|
|||
.arg(EXCLUDE_NEWER)
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(&context.temp_dir);
|
||||
|
||||
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("UV_STACK_SIZE", (2 * 1024 * 1024).to_string());
|
||||
}
|
||||
|
||||
command
|
||||
}
|
||||
|
||||
|
|
@ -54,7 +61,7 @@ fn list_single_no_editable() -> Result<()> {
|
|||
requirements_txt.touch()?;
|
||||
requirements_txt.write_str("MarkupSafe==2.1.3")?;
|
||||
|
||||
uv_snapshot!(command(&context)
|
||||
uv_snapshot!(install_command(&context)
|
||||
.arg("-r")
|
||||
.arg("requirements.txt")
|
||||
.arg("--strict"), @r###"
|
||||
|
|
@ -108,17 +115,10 @@ fn list_editable() -> Result<()> {
|
|||
.collect::<Vec<_>>();
|
||||
|
||||
// Install the editable package.
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("install")
|
||||
uv_snapshot!(filters, install_command(&context)
|
||||
.arg("-e")
|
||||
.arg("../../scripts/editable-installs/poetry_editable")
|
||||
.arg("--strict")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.env("CARGO_TARGET_DIR", "../../../target/target_install_editable"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
|
@ -208,17 +208,10 @@ fn list_editable_only() -> Result<()> {
|
|||
.collect::<Vec<_>>();
|
||||
|
||||
// Install the editable package.
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("install")
|
||||
uv_snapshot!(filters, install_command(&context)
|
||||
.arg("-e")
|
||||
.arg("../../scripts/editable-installs/poetry_editable")
|
||||
.arg("--strict")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.env("CARGO_TARGET_DIR", "../../../target/target_install_editable"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
|
@ -265,13 +258,13 @@ fn list_editable_only() -> Result<()> {
|
|||
.collect::<Vec<_>>();
|
||||
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("list")
|
||||
.arg("--editable")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(&context.temp_dir), @r###"
|
||||
.arg("pip")
|
||||
.arg("list")
|
||||
.arg("--editable")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(&context.temp_dir), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
|
@ -284,13 +277,13 @@ fn list_editable_only() -> Result<()> {
|
|||
);
|
||||
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("list")
|
||||
.arg("--exclude-editable")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(&context.temp_dir), @r###"
|
||||
.arg("pip")
|
||||
.arg("list")
|
||||
.arg("--exclude-editable")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(&context.temp_dir), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
|
@ -303,14 +296,14 @@ fn list_editable_only() -> Result<()> {
|
|||
);
|
||||
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("list")
|
||||
.arg("--editable")
|
||||
.arg("--exclude-editable")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(&context.temp_dir), @r###"
|
||||
.arg("pip")
|
||||
.arg("list")
|
||||
.arg("--editable")
|
||||
.arg("--exclude-editable")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(&context.temp_dir), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
|
@ -337,17 +330,10 @@ fn list_exclude() -> Result<()> {
|
|||
.collect::<Vec<_>>();
|
||||
|
||||
// Install the editable package.
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("install")
|
||||
uv_snapshot!(filters, install_command(&context)
|
||||
.arg("-e")
|
||||
.arg("../../scripts/editable-installs/poetry_editable")
|
||||
.arg("--strict")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.env("CARGO_TARGET_DIR", "../../../target/target_install_editable"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
|
@ -473,17 +459,10 @@ fn list_format_json() -> Result<()> {
|
|||
.collect::<Vec<_>>();
|
||||
|
||||
// Install the editable package.
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("install")
|
||||
uv_snapshot!(filters, install_command(&context)
|
||||
.arg("-e")
|
||||
.arg("../../scripts/editable-installs/poetry_editable")
|
||||
.arg("--strict")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.env("CARGO_TARGET_DIR", "../../../target/target_install_editable"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
|
@ -627,17 +606,10 @@ fn list_format_freeze() -> Result<()> {
|
|||
.collect::<Vec<_>>();
|
||||
|
||||
// Install the editable package.
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("install")
|
||||
uv_snapshot!(filters, install_command(&context)
|
||||
.arg("-e")
|
||||
.arg("../../scripts/editable-installs/poetry_editable")
|
||||
.arg("--strict")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.env("CARGO_TARGET_DIR", "../../../target/target_install_editable"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use std::env::current_dir;
|
||||
use std::process::Command;
|
||||
|
||||
use anyhow::Result;
|
||||
|
|
@ -13,7 +14,7 @@ use crate::common::{get_bin, TestContext, EXCLUDE_NEWER};
|
|||
mod common;
|
||||
|
||||
/// Create a `pip install` command with options shared across scenarios.
|
||||
fn command(context: &TestContext) -> Command {
|
||||
fn install_command(context: &TestContext) -> Command {
|
||||
let mut command = Command::new(get_bin());
|
||||
command
|
||||
.arg("pip")
|
||||
|
|
@ -24,6 +25,13 @@ fn command(context: &TestContext) -> Command {
|
|||
.arg(EXCLUDE_NEWER)
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(&context.temp_dir);
|
||||
|
||||
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("UV_STACK_SIZE", (2 * 1024 * 1024).to_string());
|
||||
}
|
||||
|
||||
command
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +64,7 @@ fn show_found_single_package() -> Result<()> {
|
|||
requirements_txt.touch()?;
|
||||
requirements_txt.write_str("MarkupSafe==2.1.3")?;
|
||||
|
||||
uv_snapshot!(command(&context)
|
||||
uv_snapshot!(install_command(&context)
|
||||
.arg("-r")
|
||||
.arg("requirements.txt")
|
||||
.arg("--strict"), @r###"
|
||||
|
|
@ -113,7 +121,7 @@ fn show_found_multiple_packages() -> Result<()> {
|
|||
"
|
||||
})?;
|
||||
|
||||
uv_snapshot!(command(&context)
|
||||
uv_snapshot!(install_command(&context)
|
||||
.arg("-r")
|
||||
.arg("requirements.txt")
|
||||
.arg("--strict"), @r###"
|
||||
|
|
@ -178,7 +186,7 @@ fn show_found_one_out_of_two() -> Result<()> {
|
|||
"
|
||||
})?;
|
||||
|
||||
uv_snapshot!(command(&context)
|
||||
uv_snapshot!(install_command(&context)
|
||||
.arg("-r")
|
||||
.arg("requirements.txt")
|
||||
.arg("--strict"), @r###"
|
||||
|
|
@ -240,7 +248,7 @@ fn show_found_one_out_of_two_quiet() -> Result<()> {
|
|||
"
|
||||
})?;
|
||||
|
||||
uv_snapshot!(command(&context)
|
||||
uv_snapshot!(install_command(&context)
|
||||
.arg("-r")
|
||||
.arg("requirements.txt")
|
||||
.arg("--strict"), @r###"
|
||||
|
|
@ -293,7 +301,7 @@ fn show_empty_quiet() -> Result<()> {
|
|||
"
|
||||
})?;
|
||||
|
||||
uv_snapshot!(command(&context)
|
||||
uv_snapshot!(install_command(&context)
|
||||
.arg("-r")
|
||||
.arg("requirements.txt")
|
||||
.arg("--strict"), @r###"
|
||||
|
|
@ -334,21 +342,14 @@ fn show_empty_quiet() -> Result<()> {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn show_editable() {
|
||||
fn show_editable() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
|
||||
// Install the editable package.
|
||||
Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("install")
|
||||
install_command(&context)
|
||||
.arg("-e")
|
||||
.arg("../../scripts/editable-installs/poetry_editable")
|
||||
.arg("--strict")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.arg("--exclude-newer")
|
||||
.arg(EXCLUDE_NEWER)
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(current_dir()?)
|
||||
.env(
|
||||
"CARGO_TARGET_DIR",
|
||||
"../../../target/target_install_editable",
|
||||
|
|
@ -381,4 +382,6 @@ fn show_editable() {
|
|||
----- stderr -----
|
||||
"###
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2216,14 +2216,9 @@ fn sync_editable() -> Result<()> {
|
|||
.collect::<Vec<_>>();
|
||||
|
||||
// Install the editable packages.
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
uv_snapshot!(filters, command(&context)
|
||||
.arg(requirements_txt.path())
|
||||
.arg("--strict")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.env("CARGO_TARGET_DIR", "../../../target/target_install_editable"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
|
@ -2242,16 +2237,11 @@ fn sync_editable() -> Result<()> {
|
|||
);
|
||||
|
||||
// Reinstall the editable packages.
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
uv_snapshot!(filters, command(&context)
|
||||
.arg(requirements_txt.path())
|
||||
.arg("--reinstall-package")
|
||||
.arg("poetry-editable")
|
||||
.arg("--strict")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.env("CARGO_TARGET_DIR", "../../../target/target_install_editable"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
|
@ -2304,14 +2294,9 @@ fn sync_editable() -> Result<()> {
|
|||
// Don't create a git diff.
|
||||
fs_err::write(python_source_file, python_version_1)?;
|
||||
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
uv_snapshot!(filters, command(&context)
|
||||
.arg(requirements_txt.path())
|
||||
.arg("--strict")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.env("CARGO_TARGET_DIR", "../../../target/target_install_editable"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
|
@ -2352,14 +2337,10 @@ fn sync_editable_and_registry() -> Result<()> {
|
|||
])
|
||||
.copied()
|
||||
.collect::<Vec<_>>();
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
uv_snapshot!(filters, command(&context)
|
||||
.arg(requirements_txt.path())
|
||||
.arg("--strict")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.env("CARGO_TARGET_DIR", "../../../target/target_install_editable"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
|
@ -2395,14 +2376,9 @@ fn sync_editable_and_registry() -> Result<()> {
|
|||
])
|
||||
.copied()
|
||||
.collect::<Vec<_>>();
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
uv_snapshot!(filters, command(&context)
|
||||
.arg(requirements_txt.path())
|
||||
.arg("--strict")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.env("CARGO_TARGET_DIR", "../../../target/target_install_editable"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
|
@ -2434,14 +2410,9 @@ fn sync_editable_and_registry() -> Result<()> {
|
|||
])
|
||||
.copied()
|
||||
.collect::<Vec<_>>();
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
uv_snapshot!(filters, command(&context)
|
||||
.arg(requirements_txt.path())
|
||||
.arg("--strict")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.env("CARGO_TARGET_DIR", "../../../target/target_install_editable"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
|
@ -2468,14 +2439,10 @@ fn sync_editable_and_registry() -> Result<()> {
|
|||
])
|
||||
.copied()
|
||||
.collect::<Vec<_>>();
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
uv_snapshot!(filters, command(&context)
|
||||
.arg(requirements_txt.path())
|
||||
.arg("--strict")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.env("CARGO_TARGET_DIR", "../../../target/target_install_editable"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
|
|
|||
|
|
@ -12,6 +12,46 @@ use crate::common::{get_bin, venv_to_interpreter, TestContext};
|
|||
|
||||
mod common;
|
||||
|
||||
/// Create a `pip uninstall` command with options shared across scenarios.
|
||||
fn uninstall_command(context: &TestContext) -> Command {
|
||||
let mut command = Command::new(get_bin());
|
||||
command
|
||||
.arg("pip")
|
||||
.arg("uninstall")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(&context.temp_dir);
|
||||
|
||||
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("UV_STACK_SIZE", (2 * 1024 * 1024).to_string());
|
||||
}
|
||||
|
||||
command
|
||||
}
|
||||
|
||||
/// Create a `pip sync` command with options shared across scenarios.
|
||||
fn sync_command(context: &TestContext) -> Command {
|
||||
let mut command = Command::new(get_bin());
|
||||
command
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(&context.temp_dir);
|
||||
|
||||
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("UV_STACK_SIZE", (8 * 1024 * 1024).to_string());
|
||||
}
|
||||
|
||||
command
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_arguments() -> Result<()> {
|
||||
let temp_dir = assert_fs::TempDir::new()?;
|
||||
|
|
@ -238,14 +278,8 @@ fn uninstall() -> Result<()> {
|
|||
requirements_txt.touch()?;
|
||||
requirements_txt.write_str("MarkupSafe==2.1.3")?;
|
||||
|
||||
Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
sync_command(&context)
|
||||
.arg("requirements.txt")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(&context.temp_dir)
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
|
|
@ -256,14 +290,8 @@ fn uninstall() -> Result<()> {
|
|||
.assert()
|
||||
.success();
|
||||
|
||||
uv_snapshot!(Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("uninstall")
|
||||
.arg("MarkupSafe")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(&context.temp_dir), @r###"
|
||||
uv_snapshot!(uninstall_command(&context)
|
||||
.arg("MarkupSafe"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
|
@ -292,14 +320,8 @@ fn missing_record() -> Result<()> {
|
|||
requirements_txt.touch()?;
|
||||
requirements_txt.write_str("MarkupSafe==2.1.3")?;
|
||||
|
||||
Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
sync_command(&context)
|
||||
.arg("requirements.txt")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(&context.temp_dir)
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
|
|
@ -342,14 +364,8 @@ fn missing_record() -> Result<()> {
|
|||
.chain(INSTA_FILTERS.to_vec())
|
||||
.collect();
|
||||
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("uninstall")
|
||||
.arg("MarkupSafe")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(&context.temp_dir), @r###"
|
||||
uv_snapshot!(filters, uninstall_command(&context)
|
||||
.arg("MarkupSafe"), @r###"
|
||||
success: false
|
||||
exit_code: 2
|
||||
----- stdout -----
|
||||
|
|
@ -382,13 +398,9 @@ fn uninstall_editable_by_name() -> Result<()> {
|
|||
requirements_txt.touch()?;
|
||||
requirements_txt.write_str("-e ../../scripts/editable-installs/poetry_editable")?;
|
||||
|
||||
Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
sync_command(&context)
|
||||
.arg(requirements_txt.path())
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
|
|
@ -399,13 +411,8 @@ fn uninstall_editable_by_name() -> Result<()> {
|
|||
.success();
|
||||
|
||||
// Uninstall the editable by name.
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("uninstall")
|
||||
.arg("poetry-editable")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str()), @r###"
|
||||
uv_snapshot!(filters, uninstall_command(&context)
|
||||
.arg("poetry-editable"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
|
@ -445,13 +452,9 @@ fn uninstall_editable_by_path() -> Result<()> {
|
|||
requirements_txt.touch()?;
|
||||
requirements_txt.write_str("-e ../../scripts/editable-installs/poetry_editable")?;
|
||||
|
||||
Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
sync_command(&context)
|
||||
.arg(requirements_txt.path())
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
|
|
@ -462,14 +465,10 @@ fn uninstall_editable_by_path() -> Result<()> {
|
|||
.success();
|
||||
|
||||
// Uninstall the editable by path.
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("uninstall")
|
||||
uv_snapshot!(filters, uninstall_command(&context)
|
||||
.arg("-e")
|
||||
.arg("../../scripts/editable-installs/poetry_editable")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str()), @r###"
|
||||
.current_dir(¤t_dir), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
|
@ -509,13 +508,9 @@ fn uninstall_duplicate_editable() -> Result<()> {
|
|||
requirements_txt.touch()?;
|
||||
requirements_txt.write_str("-e ../../scripts/editable-installs/poetry_editable")?;
|
||||
|
||||
Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
sync_command(&context)
|
||||
.arg(requirements_txt.path())
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.current_dir(¤t_dir)
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
|
|
@ -526,15 +521,11 @@ fn uninstall_duplicate_editable() -> Result<()> {
|
|||
.success();
|
||||
|
||||
// Uninstall the editable by both path and name.
|
||||
uv_snapshot!(filters, Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("uninstall")
|
||||
uv_snapshot!(filters, uninstall_command(&context)
|
||||
.arg("poetry-editable")
|
||||
.arg("-e")
|
||||
.arg("../../scripts/editable-installs/poetry_editable")
|
||||
.arg("--cache-dir")
|
||||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str()), @r###"
|
||||
.current_dir(¤t_dir), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
|
@ -567,13 +558,8 @@ fn uninstall_duplicate() -> Result<()> {
|
|||
requirements_txt.write_str("pip==21.3.1")?;
|
||||
|
||||
// Run `pip sync`.
|
||||
Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
sync_command(&context1)
|
||||
.arg(requirements_txt.path())
|
||||
.arg("--cache-dir")
|
||||
.arg(context1.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context1.venv.as_os_str())
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
|
|
@ -584,13 +570,8 @@ fn uninstall_duplicate() -> Result<()> {
|
|||
requirements_txt.write_str("pip==22.1.1")?;
|
||||
|
||||
// Run `pip sync`.
|
||||
Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("sync")
|
||||
sync_command(&context2)
|
||||
.arg(requirements_txt.path())
|
||||
.arg("--cache-dir")
|
||||
.arg(context2.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context2.venv.as_os_str())
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
|
|
@ -605,14 +586,8 @@ fn uninstall_duplicate() -> Result<()> {
|
|||
)?;
|
||||
|
||||
// Run `pip uninstall`.
|
||||
uv_snapshot!(Command::new(get_bin())
|
||||
.arg("pip")
|
||||
.arg("uninstall")
|
||||
.arg("pip")
|
||||
.arg("--cache-dir")
|
||||
.arg(context1.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context1.venv.as_os_str())
|
||||
.current_dir(&context1.temp_dir), @r###"
|
||||
uv_snapshot!(uninstall_command(&context1)
|
||||
.arg("pip"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
|
|
|||
Loading…
Reference in New Issue