mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Update BUILD_VENDOR_LINKS_URL from packse version (#3246)
Make `generate.py` update the packse version used in `BUILD_VENDOR_LINKS_URL`. Closes #3245
This commit is contained in:
parent
691b7d26a0
commit
005b76770e
2 changed files with 25 additions and 1 deletions
|
@ -25,7 +25,7 @@ pub static EXCLUDE_NEWER: &str = "2024-03-25T00:00:00Z";
|
||||||
/// 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 const BUILD_VENDOR_LINKS_URL: &str =
|
||||||
"https://raw.githubusercontent.com/astral-sh/packse/0.3.14/vendor/links.html";
|
"https://raw.githubusercontent.com/astral-sh/packse/0.3.15/vendor/links.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)] = &[
|
||||||
|
|
|
@ -39,6 +39,7 @@ import argparse
|
||||||
import importlib.metadata
|
import importlib.metadata
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
|
@ -54,6 +55,7 @@ PROJECT_ROOT = TOOL_ROOT.parent.parent
|
||||||
TESTS = PROJECT_ROOT / "crates" / "uv" / "tests"
|
TESTS = PROJECT_ROOT / "crates" / "uv" / "tests"
|
||||||
INSTALL_TESTS = TESTS / "pip_install_scenarios.rs"
|
INSTALL_TESTS = TESTS / "pip_install_scenarios.rs"
|
||||||
COMPILE_TESTS = TESTS / "pip_compile_scenarios.rs"
|
COMPILE_TESTS = TESTS / "pip_compile_scenarios.rs"
|
||||||
|
TESTS_COMMON_MOD_RS = TESTS / "common/mod.rs"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import packse
|
import packse
|
||||||
|
@ -81,6 +83,8 @@ def main(scenarios: list[Path], snapshot_update: bool = True):
|
||||||
|
|
||||||
debug = logging.getLogger().getEffectiveLevel() <= logging.DEBUG
|
debug = logging.getLogger().getEffectiveLevel() <= logging.DEBUG
|
||||||
|
|
||||||
|
update_common_mod_rs(packse_version)
|
||||||
|
|
||||||
if not scenarios:
|
if not scenarios:
|
||||||
if packse_version == "0.0.0":
|
if packse_version == "0.0.0":
|
||||||
path = packse.__development_base_path__ / "scenarios"
|
path = packse.__development_base_path__ / "scenarios"
|
||||||
|
@ -235,6 +239,26 @@ def main(scenarios: list[Path], snapshot_update: bool = True):
|
||||||
logging.info("Done!")
|
logging.info("Done!")
|
||||||
|
|
||||||
|
|
||||||
|
def update_common_mod_rs(packse_version: str):
|
||||||
|
"""Update the value of `BUILD_VENDOR_LINKS_URL` used in non-scenario tests."""
|
||||||
|
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}"
|
||||||
|
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)
|
||||||
|
)
|
||||||
|
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)
|
||||||
|
TESTS_COMMON_MOD_RS.write_text(test_common)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="Generates and updates snapshot test cases from packse scenarios.",
|
description="Generates and updates snapshot test cases from packse scenarios.",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue