diff --git a/CHANGELOG.md b/CHANGELOG.md index f6dabd2f..9ad37464 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/lang/zh-CN/ ### Fixed - 修复指定 key 时无法正确读取配置的问题 +- 插件测试时设置为 10 分钟超时 ## [3.2.4] - 2024-02-04 diff --git a/src/utils/plugin_test.py b/src/utils/plugin_test.py index 89effed6..028704c4 100644 --- a/src/utils/plugin_test.py +++ b/src/utils/plugin_test.py @@ -10,6 +10,7 @@ """ # ruff: noqa: T201, ASYNC101 +import asyncio import json import os import re @@ -297,15 +298,21 @@ async def run_poetry_project(self) -> None: ) ) - proc = await create_subprocess_shell( - "poetry run python runner.py", - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - cwd=self.path, - env=self.get_env(), - ) - stdout, stderr = await proc.communicate() - code = proc.returncode + try: + proc = await create_subprocess_shell( + "poetry run python runner.py", + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=self.path, + env=self.get_env(), + ) + stdout, stderr = await asyncio.wait_for(proc.communicate(), timeout=600) + code = proc.returncode + except asyncio.TimeoutError: + proc.terminate() + stdout = b"" + stderr = "测试超时".encode() + code = 1 self._run = not code