mirror of https://github.com/astral-sh/uv
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.
This commit is contained in:
parent
a346d257cb
commit
0f87d174b9
|
|
@ -26,10 +26,17 @@ use uv_python::{
|
||||||
// Exclude any packages uploaded after this date.
|
// Exclude any packages uploaded after this date.
|
||||||
static EXCLUDE_NEWER: &str = "2024-03-25T00:00:00Z";
|
static EXCLUDE_NEWER: &str = "2024-03-25T00:00:00Z";
|
||||||
|
|
||||||
|
pub const PACKSE_VERSION: &str = "0.3.30";
|
||||||
|
|
||||||
/// Using a find links url allows using `--index-url` instead of `--extra-index-url` in tests
|
/// Using a find links url allows using `--index-url` instead of `--extra-index-url` in tests
|
||||||
/// to prevent dependency confusion attacks against our test suite.
|
/// to prevent dependency confusion attacks against our test suite.
|
||||||
pub const BUILD_VENDOR_LINKS_URL: &str =
|
pub fn build_vendor_links_url() -> String {
|
||||||
"https://raw.githubusercontent.com/astral-sh/packse/0.3.31/vendor/links.html";
|
format!("https://raw.githubusercontent.com/astral-sh/packse/{PACKSE_VERSION}/vendor/links.html")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn packse_index_url() -> String {
|
||||||
|
format!("https://astral-sh.github.io/packse/{PACKSE_VERSION}/simple-html/")
|
||||||
|
}
|
||||||
|
|
||||||
#[doc(hidden)] // Macro and test context only, don't use directly.
|
#[doc(hidden)] // Macro and test context only, don't use directly.
|
||||||
pub const INSTA_FILTERS: &[(&str, &str)] = &[
|
pub const INSTA_FILTERS: &[(&str, &str)] = &[
|
||||||
|
|
@ -300,6 +307,13 @@ impl TestContext {
|
||||||
// Destroy any remaining UNC prefixes (Windows only)
|
// Destroy any remaining UNC prefixes (Windows only)
|
||||||
filters.push((r"\\\\\?\\".to_string(), String::new()));
|
filters.push((r"\\\\\?\\".to_string(), String::new()));
|
||||||
|
|
||||||
|
// Remove the version from the packse url in lockfile snapshots. This avoid having a huge
|
||||||
|
// diff any time we upgrade packse
|
||||||
|
filters.push((
|
||||||
|
format!("https://astral-sh.github.io/packse/{PACKSE_VERSION}/"),
|
||||||
|
"https://astral-sh.github.io/packse/PACKSE_VERSION/".to_string(),
|
||||||
|
));
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
temp_dir,
|
temp_dir,
|
||||||
cache_dir,
|
cache_dir,
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -13,7 +13,10 @@ use assert_cmd::assert::OutputAssertExt;
|
||||||
use assert_fs::fixture::{FileWriteStr, PathChild};
|
use assert_fs::fixture::{FileWriteStr, PathChild};
|
||||||
use predicates::prelude::predicate;
|
use predicates::prelude::predicate;
|
||||||
|
|
||||||
use common::{get_bin, python_path_with_versions, uv_snapshot, TestContext};
|
use common::{
|
||||||
|
build_vendor_links_url, get_bin, packse_index_url, python_path_with_versions, uv_snapshot,
|
||||||
|
TestContext,
|
||||||
|
};
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
|
|
@ -27,9 +30,9 @@ fn command(context: &TestContext, python_versions: &[&str]) -> Command {
|
||||||
.arg("compile")
|
.arg("compile")
|
||||||
.arg("requirements.in")
|
.arg("requirements.in")
|
||||||
.arg("--index-url")
|
.arg("--index-url")
|
||||||
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
|
.arg(packse_index_url())
|
||||||
.arg("--find-links")
|
.arg("--find-links")
|
||||||
.arg("https://raw.githubusercontent.com/astral-sh/packse/0.3.31/vendor/links.html");
|
.arg(build_vendor_links_url());
|
||||||
context.add_shared_args(&mut command);
|
context.add_shared_args(&mut command);
|
||||||
command.env_remove("UV_EXCLUDE_NEWER");
|
command.env_remove("UV_EXCLUDE_NEWER");
|
||||||
command.env("UV_TEST_PYTHON_PATH", python_path);
|
command.env("UV_TEST_PYTHON_PATH", python_path);
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ use url::Url;
|
||||||
use common::{uv_snapshot, TestContext};
|
use common::{uv_snapshot, TestContext};
|
||||||
use uv_fs::Simplified;
|
use uv_fs::Simplified;
|
||||||
|
|
||||||
use crate::common::{get_bin, venv_bin_path, BUILD_VENDOR_LINKS_URL};
|
use crate::common::{build_vendor_links_url, get_bin, venv_bin_path};
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
|
|
@ -4431,7 +4431,7 @@ fn already_installed_dependent_editable() {
|
||||||
// Disable the index to guard this test against dependency confusion attacks
|
// Disable the index to guard this test against dependency confusion attacks
|
||||||
.arg("--no-index")
|
.arg("--no-index")
|
||||||
.arg("--find-links")
|
.arg("--find-links")
|
||||||
.arg(BUILD_VENDOR_LINKS_URL), @r###"
|
.arg(build_vendor_links_url()), @r###"
|
||||||
success: true
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
@ -4468,7 +4468,7 @@ fn already_installed_dependent_editable() {
|
||||||
// Disable the index to guard this test against dependency confusion attacks
|
// Disable the index to guard this test against dependency confusion attacks
|
||||||
.arg("--no-index")
|
.arg("--no-index")
|
||||||
.arg("--find-links")
|
.arg("--find-links")
|
||||||
.arg(BUILD_VENDOR_LINKS_URL), @r###"
|
.arg(build_vendor_links_url()), @r###"
|
||||||
success: false
|
success: false
|
||||||
exit_code: 1
|
exit_code: 1
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
@ -4532,7 +4532,7 @@ fn already_installed_local_path_dependent() {
|
||||||
// Disable the index to guard this test against dependency confusion attacks
|
// Disable the index to guard this test against dependency confusion attacks
|
||||||
.arg("--no-index")
|
.arg("--no-index")
|
||||||
.arg("--find-links")
|
.arg("--find-links")
|
||||||
.arg(BUILD_VENDOR_LINKS_URL), @r###"
|
.arg(build_vendor_links_url()), @r###"
|
||||||
success: true
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
@ -4567,7 +4567,7 @@ fn already_installed_local_path_dependent() {
|
||||||
// Disable the index to guard this test against dependency confusion attacks
|
// Disable the index to guard this test against dependency confusion attacks
|
||||||
.arg("--no-index")
|
.arg("--no-index")
|
||||||
.arg("--find-links")
|
.arg("--find-links")
|
||||||
.arg(BUILD_VENDOR_LINKS_URL), @r###"
|
.arg(build_vendor_links_url()), @r###"
|
||||||
success: false
|
success: false
|
||||||
exit_code: 1
|
exit_code: 1
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
@ -4609,7 +4609,7 @@ fn already_installed_local_path_dependent() {
|
||||||
// Disable the index to guard this test against dependency confusion attacks
|
// Disable the index to guard this test against dependency confusion attacks
|
||||||
.arg("--no-index")
|
.arg("--no-index")
|
||||||
.arg("--find-links")
|
.arg("--find-links")
|
||||||
.arg(BUILD_VENDOR_LINKS_URL), @r###"
|
.arg(build_vendor_links_url()), @r###"
|
||||||
success: false
|
success: false
|
||||||
exit_code: 1
|
exit_code: 1
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
@ -4631,7 +4631,7 @@ fn already_installed_local_path_dependent() {
|
||||||
// Disable the index to guard this test against dependency confusion attacks
|
// Disable the index to guard this test against dependency confusion attacks
|
||||||
.arg("--no-index")
|
.arg("--no-index")
|
||||||
.arg("--find-links")
|
.arg("--find-links")
|
||||||
.arg(BUILD_VENDOR_LINKS_URL), @r###"
|
.arg(build_vendor_links_url()), @r###"
|
||||||
success: true
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ use assert_cmd::prelude::*;
|
||||||
|
|
||||||
use common::venv_to_interpreter;
|
use common::venv_to_interpreter;
|
||||||
|
|
||||||
use crate::common::{get_bin, uv_snapshot, TestContext};
|
use crate::common::{build_vendor_links_url, get_bin, packse_index_url, uv_snapshot, TestContext};
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
|
|
@ -46,9 +46,9 @@ fn command(context: &TestContext) -> Command {
|
||||||
.arg("pip")
|
.arg("pip")
|
||||||
.arg("install")
|
.arg("install")
|
||||||
.arg("--index-url")
|
.arg("--index-url")
|
||||||
.arg("https://astral-sh.github.io/packse/0.3.31/simple-html/")
|
.arg(packse_index_url())
|
||||||
.arg("--find-links")
|
.arg("--find-links")
|
||||||
.arg("https://raw.githubusercontent.com/astral-sh/packse/0.3.31/vendor/links.html");
|
.arg(build_vendor_links_url());
|
||||||
context.add_shared_args(&mut command);
|
context.add_shared_args(&mut command);
|
||||||
command.env_remove("UV_EXCLUDE_NEWER");
|
command.env_remove("UV_EXCLUDE_NEWER");
|
||||||
command
|
command
|
||||||
|
|
|
||||||
|
|
@ -250,22 +250,28 @@ def main(scenarios: list[Path], snapshot_update: bool = True):
|
||||||
|
|
||||||
|
|
||||||
def update_common_mod_rs(packse_version: str):
|
def update_common_mod_rs(packse_version: str):
|
||||||
"""Update the value of `BUILD_VENDOR_LINKS_URL` used in non-scenario tests."""
|
"""Update the value of `PACKSE_VERSION` used in non-scenario tests.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```rust
|
||||||
|
pub const PACKSE_VERSION: &str = "0.3.30";
|
||||||
|
```
|
||||||
|
"""
|
||||||
test_common = TESTS_COMMON_MOD_RS.read_text()
|
test_common = TESTS_COMMON_MOD_RS.read_text()
|
||||||
url_before_version = "https://raw.githubusercontent.com/astral-sh/packse/"
|
before_version = 'pub const PACKSE_VERSION: &str = "'
|
||||||
url_after_version = "/vendor/links.html"
|
after_version = '";'
|
||||||
build_vendor_links_url = f"{url_before_version}{packse_version}{url_after_version}"
|
build_vendor_links_url = f"{before_version}{packse_version}{after_version}"
|
||||||
if build_vendor_links_url in test_common:
|
if build_vendor_links_url in test_common:
|
||||||
logging.info(f"Up-to-date: {TESTS_COMMON_MOD_RS}")
|
logging.info(f"Up-to-date: {TESTS_COMMON_MOD_RS}")
|
||||||
else:
|
else:
|
||||||
logging.info(f"Updating: {TESTS_COMMON_MOD_RS}")
|
logging.info(f"Updating: {TESTS_COMMON_MOD_RS}")
|
||||||
url_matcher = re.compile(
|
url_matcher = re.compile(
|
||||||
re.escape(url_before_version) + "[^/]+" + re.escape(url_after_version)
|
re.escape(before_version) + '[^"]+' + re.escape(after_version)
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
len(url_matcher.findall(test_common)) == 1
|
len(url_matcher.findall(test_common)) == 1
|
||||||
), f"BUILD_VENDOR_LINKS_URL not found in {TESTS_COMMON_MOD_RS}"
|
), f"PACKSE_VERSION not found in {TESTS_COMMON_MOD_RS}"
|
||||||
test_common = url_matcher.sub(build_vendor_links_url, test_common)
|
test_common = url_matcher.sub(packse_version, test_common)
|
||||||
TESTS_COMMON_MOD_RS.write_text(test_common)
|
TESTS_COMMON_MOD_RS.write_text(test_common)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ use assert_cmd::assert::OutputAssertExt;
|
||||||
use assert_fs::fixture::{FileWriteStr, PathChild};
|
use assert_fs::fixture::{FileWriteStr, PathChild};
|
||||||
use predicates::prelude::predicate;
|
use predicates::prelude::predicate;
|
||||||
|
|
||||||
use common::{python_path_with_versions, get_bin, uv_snapshot, TestContext};
|
use common::{build_vendor_links_url, packse_index_url, python_path_with_versions, get_bin, uv_snapshot, TestContext};
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
|
|
@ -27,9 +27,9 @@ fn command(context: &TestContext, python_versions: &[&str]) -> Command {
|
||||||
.arg("compile")
|
.arg("compile")
|
||||||
.arg("requirements.in")
|
.arg("requirements.in")
|
||||||
.arg("--index-url")
|
.arg("--index-url")
|
||||||
.arg("{{index_url}}")
|
.arg(packse_index_url())
|
||||||
.arg("--find-links")
|
.arg("--find-links")
|
||||||
.arg("{{vendor_links}}");
|
.arg(build_vendor_links_url());
|
||||||
context.add_shared_args(&mut command);
|
context.add_shared_args(&mut command);
|
||||||
command.env_remove("UV_EXCLUDE_NEWER");
|
command.env_remove("UV_EXCLUDE_NEWER");
|
||||||
command.env("UV_TEST_PYTHON_PATH", python_path);
|
command.env("UV_TEST_PYTHON_PATH", python_path);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ use assert_cmd::prelude::*;
|
||||||
|
|
||||||
use common::{venv_to_interpreter};
|
use common::{venv_to_interpreter};
|
||||||
|
|
||||||
use crate::common::{get_bin, uv_snapshot, TestContext};
|
use crate::common::{build_vendor_links_url, get_bin, packse_index_url, uv_snapshot, TestContext};
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
|
|
@ -47,9 +47,9 @@ fn command(context: &TestContext) -> Command {
|
||||||
.arg("pip")
|
.arg("pip")
|
||||||
.arg("install")
|
.arg("install")
|
||||||
.arg("--index-url")
|
.arg("--index-url")
|
||||||
.arg("{{index_url}}")
|
.arg(packse_index_url())
|
||||||
.arg("--find-links")
|
.arg("--find-links")
|
||||||
.arg("{{vendor_links}}");
|
.arg(build_vendor_links_url());
|
||||||
context.add_shared_args(&mut command);
|
context.add_shared_args(&mut command);
|
||||||
command.env_remove("UV_EXCLUDE_NEWER");
|
command.env_remove("UV_EXCLUDE_NEWER");
|
||||||
command
|
command
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use anyhow::Result;
|
||||||
use assert_fs::prelude::*;
|
use assert_fs::prelude::*;
|
||||||
use insta::assert_snapshot;
|
use insta::assert_snapshot;
|
||||||
|
|
||||||
use common::{uv_snapshot, TestContext};
|
use common::{packse_index_url, TestContext, uv_snapshot};
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@ fn {{module_name}}() -> Result<()> {
|
||||||
|
|
||||||
let mut cmd = context.lock();
|
let mut cmd = context.lock();
|
||||||
cmd.env_remove("UV_EXCLUDE_NEWER");
|
cmd.env_remove("UV_EXCLUDE_NEWER");
|
||||||
cmd.arg("--index-url").arg("{{index_url}}");
|
cmd.arg("--index-url").arg(packse_index_url());
|
||||||
{{#expected.explanation_lines}}
|
{{#expected.explanation_lines}}
|
||||||
// {{.}}
|
// {{.}}
|
||||||
{{/expected.explanation_lines}}
|
{{/expected.explanation_lines}}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue