test(release): resolve real historical baseline dependencies

This commit is contained in:
Xubin Ren committed 2026-10-28 16:54:41 +08:00
1 parent 91972b0e4f
commit 656f124fe9
2 files changed
+20 -10

No files matched your search

+11 -7
View File
@@ -820,13 +820,15 @@ def run_serial(args, root: Path, target: Path, version: str, original_hash: str,
raise ValueError("Baseline must precede the target; select an earlier baseline wheel")
results = []
system = isolated_environment(root)
# Install once per lane, without inherited user pip settings; every case
# resets only nanobot. No mutable venv or dependency snapshot crosses lanes.
# Version-only fixtures share the target's dependency constraints. Real
# historical packages must resolve their own dependencies for every case.
# No mutable venv or dependency snapshot crosses lanes.
with timings.measure("venv"):
subprocess.run([sys.executable, "-I", "-B", "-m", "venv", str(environment)], check=True, env=system, timeout=90)
with timings.measure("initial_dependency_install"):
subprocess.run([str(python), "-I", "-m", "pip", "install", "--only-binary=:all:", str(target)],
check=True, env=system, timeout=600, stdout=subprocess.DEVNULL)
if not args.baseline_wheel:
with timings.measure("initial_dependency_install"):
subprocess.run([str(python), "-I", "-m", "pip", "install", "--only-binary=:all:", str(target)],
check=True, env=system, timeout=600, stdout=subprocess.DEVNULL)
write(environment / "nanobot-install.json", {"schema_version": 1, "owner": "nanobot-installer",
"environment": str(environment), "extras": []})
for scenario in scenarios:
@@ -865,8 +867,10 @@ def run_serial(args, root: Path, target: Path, version: str, original_hash: str,
"target_unmodified": selected == target}
write(case_root / "case.json", case)
with timings.measure("baseline_install", scenario=scenario, journey=1):
subprocess.run([str(python), "-I", "-m", "pip", "install", "--no-deps", "--force-reinstall", str(baseline)],
check=True, env=env, timeout=120, stdout=subprocess.DEVNULL)
dependencies = ["--only-binary=:all:"] if args.baseline_wheel else ["--no-deps"]
subprocess.run([str(python), "-I", "-m", "pip", "install", *dependencies,
"--force-reinstall", str(baseline)], check=True, env=env,
timeout=600 if args.baseline_wheel else 120, stdout=subprocess.DEVNULL)
child = [str(python), "-I", str(Path(__file__).resolve())]
# Raw logs stay private to this local evidence root, including on success.
with (case_root / "acceptance.log").open("w", encoding="utf-8") as log:
+9 -3
View File
@@ -534,7 +534,7 @@ def test_controller_error_does_not_print_exception_values_or_commands(tmp_path):
@pytest.mark.parametrize("version,baseline_version", [
("0.3.6", None), ("0.4.0", None), ("1.0.0", None), ("0.4.0", "0.3.5"),
])
def test_serial_lanes_install_dependencies_once_and_keep_recovery_chains_on_the_same_venv(
def test_serial_lanes_resolve_baseline_dependencies_and_keep_recovery_chains_on_the_same_venv(
tmp_path, monkeypatch, version, baseline_version,
):
package = Path(__file__).resolve().parents[1] / "nanobot"
@@ -549,7 +549,7 @@ def test_serial_lanes_install_dependencies_once_and_keep_recovery_chains_on_the_
installations.append(Path(command[-1]))
Path(command[-1]).mkdir()
elif "pip" in command:
(baselines if "--no-deps" in command else dependencies).append(command[0])
(baselines if "--force-reinstall" in command else dependencies).append(command)
elif "--phase" in command:
phase = command[command.index("--phase") + 1]
case_root = Path(command[command.index("--output") + 1])
@@ -583,8 +583,14 @@ def test_serial_lanes_install_dependencies_once_and_keep_recovery_chains_on_the_
args = Namespace(baseline_wheel=baseline, commit="a" * 40, dock=False)
results.extend(probe.run_serial(args, root, target, version, original_hash, scenarios,
Timings(root / "packaged-update-timings.json")))
assert len(installations) == len(dependencies) == 2 and len(set(installations)) == 2
assert len(installations) == len(set(installations)) == 2
assert len(dependencies) == (0 if baseline_version else 2)
assert len(baselines) == 9 and len(stages) == 9
for command in baselines:
# Actual historical constraints must be resolved again after each
# successful upgrade, rather than paired with the target's dependencies.
assert ("--no-deps" in command) == (baseline_version is None)
assert ("--only-binary=:all:" in command) == (baseline_version is not None)
assert sum(1 + ("subsequent_update" in result) for result in results) == 15
assert digest(target) == original_hash
upgrade = next(result for result in results if result["scenario"] == "upgrade")