mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +00:00
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
9 changed files with 274 additions and 537 deletions
|
@ -250,22 +250,28 @@ def main(scenarios: list[Path], snapshot_update: bool = True):
|
|||
|
||||
|
||||
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()
|
||||
url_before_version = "https://raw.githubusercontent.com/astral-sh/packse/"
|
||||
url_after_version = "/vendor/links.html"
|
||||
build_vendor_links_url = f"{url_before_version}{packse_version}{url_after_version}"
|
||||
before_version = 'pub const PACKSE_VERSION: &str = "'
|
||||
after_version = '";'
|
||||
build_vendor_links_url = f"{before_version}{packse_version}{after_version}"
|
||||
if build_vendor_links_url in test_common:
|
||||
logging.info(f"Up-to-date: {TESTS_COMMON_MOD_RS}")
|
||||
else:
|
||||
logging.info(f"Updating: {TESTS_COMMON_MOD_RS}")
|
||||
url_matcher = re.compile(
|
||||
re.escape(url_before_version) + "[^/]+" + re.escape(url_after_version)
|
||||
re.escape(before_version) + '[^"]+' + re.escape(after_version)
|
||||
)
|
||||
assert (
|
||||
len(url_matcher.findall(test_common)) == 1
|
||||
), f"BUILD_VENDOR_LINKS_URL not found in {TESTS_COMMON_MOD_RS}"
|
||||
test_common = url_matcher.sub(build_vendor_links_url, test_common)
|
||||
), f"PACKSE_VERSION not found in {TESTS_COMMON_MOD_RS}"
|
||||
test_common = url_matcher.sub(packse_version, 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 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;
|
||||
|
||||
|
@ -27,9 +27,9 @@ fn command(context: &TestContext, python_versions: &[&str]) -> Command {
|
|||
.arg("compile")
|
||||
.arg("requirements.in")
|
||||
.arg("--index-url")
|
||||
.arg("{{index_url}}")
|
||||
.arg(packse_index_url())
|
||||
.arg("--find-links")
|
||||
.arg("{{vendor_links}}");
|
||||
.arg(build_vendor_links_url());
|
||||
context.add_shared_args(&mut command);
|
||||
command.env_remove("UV_EXCLUDE_NEWER");
|
||||
command.env("UV_TEST_PYTHON_PATH", python_path);
|
||||
|
|
|
@ -13,7 +13,7 @@ use assert_cmd::prelude::*;
|
|||
|
||||
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;
|
||||
|
||||
|
@ -47,9 +47,9 @@ fn command(context: &TestContext) -> Command {
|
|||
.arg("pip")
|
||||
.arg("install")
|
||||
.arg("--index-url")
|
||||
.arg("{{index_url}}")
|
||||
.arg(packse_index_url())
|
||||
.arg("--find-links")
|
||||
.arg("{{vendor_links}}");
|
||||
.arg(build_vendor_links_url());
|
||||
context.add_shared_args(&mut command);
|
||||
command.env_remove("UV_EXCLUDE_NEWER");
|
||||
command
|
||||
|
|
|
@ -10,7 +10,7 @@ use anyhow::Result;
|
|||
use assert_fs::prelude::*;
|
||||
use insta::assert_snapshot;
|
||||
|
||||
use common::{uv_snapshot, TestContext};
|
||||
use common::{packse_index_url, TestContext, uv_snapshot};
|
||||
|
||||
mod common;
|
||||
|
||||
|
@ -53,7 +53,7 @@ fn {{module_name}}() -> Result<()> {
|
|||
|
||||
let mut cmd = context.lock();
|
||||
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}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue