#!/usr/bin/env python3 """Run preserved AT-SPI upstream unit tests in a temporary standalone workspace. Cargo cannot directly test dev-dependencies of an excluded patched dependency. This copies the exact patched sources (including XML fixtures), enables no test exclusions, and uses this repository's maintained dependency backports. """ from pathlib import Path import shutil import subprocess import tempfile patches = Path(__file__).resolve().parent project = patches.parent with tempfile.TemporaryDirectory(prefix="vnox-upstream-tests-") as temporary: package = Path(temporary) / "atspi-common" shutil.copytree( patches / "atspi-common", package, ignore=shutil.ignore_patterns("target", "Cargo.lock"), ) command = [ "cargo", "test", "--manifest-path", str(package / "Cargo.toml"), "--lib", "--target-dir", str(project / "target"), ] for dependency in ("zbus-lockstep", "zbus-lockstep-macros"): command.extend([ "--config", f'patch.crates-io.{dependency}.path="{patches / dependency}"', ]) raise SystemExit(subprocess.run(command, cwd=project).returncode)