Preserve discarded patch context
Some checks failed
CI / test (push) Has been cancelled

This commit is contained in:
2026-08-28 13:55:39 +02:00
parent 0f2f131034
commit 34bf645957
4 changed files with 36 additions and 2 deletions

View File

@@ -158,6 +158,7 @@ def test_php_syntax_failure_discards_attempt_before_full_validation() -> None:
Mock(returncode=0, stdout="No syntax errors", stderr=""),
Mock(returncode=0, stdout="No syntax errors", stderr=""),
]
workspace.diff.return_value = "--- app/Service.php\n+++ app/Service.php\n+intended fix"
workspace.checkpoint.return_value = "valid-checkpoint"
workspace.commit.return_value = "commit-id"
@@ -167,6 +168,7 @@ def test_php_syntax_failure_discards_attempt_before_full_validation() -> None:
assert worker.agent.run.call_count == 2
assert "unexpected token" in worker.agent.run.call_args_list[1].args[1]
assert "clean repository" in worker.agent.run.call_args_list[1].args[1]
assert "intended fix" in worker.agent.run.call_args_list[1].args[1]
workspace.restore_checkpoint.assert_called_once_with(None)
worker._run_tests.assert_called_once()
@@ -207,6 +209,7 @@ def test_malformed_retry_restores_last_syntax_valid_attempt() -> None:
Mock(returncode=0, stdout="No syntax errors", stderr=""),
Mock(returncode=0, stdout="No syntax errors", stderr=""),
]
workspace.diff.return_value = "--- app/Service.php\n+++ app/Service.php\n+application repair"
workspace.checkpoint.side_effect = ["checkpoint-1", "checkpoint-3"]
workspace.commit.return_value = "commit-id"
@@ -216,6 +219,7 @@ def test_malformed_retry_restores_last_syntax_valid_attempt() -> None:
assert worker.agent.run.call_count == 3
workspace.restore_checkpoint.assert_called_once_with("checkpoint-1")
assert "last syntax-valid changes were restored" in worker.agent.run.call_args_list[2].args[1]
assert "application repair" in worker.agent.run.call_args_list[2].args[1]
assert worker._run_tests.call_count == 2