task_status 在退出码为 0 但日志有报错时附上 errors
取自 codex/story-test-20261003 的 66418dc (DSH) 中 tasks.py 部分及其两项测试:
AALC 每日流程单次战斗失败("未能进入战斗")后仍 exit 0, 只看 succeeded 会误判。
同一提交里的编队滑动补丁未合入: 后台模式分段移动时长 <0.01s 时 AALC 的
_mouse_move_to 步数为 0 不发移动事件, 前台每段受 pyautogui 默认 0.1s 停顿
影响单次滑动约 4.4s, 且行程比 AALC 的 Windows 标定多 60px; 另行重写后实测。
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -635,5 +635,37 @@ class TransportTest(unittest.TestCase):
|
|||||||
self.assertEqual((state['ok'], state['items']), (True, []))
|
self.assertEqual((state['ok'], state['items']), (True, []))
|
||||||
|
|
||||||
|
|
||||||
|
class TaskErrorSurfaceTest(unittest.TestCase):
|
||||||
|
"""AALC 每日流程单次战斗失败后仍 exit 0; 状态里必须带出日志报错。"""
|
||||||
|
|
||||||
|
CHILD = ('import sys; '
|
||||||
|
'sys.stdout.write("[ERROR] [AALC] tasks\\\\battle\\\\battle.py:83: '
|
||||||
|
'超出最大尝试次数,未能进入战斗\\n"); '
|
||||||
|
'sys.stdout.write("[lc_mcp] task daily done\\n"); '
|
||||||
|
'sys.stdout.flush()')
|
||||||
|
|
||||||
|
def test_exit_zero_with_battle_error_is_reported(self):
|
||||||
|
with tempfile.TemporaryDirectory() as d:
|
||||||
|
runner = TaskRunner(d, argv_factory=lambda t, p: [sys.executable, '-c', self.CHILD])
|
||||||
|
self.assertTrue(runner.start('daily', {'exp': 1})['ok'])
|
||||||
|
deadline = time.time() + 15
|
||||||
|
while time.time() < deadline and runner.running():
|
||||||
|
time.sleep(0.05)
|
||||||
|
status = runner.status()
|
||||||
|
self.assertEqual((status['state'], status['exit_code']), ('succeeded', 0), status)
|
||||||
|
self.assertIn('未能进入战斗', status['errors'][-1])
|
||||||
|
|
||||||
|
def test_clean_log_has_no_errors_field(self):
|
||||||
|
with tempfile.TemporaryDirectory() as d:
|
||||||
|
runner = TaskRunner(d, argv_factory=lambda t, p: [sys.executable, '-c', 'print("[lc_mcp] ok")'])
|
||||||
|
self.assertTrue(runner.start('daily', {})['ok'])
|
||||||
|
deadline = time.time() + 15
|
||||||
|
while time.time() < deadline and runner.running():
|
||||||
|
time.sleep(0.05)
|
||||||
|
status = runner.status()
|
||||||
|
self.assertEqual(status['state'], 'succeeded')
|
||||||
|
self.assertNotIn('errors', status)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user