This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""Phase-1.0CC exact derived-output cleanup guardrails."""
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--root", type=Path, required=True)
|
||||
root = parser.parse_args().root
|
||||
|
||||
|
||||
class Phase10CCGuardrails(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls) -> None:
|
||||
cls.data = json.loads((root / "manifests/retroarch/phase-1.0cc-cmake-timeout-and-exact-output-cleanup-gate.json").read_text(encoding="utf-8"))
|
||||
|
||||
def test_parent_and_bounded_stop(self) -> None:
|
||||
parent = root / "manifests/retroarch/phase-1.0cb-hash-verified-sdl-materializer-one-shot-gate.json"
|
||||
self.assertEqual(hashlib.sha256(parent.read_bytes()).hexdigest(), self.data["source_bindings"]["phase10cb_manifest_sha256"])
|
||||
result = self.data["consumed_attempt"]
|
||||
self.assertEqual(result["failed_operation"], "cmake_configure_sdl_only")
|
||||
self.assertEqual(result["timeout_seconds"], 120)
|
||||
self.assertTrue(result["process_group_terminated"])
|
||||
self.assertTrue(result["cmake_cache_absent_after"])
|
||||
self.assertTrue(result["archive_absent_after"])
|
||||
self.assertRegex(result["configure_log_sha256"], r"^[0-9a-f]{64}$")
|
||||
|
||||
def test_cleanup_is_exact_and_nonretrying(self) -> None:
|
||||
cleanup = self.data["cleanup"]
|
||||
self.assertEqual(cleanup["attempts_authorized"], 1)
|
||||
self.assertTrue(cleanup["stage"].endswith(
|
||||
"/build/phase10bd/sdl-source"))
|
||||
self.assertTrue(cleanup["build"].endswith(
|
||||
"/build/phase10bd/sdl-build"))
|
||||
self.assertTrue(cleanup["stage_git_worktree_remove_force"])
|
||||
self.assertTrue(cleanup["build_recursive_remove_after_absolute_containment_check"])
|
||||
self.assertFalse(cleanup["other_worktree_cleanup_authorized"])
|
||||
self.assertFalse(cleanup["automatic_retry"])
|
||||
|
||||
def test_only_exact_cleanup_is_open(self) -> None:
|
||||
auth = self.data["authorizations"]
|
||||
self.assertTrue(auth["exact_derived_output_cleanup_authorized"])
|
||||
for key, value in auth.items():
|
||||
if key != "exact_derived_output_cleanup_authorized":
|
||||
self.assertFalse(value, key)
|
||||
self.assertFalse(self.data["decision"]["source_change_allowed"])
|
||||
self.assertFalse(self.data["decision"]["materialization_allowed"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(argv=[__file__])
|
||||
Reference in New Issue
Block a user