← Commit history

0.1.32 tests: the guard swaps mid-turn and retires later; an engine-only change reuses a busy backend

John Lauer ·2a06a0333a · ·parent 9ca34ff
2 files changed +47−3
tests/test_guard.py+15−3
@@ -77,13 +77,25 @@ class GuardTests(unittest.TestCase):         self.assertIn('[email protected]', run.call_args[0][0])      def test_running_turn_is_never_interrupted(self):+        # The good build goes back on disk at once (a running backend keeps its own files);+        # only stopping a bad build's backend waits until no turn runs (0.1.32, a thread+        # waiting on an approval for days kept the old 'wait first' from ever swapping).         self.install('2.0.0')         g = self.make({'last_good': '1.2.0'})         with patch.object(g, 'codex_idle', return_value=(False, {'pid': 1})), \-             patch.object(guard.subprocess, 'run') as run:+             patch.object(guard.subprocess, 'run', side_effect=self.fake_install) as run, \+             patch.object(g, 'retire_backend') as retire:             g.check()-        run.assert_not_called()-        self.assertEqual(self.notes, [])+        self.assertIn('[email protected]', run.call_args[0][0])+        retire.assert_not_called()+        self.assertEqual(g.state['held'], '1.2.0')+        self.assertTrue(g.state['retire_from'])+        # Next pass, the turn has finished: the bad build's backend is retired then.+        with patch.object(g, 'codex_idle', return_value=(True, {'pid': 1})), \+             patch.object(g, 'retire_backend') as retire:+            g.check()+        retire.assert_called_once()+        self.assertNotIn('retire_from', g.state)      def test_hold_stays_while_newest_is_still_bad(self):         self.install('1.2.0', pinned=True)
tests/test_same_extension.pyadded+32
@@ -0,0 +1,32 @@+from pathlib import Path+import sys+import unittest+from unittest.mock import patch++sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'runtime'))+import runtime  # noqa: E402++EXT = '/home/adom/.local/share/code-server/extensions/openai.chatgpt-26.908.40401-linux-x64/bin/linux-x86_64/codex'+ENGINE = '/home/adom/.local/share/adom/codex-engine/0.166.0/x86_64-unknown-linux-musl/bin/codex'+++class SameExtensionTests(unittest.TestCase):+    """0.1.32: an engine-only change never refuses a busy backend (ConfRoomROG 2026-10-31)."""++    def test_old_backend_of_this_extension_is_reused(self):+        with patch.object(runtime, 'bundled_binary', return_value=Path(EXT)):+            self.assertTrue(runtime.same_extension({'binary': EXT}, Path(ENGINE)))++    def test_engine_backend_records_its_extension(self):+        with patch.object(runtime, 'bundled_binary', return_value=Path(EXT)):+            self.assertTrue(runtime.same_extension({'binary': ENGINE, 'extension': '26.908.40401'}, Path(EXT)))++    def test_other_extension_is_not_the_same(self):+        newer = EXT.replace('26.908.40401', '26.1021.22027')+        with patch.object(runtime, 'bundled_binary', return_value=Path(newer)):+            self.assertFalse(runtime.same_extension({'binary': EXT}, Path(newer)))+            self.assertFalse(runtime.same_extension({'binary': ENGINE}, Path(newer)))+++if __name__ == '__main__':+    unittest.main()