| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554 |
- import hashlib
- import json
- import re
- import subprocess
- import tempfile
- import unittest
- import xml.etree.ElementTree as ET
- from pathlib import Path
- from unittest.mock import patch
- from tools import codex_harness
- from tools import prod2u_p4_harness
- from tools import prod2u_p4_normal_v3_build
- ROOT = Path(__file__).resolve().parents[2]
- PROJECT = ROOT / "projects" / "prod2u-door-temp" / "project.json"
- CONVERGENCE_RUN_ID = "b2a3230e66f74a35bb74ac6730e58bb5"
- CONVERGENCE_BRANCH = "codex/final-convergence-" + CONVERGENCE_RUN_ID
- ASSIGNED_BASE_COMMIT = "2084c0ea56aa02918232660305304e15035b6d5d"
- OWNED_TEST_PATHS = [
- "tests/unit/test_project_config.py",
- "tests/unit/test_phase1_contract.py",
- "tests/unit/test_codex_harness.py",
- "tests/unit/test_native_multi_agent_contract.py",
- "tests/unit/test_project_generation.py",
- "config/prod2u_p4_verification_targets_v1.json",
- ]
- def _current_full_commit() -> str:
- return codex_harness._run_git(ROOT, ["rev-parse", "HEAD"]).stdout.decode("ascii").strip()
- def _current_short_commit() -> str:
- return codex_harness.current_commit8(ROOT)
- def _report_base(*, run_id: str = CONVERGENCE_RUN_ID, task_id: str = "audit") -> dict:
- return {
- "schema": codex_harness.AGENT_TASK_REPORT_SCHEMA,
- "run_id": run_id,
- "task_id": task_id,
- "dependencies": [],
- "assigned_base_commit": ASSIGNED_BASE_COMMIT,
- "result_commit": None,
- "integration_commit": None,
- "feature_branch": CONVERGENCE_BRANCH,
- "worktree": str(ROOT),
- "owned_paths": list(OWNED_TEST_PATHS),
- "native_thread": {
- "model_policy": "unconstrained",
- "reasoning_effort_policy": "unconstrained",
- "observed_model": None,
- "observed_reasoning_effort": None,
- "model_selection_source": "not_exposed",
- "effort_selection_source": "not_exposed",
- "observation_source": "not_exposed",
- "observed_permission_mode": "not_exposed",
- },
- "status": "completed",
- "read_only_report": "read-only evidence",
- }
- class CodexHarnessTests(unittest.TestCase):
- def test_run_id_is_lowercase_32_hex(self):
- value = codex_harness.new_run_id()
- self.assertRegex(value, r"^[0-9a-f]{32}$")
- def test_source_manifest_is_project_bound_and_excludes_legacy_protocol_sources(self):
- manifest = codex_harness.build_source_manifest(Path.cwd())
- paths = manifest["sources"]
- self.assertIn("src/top/prod2u_p4_normal_v3_top.v", paths)
- self.assertIn("src/common/frame_rx.v", paths)
- self.assertNotIn("src/rtl/binary921_crc16.v", paths)
- self.assertNotIn("src/rtl/binary921_frame_tx.v", paths)
- self.assertEqual(manifest["project_id"], "prod2u-door-temp")
- self.assertRegex(manifest["project_sha256"], r"^[0-9a-f]{64}$")
- def test_unverified_package_binds_commit_project_and_bitstream_hash(self):
- with tempfile.TemporaryDirectory() as directory:
- root = Path(directory)
- bitstream = root / "candidate.bit"
- bitstream.write_bytes(b"candidate-bitstream")
- package = codex_harness.create_unverified_package(
- bitstream=bitstream,
- project=PROJECT,
- commit=_current_short_commit(),
- run_id="a" * 32,
- output_root=root / "dist",
- )
- manifest = json.loads((package / "package_manifest.json").read_text(encoding="utf-8"))
- self.assertEqual(manifest["status"], "UNVERIFIED")
- self.assertEqual(manifest["commit"], _current_short_commit())
- self.assertEqual(manifest["commit_full"], _current_full_commit())
- self.assertEqual(manifest["run_id"], "a" * 32)
- self.assertEqual(
- manifest["bitstream_sha256"],
- hashlib.sha256(b"candidate-bitstream").hexdigest(),
- )
- self.assertTrue((package / "fw.bit").is_file())
- self.assertEqual(package.name, _current_short_commit() + "-" + manifest["bitstream_sha256"][:16])
- package_info = json.loads((package / "package-info.json").read_text(encoding="utf-8"))
- self.assertEqual(package_info["schema"], "prod2u-p4-normal-v3-folder-package-info-v3")
- self.assertEqual(package_info["bitstream"], "fw.bit")
- self.assertEqual(package_info["bitstream_sha256"], manifest["bitstream_sha256"])
- self.assertTrue((package / "protocol.md").is_file())
- self.assertTrue((package / "requirements.zh-CN.md").is_file())
- self.assertTrue((package / "source_manifest.json").is_file())
- self.assertTrue((package / "verification_targets.json").is_file())
- for relative in (
- "evidence/td-primary-receipt.json",
- "evidence/td-confirmation-receipt.json",
- "evidence/python-unit-receipt.json",
- "evidence/icarus-receipt.json",
- "evidence/verilator-receipt.json",
- "evidence/cocotb-receipt.json",
- "evidence/formal-receipt.json",
- "evidence/validation-summary.json",
- ):
- self.assertTrue((package / relative).is_file(), relative)
- def test_early_unverified_package_binds_full_production_and_input_receipt_hashes(self):
- with tempfile.TemporaryDirectory() as directory:
- root = Path(directory)
- bitstream = root / "candidate.bit"
- bitstream.write_bytes(b"early-candidate-bitstream")
- td_receipt = root / "td-primary.json"
- td_receipt.write_text(
- '{"schema":"td","status":"pass"}\n', encoding="utf-8"
- )
- source_manifest = codex_harness.build_source_manifest()
- source_manifest_bytes = (
- json.dumps(source_manifest, indent=2, sort_keys=True) + "\n"
- ).encode("utf-8")
- expected_source_manifest_sha256 = hashlib.sha256(source_manifest_bytes).hexdigest()
- expected_td_receipt_sha256 = hashlib.sha256(td_receipt.read_bytes()).hexdigest()
- production_commit = _current_full_commit()
- package = codex_harness.create_unverified_package(
- bitstream=bitstream,
- project=PROJECT,
- commit=_current_short_commit(),
- production_integration_commit=production_commit,
- source_manifest_sha256=expected_source_manifest_sha256,
- td_receipt_sha256=expected_td_receipt_sha256,
- package_class="UNVERIFIED_EARLY_BUILD",
- run_id="9" * 32,
- output_root=root / "dist",
- td_receipt=td_receipt,
- )
- manifest = json.loads((package / "package_manifest.json").read_text(encoding="utf-8"))
- package_info = json.loads((package / "package-info.json").read_text(encoding="utf-8"))
- bound_td = package / "evidence" / "td-primary-receipt.json"
- bound_td_value = json.loads(bound_td.read_text(encoding="utf-8"))
- self.assertEqual(manifest["status"], "UNVERIFIED")
- self.assertEqual(manifest["package_class"], "UNVERIFIED_EARLY_BUILD")
- self.assertEqual(manifest["commit"], _current_short_commit())
- self.assertEqual(manifest["commit_full"], _current_full_commit())
- self.assertEqual(manifest["production_integration_commit"], production_commit)
- self.assertEqual(manifest["source_manifest_sha256"], expected_source_manifest_sha256)
- self.assertEqual(manifest["bitstream_sha256"], hashlib.sha256(bitstream.read_bytes()).hexdigest())
- self.assertEqual(
- bound_td_value["source_receipt_sha256"], expected_td_receipt_sha256
- )
- self.assertEqual(
- manifest["td_receipt_sha256"], hashlib.sha256(bound_td.read_bytes()).hexdigest()
- )
- self.assertEqual(package_info["production_integration_commit"], production_commit)
- self.assertEqual(package_info["source_manifest_sha256"], expected_source_manifest_sha256)
- self.assertEqual(package_info["package_class"], "UNVERIFIED_EARLY_BUILD")
- def test_early_unverified_package_rejects_mismatched_binding_hashes(self):
- with tempfile.TemporaryDirectory() as directory:
- root = Path(directory)
- bitstream = root / "candidate.bit"
- bitstream.write_bytes(b"early-candidate-bitstream")
- td_receipt = root / "td-primary.json"
- td_receipt.write_text(
- '{"schema":"td","status":"pass"}\n', encoding="utf-8"
- )
- kwargs = {
- "bitstream": bitstream,
- "project": PROJECT,
- "commit": _current_short_commit(),
- "production_integration_commit": "b" * 40,
- "source_manifest_sha256": "c" * 64,
- "td_receipt_sha256": "d" * 64,
- "package_class": "UNVERIFIED_EARLY_BUILD",
- "run_id": "a" * 32,
- "output_root": root / "dist",
- "td_receipt": td_receipt,
- }
- with self.assertRaisesRegex(ValueError, "source manifest"):
- codex_harness.create_unverified_package(**kwargs)
- def test_early_package_selftest_accepts_and_detects_production_binding_tamper(self):
- with tempfile.TemporaryDirectory() as directory:
- root = Path(directory)
- bitstream = root / "candidate.bit"
- bitstream.write_bytes(b"early-selftest-bitstream")
- td_receipt = root / "td-primary.json"
- td_receipt.write_text(
- '{"schema":"td","status":"pass"}\n', encoding="utf-8"
- )
- source_manifest = codex_harness.build_source_manifest()
- expected_source_manifest_sha256 = hashlib.sha256(
- (json.dumps(source_manifest, indent=2, sort_keys=True) + "\n").encode(
- "utf-8"
- )
- ).hexdigest()
- expected_td_receipt_sha256 = hashlib.sha256(td_receipt.read_bytes()).hexdigest()
- run_id = "8" * 32
- production_commit = _current_full_commit()
- package = codex_harness.create_unverified_package(
- bitstream=bitstream,
- project=PROJECT,
- commit=_current_short_commit(),
- production_integration_commit=production_commit,
- source_manifest_sha256=expected_source_manifest_sha256,
- td_receipt_sha256=expected_td_receipt_sha256,
- package_class="UNVERIFIED_EARLY_BUILD",
- run_id=run_id,
- output_root=root / "dist",
- td_receipt=td_receipt,
- )
- valid = prod2u_p4_harness.package_selftest_payload(
- package, verification_run_id=run_id
- )
- self.assertEqual(valid["status"], "fail")
- self.assertTrue(valid["failures"])
- package_info_path = package / "package-info.json"
- package_info = json.loads(package_info_path.read_text(encoding="utf-8"))
- package_info["production_integration_commit"] = "f" * 40
- package_info_path.write_text(
- json.dumps(package_info, indent=2, sort_keys=True) + "\n",
- encoding="utf-8",
- newline="\n",
- )
- tampered = prod2u_p4_harness.package_selftest_payload(
- package, verification_run_id=run_id
- )
- self.assertEqual(tampered["status"], "fail")
- self.assertTrue(tampered["failures"])
- self.assertIn(
- "early_manifest_commit_mismatch",
- " ".join(tampered["failures"]),
- )
- def test_unverified_package_matches_prod2u_selftest_contract(self):
- with tempfile.TemporaryDirectory() as directory:
- root = Path(directory)
- bitstream = root / "candidate.bit"
- bitstream.write_bytes(b"candidate-bitstream")
- package = codex_harness.create_unverified_package(
- bitstream=bitstream,
- project=PROJECT,
- commit=_current_short_commit(),
- run_id="b" * 32,
- output_root=root / "dist",
- )
- receipt = prod2u_p4_harness.package_selftest_payload(
- package,
- verification_run_id="b" * 32,
- )
- self.assertEqual(receipt["status"], "fail")
- self.assertTrue(receipt["failures"])
- def test_supplied_receipt_is_copied_with_package_bindings(self):
- with tempfile.TemporaryDirectory() as directory:
- root = Path(directory)
- bitstream = root / "candidate.bit"
- bitstream.write_bytes(b"candidate-bitstream")
- source_receipt = root / "icarus.json"
- source_receipt.write_text('{"schema":"hdl","status":"pass"}\n', encoding="utf-8")
- package = codex_harness.create_unverified_package(
- bitstream=bitstream,
- project=PROJECT,
- commit=_current_short_commit(),
- run_id="c" * 32,
- output_root=root / "dist",
- verification_receipts={"icarus": source_receipt},
- )
- bound = json.loads((package / "evidence/icarus-receipt.json").read_text(encoding="utf-8"))
- self.assertEqual(bound["status"], "pass")
- self.assertEqual(bound["verification_run_id"], "c" * 32)
- self.assertEqual(bound["commit"], _current_full_commit())
- self.assertEqual(bound["commit_full"], _current_full_commit())
- self.assertRegex(bound["project_config_sha256"], r"^[0-9a-f]{64}$")
- self.assertRegex(bound["source_receipt_sha256"], r"^[0-9a-f]{64}$")
- def test_build_source_list_and_build_info_use_only_the_new_contract(self):
- sources = prod2u_p4_normal_v3_build.PRODUCTION_RTL_SOURCES
- self.assertIn("src/common/frame_rx.v", sources)
- self.assertIn("src/modules/shared_500us_tick.v", sources)
- self.assertIn("src/modules/host_watchdog.v", sources)
- self.assertIn("src/top/prod2u_p4_normal_v3_top.v", sources)
- self.assertNotIn("src/rtl/binary921_crc16.v", sources)
- self.assertNotIn("src/rtl/prod2u_p4_normal_v3_watchdog.v", sources)
- with tempfile.TemporaryDirectory() as directory:
- bitstream = Path(directory) / "candidate.bit"
- bitstream.write_bytes(b"candidate")
- info = prod2u_p4_normal_v3_build.create_build_info(
- bitstream=bitstream,
- commit=_current_short_commit(),
- )
- self.assertEqual(info["serial"], {"baud": 115200, "format": "8N1", "flow_control": "none"})
- self.assertEqual(
- info["hardware_access"],
- {"com": False, "jtag": False, "programming": False, "drivers": False},
- )
- def test_source_closure_is_bidirectional_across_manifest_build_and_td_consumers(self):
- generated = json.loads(
- (ROOT / "src" / "generated" / "td-source-manifest.json").read_text(encoding="utf-8")
- )
- canonical = generated["sources"]
- self.assertEqual(canonical, list(prod2u_p4_normal_v3_build.PRODUCTION_RTL_SOURCES))
- self.assertEqual(canonical, codex_harness.build_source_manifest(ROOT)["sources"])
- project = ET.parse(ROOT / "td" / "prod2u_p4_normal_v3.prj")
- td_project_sources = [
- Path(node.attrib["Path"]).as_posix().removeprefix("../")
- for node in project.findall(".//Verilog/File")
- ]
- self.assertEqual(td_project_sources, canonical)
- syn = (ROOT / "td" / "syn" / "prod2u_p4_normal_v3.tcl").read_text(encoding="ascii")
- tcl_sources = [
- Path(match).as_posix()
- for match in re.findall(r"analyze\s+-file\s+\{([^}]+)\}", syn)
- ]
- self.assertEqual(tcl_sources, canonical)
- self.assertEqual(len(canonical), len(set(canonical)))
- self.assertTrue(all((ROOT / source).is_file() for source in canonical))
- def test_runtime_profile_is_the_new_115200_contract(self):
- self.assertEqual(
- prod2u_p4_harness.RUNTIME_PROFILE,
- "prod2u-door-temp-115200-v1",
- )
- def test_qor_attribute_count_accepts_td_gate_qor_name(self):
- with tempfile.TemporaryDirectory() as directory:
- root = Path(directory)
- (root / "gate.qor").write_text(
- "| #async_reg | 6 |\n",
- encoding="ascii",
- )
- observed = prod2u_p4_harness.parse_qor_attribute_count(
- root / "prod2u_p4_normal_v3_gate.qor",
- "async_reg",
- )
- self.assertEqual(observed, 6)
- def test_verification_inventory_uses_only_the_current_manifest(self):
- manifest = prod2u_p4_harness.load_target_manifest()
- self.assertEqual(
- manifest["schema"],
- "prod2u-simple-verification-target-manifest-v1",
- )
- self.assertEqual(
- [target["name"] for target in prod2u_p4_harness.cocotb_tests()],
- ["prod2u_door_temp_uart_e2e"],
- )
- self.assertEqual(
- [target["name"] for target in prod2u_p4_harness.formal_targets()],
- [
- "frame_command_contract",
- "frame_tx_contract",
- "output_target_ram_contract",
- "simple_frame_contract",
- "simple_motor_temperature_contract",
- "pwm_scheduler_contract",
- "host_watchdog_contract",
- ],
- )
- icarus_names = [target["name"] for target in prod2u_p4_harness.hdl_testbenches()]
- self.assertEqual(
- icarus_names,
- sorted(manifest["layers"]["icarus"]),
- )
- def test_agent_task_report_accepts_unconstrained_observations_and_full_commits(self):
- report = _report_base(task_id="capability_probe")
- report["result_commit"] = _current_full_commit()
- report["read_only_report"] = None
- validated = codex_harness.validate_agent_task_report(
- report,
- expected_run_id=CONVERGENCE_RUN_ID,
- expected_base_commit=ASSIGNED_BASE_COMMIT,
- root=ROOT,
- )
- self.assertEqual(validated["assigned_base_commit"], ASSIGNED_BASE_COMMIT)
- self.assertEqual(validated["feature_branch"], CONVERGENCE_BRANCH)
- self.assertEqual(validated["worktree"], str(ROOT))
- def test_agent_task_report_accepts_read_only_report_with_unexposed_observations(self):
- report = _report_base(task_id="repo_process_audit")
- report["native_thread"]["observed_model"] = None
- report["native_thread"]["observed_reasoning_effort"] = None
- validated = codex_harness.validate_agent_task_report(
- report,
- expected_run_id=CONVERGENCE_RUN_ID,
- expected_base_commit=ASSIGNED_BASE_COMMIT,
- )
- self.assertEqual(validated["read_only_report"], "read-only evidence")
- def test_agent_task_report_rejects_stale_assigned_base(self):
- report = _report_base(task_id="stale")
- report["assigned_base_commit"] = "0" * 40
- with self.assertRaisesRegex(ValueError, "stale"):
- codex_harness.validate_agent_task_report(
- report,
- expected_run_id=CONVERGENCE_RUN_ID,
- expected_base_commit=ASSIGNED_BASE_COMMIT,
- )
- def test_agent_task_report_rejects_dependency_mismatch_but_preserves_integration_conflict(self):
- report = _report_base(task_id="dependent")
- report["dependencies"] = [
- {"task_id": "producer", "result_commit": "2" * 40, "integration_commit": None}
- ]
- report["status"] = "integration_conflict"
- report["read_only_report"] = "conflicting paths"
- with self.assertRaisesRegex(ValueError, "dependency"):
- codex_harness.validate_agent_task_report(
- report,
- expected_run_id=CONVERGENCE_RUN_ID,
- expected_base_commit=ASSIGNED_BASE_COMMIT,
- expected_dependencies={
- "producer": {"result_commit": "3" * 40, "integration_commit": None}
- },
- )
- report["dependencies"][0]["result_commit"] = "3" * 40
- validated = codex_harness.validate_agent_task_report(
- report,
- expected_run_id=CONVERGENCE_RUN_ID,
- expected_base_commit=ASSIGNED_BASE_COMMIT,
- expected_dependencies={
- "producer": {"result_commit": "3" * 40, "integration_commit": None}
- },
- )
- self.assertEqual(validated["status"], "integration_conflict")
- def test_agent_task_report_rejects_duplicate_dependencies(self):
- report = _report_base(task_id="duplicate-dependency")
- report["dependencies"] = [
- {"task_id": "producer", "result_commit": None, "integration_commit": None},
- {"task_id": "producer", "result_commit": None, "integration_commit": None},
- ]
- with self.assertRaisesRegex(ValueError, "duplicate dependency"):
- codex_harness.validate_agent_task_report(
- report,
- expected_run_id=CONVERGENCE_RUN_ID,
- expected_base_commit=ASSIGNED_BASE_COMMIT,
- )
- def test_worktree_identity_rejects_protected_root_wrong_branch_and_wrong_head(self):
- with self.assertRaisesRegex(ValueError, "protected_worktree_violation"):
- codex_harness.validate_worktree_identity(ROOT, protected_root=ROOT)
- with self.assertRaisesRegex(ValueError, "branch"):
- codex_harness.validate_worktree_identity(
- ROOT, expected_branch=CONVERGENCE_BRANCH + "-wrong"
- )
- with self.assertRaisesRegex(ValueError, "HEAD"):
- codex_harness.validate_worktree_identity(ROOT, expected_head="0" * 40)
- def test_agent_task_report_rejects_non_worktree_report_cwd(self):
- report = _report_base(task_id="wrong-cwd")
- report["worktree"] = str(ROOT / "tools")
- with self.assertRaisesRegex(ValueError, "worktree root mismatch"):
- codex_harness.validate_agent_task_report(
- report,
- expected_run_id=CONVERGENCE_RUN_ID,
- expected_base_commit=ASSIGNED_BASE_COMMIT,
- )
- def test_package_rejects_noncanonical_project_input(self):
- with tempfile.TemporaryDirectory() as directory:
- root = Path(directory)
- bitstream = root / "candidate.bit"
- bitstream.write_bytes(b"candidate-bitstream")
- fake_project = root / "project.json"
- fake_project.write_text('{"project_id":"prod2u-door-temp"}\n', encoding="utf-8")
- with self.assertRaisesRegex(ValueError, "canonical project"):
- codex_harness.create_unverified_package(
- bitstream=bitstream,
- project=fake_project,
- commit=_current_short_commit(),
- run_id=CONVERGENCE_RUN_ID,
- output_root=root / "dist",
- )
- def test_name_status_z_parses_rename_and_copy_paths(self):
- events = codex_harness.parse_name_status_z(
- b"R100\0old.txt\0new.txt\0C100\0source.txt\0copy.txt\0M\0owned.txt\0"
- )
- self.assertEqual(
- events,
- [
- ("R100", ("old.txt", "new.txt")),
- ("C100", ("source.txt", "copy.txt")),
- ("M", ("owned.txt",)),
- ],
- )
- def test_owned_paths_require_exact_files_or_explicit_directory_prefixes(self):
- events = [("R100", ("tests/unit/old.py", "tests/unit/new.py"))]
- self.assertEqual(
- codex_harness.validate_changed_paths(events, ["tests/unit/"]),
- ["tests/unit/old.py", "tests/unit/new.py"],
- )
- with self.assertRaisesRegex(ValueError, "owned"):
- codex_harness.validate_changed_paths(events, ["tests/unit/old.py"])
- with self.assertRaisesRegex(ValueError, "path"):
- codex_harness.validate_changed_paths([("M", ("../outside.py",))], ["tests/"])
- with self.assertRaisesRegex(ValueError, "glob"):
- codex_harness.validate_changed_paths(events, ["tests/*.py"])
- def test_agent_receipt_aggregation_preserves_hashes_and_bindings(self):
- aggregate = codex_harness.aggregate_agent_receipt_bindings(
- {
- "unit": {
- "verification_run_id": "a" * 32,
- "commit": "b" * 40,
- "artifact_sha256": "c" * 64,
- }
- },
- expected_run_id="a" * 32,
- expected_commit="b" * 40,
- )
- self.assertEqual(aggregate["receipts"]["unit"]["artifact_sha256"], "c" * 64)
- def test_current_commit8_uses_the_git_wrapper(self):
- completed = subprocess.CompletedProcess(
- args=["git"], returncode=0, stdout=b"0123abcd\n", stderr=b""
- )
- with patch.object(codex_harness.subprocess, "run", return_value=completed) as run:
- self.assertEqual(codex_harness.current_commit8(Path.cwd()), "0123abcd")
- args, kwargs = run.call_args
- self.assertEqual(args[0][0], "git")
- self.assertFalse(kwargs["shell"])
- self.assertFalse(kwargs["text"])
- self.assertIn("timeout", kwargs)
- if __name__ == "__main__":
- unittest.main()
|