Integrate the ignored-workspace corpus into verification
Give the Git Sentry launch shape one Rust owner, update the physical corpus to supply every authority, and make the default repository gate distinguish unavailable physical prerequisites from corpus failures.
This commit is contained in:
parent
bda342890f
commit
a0055f67f1
1 changed files with 210 additions and 17 deletions
|
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||
import copy
|
||||
import importlib.machinery
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import unittest
|
||||
|
|
@ -15,6 +16,12 @@ LOADER = importlib.machinery.SourceFileLoader(
|
|||
SPEC = importlib.util.spec_from_loader(LOADER.name, LOADER)
|
||||
VERIFY = importlib.util.module_from_spec(SPEC)
|
||||
LOADER.exec_module(VERIFY)
|
||||
CORPUS_LOADER = importlib.machinery.SourceFileLoader(
|
||||
"ignored_workspace_verifier", str(ROOT / "tools/ignored_workspace_verifier.py")
|
||||
)
|
||||
CORPUS_SPEC = importlib.util.spec_from_loader(CORPUS_LOADER.name, CORPUS_LOADER)
|
||||
CORPUS = importlib.util.module_from_spec(CORPUS_SPEC)
|
||||
CORPUS_LOADER.exec_module(CORPUS)
|
||||
|
||||
|
||||
class VerificationTests(unittest.TestCase):
|
||||
|
|
@ -414,6 +421,59 @@ class VerificationTests(unittest.TestCase):
|
|||
with self.assertRaisesRegex(VERIFY.VerificationError, "physical test exited 1"):
|
||||
VERIFY.run_physical(["physical"])
|
||||
|
||||
def test_ignored_workspace_corpus_inventory_has_an_executable_owner(self) -> None:
|
||||
inventory = json.loads(
|
||||
(
|
||||
ROOT / "tests/fixtures/ignored-workspace-v1/corpus.json"
|
||||
).read_text()
|
||||
)["cases"]
|
||||
implemented = set(CORPUS.CASE_GROUPS) | {"linked-worktree-index", "git-sentry"}
|
||||
self.assertEqual({case["id"] for case in inventory}, implemented)
|
||||
|
||||
def test_git_sentry_launch_uses_every_production_authority(self) -> None:
|
||||
self.assertEqual(
|
||||
CORPUS.git_sentry_command(
|
||||
"sentry", "workspace", "common", "hooks", "config"
|
||||
),
|
||||
["sentry", "workspace", "common", "hooks", "config"],
|
||||
)
|
||||
|
||||
def test_ignored_workspace_prerequisite_absence_is_specific(self) -> None:
|
||||
with mock.patch.object(CORPUS.sys, "platform", "darwin"):
|
||||
self.assertEqual(CORPUS.unavailable_physical_prerequisite(), "Linux is required")
|
||||
with (
|
||||
mock.patch.object(CORPUS.sys, "platform", "linux"),
|
||||
mock.patch.object(CORPUS.shutil, "which", return_value=None),
|
||||
):
|
||||
self.assertEqual(
|
||||
CORPUS.unavailable_physical_prerequisite(), "git is unavailable"
|
||||
)
|
||||
|
||||
def test_default_verifier_runs_the_complete_ignored_workspace_corpus(self) -> None:
|
||||
binaries = {
|
||||
"lazaret-ignored-workspace": Path("/build/router"),
|
||||
"lazaret-git-sentry": Path("/build/sentry"),
|
||||
}
|
||||
commands = []
|
||||
with (
|
||||
mock.patch.object(VERIFY, "build_workspace_binaries", return_value=binaries),
|
||||
mock.patch.object(
|
||||
VERIFY,
|
||||
"run_physical",
|
||||
side_effect=lambda command, cwd=VERIFY.ROOT: commands.append(command),
|
||||
),
|
||||
):
|
||||
VERIFY.run_ignored_workspace_corpus({})
|
||||
[command] = commands
|
||||
self.assertEqual(
|
||||
command[0:2],
|
||||
[VERIFY.sys.executable, str(ROOT / "tools/ignored_workspace_verifier.py")],
|
||||
)
|
||||
self.assertIn("corpus", command)
|
||||
self.assertIn(str(binaries["lazaret-ignored-workspace"]), command)
|
||||
self.assertIn(str(binaries["lazaret-git-sentry"]), command)
|
||||
self.assertNotIn("--case", command)
|
||||
|
||||
def test_advisory_refresh_checks_versions_before_mutation(self) -> None:
|
||||
events = []
|
||||
original_versions = VERIFY.check_tool_versions
|
||||
|
|
|
|||
Loading…
Reference in a new issue