Files
uv/scripts/scenarios/templates/install.mustache
T
konsti 0f87d174b9 Redact packse version in snapshots (#5483)
Every packse version update is currently causing a huge diff (the size
of the `lock_scenarios.rs` diff in this PR). By redacting the version
from the snapshots, we will only have the actual change in the diff and
not the redundant version change noise.

The second commit moves all remaining packse url arg values to
`common/mod.rs`, which acts as a single source of truth for the packse
version.
2024-07-29 17:04:46 +02:00

118 lines
3.0 KiB
Plaintext

//! DO NOT EDIT
//!
//! Generated with `{{generated_with}}`
//! Scenarios from <{{generated_from}}>
//!
#![cfg(all(feature = "python", feature = "pypi", unix))]
use std::path::Path;
use std::process::Command;
use assert_cmd::assert::Assert;
use assert_cmd::prelude::*;
use common::{venv_to_interpreter};
use crate::common::{build_vendor_links_url, get_bin, packse_index_url, uv_snapshot, TestContext};
mod common;
fn assert_command(venv: &Path, command: &str, temp_dir: &Path) -> Assert {
Command::new(venv_to_interpreter(venv))
.arg("-c")
.arg(command)
.current_dir(temp_dir)
.assert()
}
fn assert_installed(venv: &Path, package: &'static str, version: &'static str, temp_dir: &Path) {
assert_command(
venv,
format!("import {package} as package; print(package.__version__, end='')").as_str(),
temp_dir,
)
.success()
.stdout(version);
}
fn assert_not_installed(venv: &Path, package: &'static str, temp_dir: &Path) {
assert_command(venv, format!("import {package}").as_str(), temp_dir).failure();
}
/// Create a `pip install` command with options shared across all scenarios.
fn command(context: &TestContext) -> Command {
let mut command = Command::new(get_bin());
command
.arg("pip")
.arg("install")
.arg("--index-url")
.arg(packse_index_url())
.arg("--find-links")
.arg(build_vendor_links_url());
context.add_shared_args(&mut command);
command.env_remove("UV_EXCLUDE_NEWER");
command
}
{{#scenarios}}
{{#description_lines}}
/// {{.}}
{{/description_lines}}
///
/// ```text
/// {{name}}
{{#tree}}
/// {{.}}
{{/tree}}
/// ```
{{#python_patch}}
#[cfg(feature = "python-patch")]
{{/python_patch}}
#[test]
fn {{module_name}}() {
let context = TestContext::new("{{environment.python}}");
// In addition to the standard filters, swap out package names for shorter messages
let mut filters = context.filters();
filters.push((r"{{name}}-", "package-"));
uv_snapshot!(filters, command(&context)
{{#resolver_options.prereleases}}
.arg("--prerelease=allow")
{{/resolver_options.prereleases}}
{{#resolver_options.no_build}}
.arg("--only-binary")
.arg("{{.}}")
{{/resolver_options.no_build}}
{{#resolver_options.no_binary}}
.arg("--no-binary")
.arg("{{.}}")
{{/resolver_options.no_binary}}
{{#root.requires}}
.arg("{{requirement}}")
{{/root.requires}}, @r###"<snapshot>
"###);
{{#expected.explanation_lines}}
// {{.}}
{{/expected.explanation_lines}}
{{#expected.satisfiable}}
{{#expected.packages}}
assert_installed(
&context.venv,
"{{module_name}}",
"{{version}}",
&context.temp_dir
);
{{/expected.packages}}
{{/expected.satisfiable}}
{{^expected.satisfiable}}
{{#root.requires}}
assert_not_installed(&context.venv, "{{module_name}}", &context.temp_dir);
{{/root.requires}}
{{/expected.satisfiable}}
}
{{/scenarios}}