import os import pytest from probes import file from llm import judge_log, LLMClient FIXTURES = os.path.join(os.path.dirname(os.path.dirname(__file__)), "fixtures", "finalize") @pytest.mark.finalize class TestFinalizeMinimal: def test_minimal_finalize_succeeds(self, run_baker, work_dir): config = os.path.join(FIXTURES, "minimal.yml") result = run_baker("finalize", config, cwd=work_dir, timeout=60) assert result["success"], f"Minimal finalize failed: {result['stderr']}" @pytest.mark.finalize class TestFinalizeHooks: def test_early_hook_executes(self, run_baker, work_dir): config = os.path.join(FIXTURES, "with_hooks.yml") result = run_baker("finalize", config, cwd=work_dir, timeout=60) assert result["success"] assert "finalize early hook" in result["stdout"] or "finalize early hook" in result["stderr"] def test_late_hook_executes(self, run_baker, work_dir): config = os.path.join(FIXTURES, "with_hooks.yml") result = run_baker("finalize", config, cwd=work_dir, timeout=60) assert result["success"] assert "finalize late hook" in result["stdout"] or "finalize late hook" in result["stderr"] @pytest.mark.finalize @pytest.mark.llm class TestFinalizeWithLLM: def test_finalize_hooks_via_llm(self, run_baker, llm_env, work_dir): if not llm_env: pytest.skip("LLM environment not configured") config = os.path.join(FIXTURES, "with_hooks.yml") result = run_baker("finalize", config, cwd=work_dir, timeout=60) combined_log = result["stdout"] + "\n" + result["stderr"] judgment = judge_log( operation="finalize with early and late hooks", expected_behavior="Both early and late hooks executed successfully, " "printing 'finalize early hook' and 'finalize late hook'", actual_log=combined_log, ) assert judgment.passed, f"LLM judgment failed: {judgment.reason}" @pytest.mark.finalize class TestFinalizePlugins: @pytest.mark.skip(reason="Plugin download test not yet implemented") def test_plugin_download(self, run_baker, work_dir): pass @pytest.mark.skip(reason="Artifact stage not yet implemented") def test_artifact_collection(self, run_baker, work_dir): pass