from __future__ import annotations import tempfile import unittest from pathlib import Path from t3 import backend from t3.evaluate import _manual_progress class ManualProgressTests(unittest.TestCase): def test_counts_only_required_top_level_admitted_goals(self) -> None: with tempfile.TemporaryDirectory() as directory: root = Path(directory) workspace = root / "ws" skeleton = workspace / "problem/groundtruth/demo_proof_manual.skel.v" skeleton.parent.mkdir(parents=True) skeleton.write_text( "Lemma proof_of_x_split_goal_1 : x1.\nProof. Abort.\n\n" "Lemma proof_of_x : x.\nProof. Admitted.\n\n" "Lemma proof_of_y : y.\nProof. Admitted.\n" ) # Redirect the case output by temporarily constructing its expected tree under T3 # is undesirable in a unit test, so exercise a small equivalent local Case subclass. class LocalCase: id = "demo" manual_name = "demo_proof_manual.v" suffix = ".v" be = backend.ROCQ out_dir = root / "out" LocalCase.out_dir.mkdir() (LocalCase.out_dir / LocalCase.manual_name).write_text( "Lemma proof_of_x_split_goal_1 : x1. Proof. Abort.\n" "Lemma proof_of_x : x.\nProof. exact px. Qed.\n" "Lemma proof_of_y : y.\nProof. exact py. Abort.\n" ) progress = _manual_progress(LocalCase, workspace, "FAILED") self.assertEqual(progress["residual_vcs"], 2) self.assertEqual(progress["source_closed"], 1) self.assertEqual(progress["source_closed_names"], ["proof_of_x"]) self.assertEqual(progress["kernel_checked"], 0) def test_lean_counts_theorems_not_example_stubs(self) -> None: with tempfile.TemporaryDirectory() as directory: root = Path(directory) workspace = root / "ws" skeleton = workspace / "problem/groundtruth/demo_proof_manual.skel.lean" skeleton.parent.mkdir(parents=True) skeleton.write_text( "example : demo_goal.x_split_goal_1 := by\n sorry\n\n" "theorem proof_of_x : demo_goal.x := by\n sorry\n\n" "theorem proof_of_y : demo_goal.y := by\n sorry\n" ) class LocalCase: id = "demo" manual_name = "demo_proof_manual.lean" suffix = ".lean" be = backend.LEAN out_dir = root / "out" LocalCase.out_dir.mkdir() (LocalCase.out_dir / LocalCase.manual_name).write_text( "theorem proof_of_x : demo_goal.x := by\n unfold demo_goal.x\n omega\n\n" "theorem proof_of_y : demo_goal.y := by\n sorry\n" ) progress = _manual_progress(LocalCase, workspace, "FAILED") self.assertEqual(progress["residual_vcs"], 2) self.assertEqual(progress["source_closed_names"], ["proof_of_x"]) self.assertEqual(progress["kernel_checked"], 0) if __name__ == "__main__": unittest.main()