Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugin_test): 超时后仍需读取 stdout 与 stderr 的内容 #291

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/lang/zh-CN/

- 从插件测试中提取环境信息

### Fixed

- 超时后仍需读取 stdout 与 stderr 的内容

## [4.0.11] - 2024-11-23

### Fixed
Expand Down
8 changes: 7 additions & 1 deletion src/providers/docker_test/plugin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,13 @@
code = proc.returncode
except TimeoutError:
proc.terminate()
stdout, stderr = b"", "执行命令超时".encode()
# 超时后仍需读取 stdout 与 stderr 的内容
stdout = await proc.stdout.read() if proc.stdout else b""
stderr = (

Check warning on line 339 in src/providers/docker_test/plugin_test.py

View check run for this annotation

Codecov / codecov/patch

src/providers/docker_test/plugin_test.py#L338-L339

Added lines #L338 - L339 were not covered by tests
"执行命令超时".encode() + await proc.stderr.read()
if proc.stderr
else "执行命令超时".encode()
)
code = 1

return not code, stdout.decode(), stderr.decode()
Expand Down
Loading