mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +00:00
Improve scenario update script (#759)
Following #757, improves the script for generating scenario test cases with: - A requirements file - Support for downloading packse scenarios from GitHub dynamically - Running rustfmt on the generated test file - Updating snapshots / running tests
This commit is contained in:
parent
bf9e9daa39
commit
0d5252580c
4 changed files with 146 additions and 57 deletions
|
@ -1,56 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
#
|
||||
# Generates snapshot test cases from packse scenarios.
|
||||
#
|
||||
# Usage:
|
||||
# $ scripts/scenarios/generate.py > crates/puffin-cli/tests/pip_install_scenarios.rs
|
||||
|
||||
try:
|
||||
import packse
|
||||
except ImportError:
|
||||
print("packse must be installed")
|
||||
exit(1)
|
||||
|
||||
|
||||
try:
|
||||
import chevron_blue
|
||||
except ImportError:
|
||||
print("chevron-blue must be installed")
|
||||
exit(1)
|
||||
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
__dir__ = Path(__file__).parent
|
||||
|
||||
TEMPLATE = __dir__ / "template.mustache"
|
||||
DATA = __dir__ / "data.json"
|
||||
|
||||
data = json.loads(
|
||||
subprocess.check_output(
|
||||
[
|
||||
"packse",
|
||||
"inspect",
|
||||
str(packse.__development_base_path__ / "scenarios"),
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
# Add a generated
|
||||
data["generated_by"] = f"Generated by `{' '.join(sys.argv)}`"
|
||||
|
||||
# Add normalized names for tests
|
||||
for scenario in data["scenarios"]:
|
||||
scenario["normalized_name"] = scenario["name"].replace("-", "_")
|
||||
|
||||
# Drop the example scenario
|
||||
for index, scenario in enumerate(data["scenarios"]):
|
||||
if scenario["name"] == "example":
|
||||
data["scenarios"].pop(index)
|
||||
|
||||
output = chevron_blue.render(template=TEMPLATE.read_text(), data=data, no_escape=True)
|
||||
|
||||
print(output)
|
Loading…
Add table
Add a link
Reference in a new issue