合并前复核:补齐急停释放、整轮中止和计划任务时限
This commit is contained in:
@@ -164,6 +164,35 @@ class RunAalcTest(unittest.TestCase):
|
|||||||
self.assertIn('preflight', info)
|
self.assertIn('preflight', info)
|
||||||
self.assertEqual(self.tools(mcp), ['run_task'])
|
self.assertEqual(self.tools(mcp), ['run_task'])
|
||||||
|
|
||||||
|
def test_user_stop_never_retries(self):
|
||||||
|
for status in ({'state': 'stopped', 'exit_code': 130},
|
||||||
|
{'state': 'stopped'}, {'state': 'failed', 'exit_code': 130}):
|
||||||
|
mcp = FakeMcp([status], [DONE])
|
||||||
|
with self.subTest(status=status), self.assertRaises(auto_cycle.UserAborted):
|
||||||
|
self.run_aalc(mcp)
|
||||||
|
self.assertEqual(self.tools(mcp), ['run_task'])
|
||||||
|
|
||||||
|
def test_mirror_emergency_stop_ends_cycle_before_upgrade_or_navigation(self):
|
||||||
|
mcp = FakeMcp([DONE], [{'state': 'stopped', 'exit_code': 130}])
|
||||||
|
poll = auto_cycle.poll_task
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
with mock.patch.object(auto_cycle, 'probe', mcp.probe), \
|
||||||
|
mock.patch.object(auto_cycle, 'poll_task',
|
||||||
|
side_effect=lambda t, s, **kw: poll(t, s, sleep=lambda _: None)), \
|
||||||
|
mock.patch.object(auto_cycle, 'lunacy_guard', return_value=(True, 'ok')), \
|
||||||
|
mock.patch.object(auto_cycle, 'ensure_team1', return_value=True), \
|
||||||
|
mock.patch.object(auto_cycle, 'goto_identities') as navigate, \
|
||||||
|
mock.patch.object(auto_cycle, 'run') as upgrade, \
|
||||||
|
mock.patch('builtins.print'):
|
||||||
|
code = auto_cycle.main(['--mirror', '1', '--report-dir', tmp])
|
||||||
|
report = json.loads(next(Path(tmp).glob('cycle_*.json')).read_text(encoding='utf-8'))
|
||||||
|
self.assertEqual(code, 130)
|
||||||
|
self.assertFalse(report['ok'])
|
||||||
|
self.assertIn('用户停止', report['result'])
|
||||||
|
navigate.assert_not_called()
|
||||||
|
upgrade.assert_not_called()
|
||||||
|
self.assertEqual(self.tools(mcp), ['run_task', 'run_task'])
|
||||||
|
|
||||||
def test_exit_zero_with_errors_is_failure(self):
|
def test_exit_zero_with_errors_is_failure(self):
|
||||||
mcp = FakeMcp([dict(DONE, errors=['[ERROR] 超出最大尝试次数,未能进入战斗'])])
|
mcp = FakeMcp([dict(DONE, errors=['[ERROR] 超出最大尝试次数,未能进入战斗'])])
|
||||||
ok, info = self.run_aalc(mcp)
|
ok, info = self.run_aalc(mcp)
|
||||||
|
|||||||
Reference in New Issue
Block a user