fix: distinguish unavailable sandbox results - #57
Merged
XiaoCow666 merged 1 commit intoSep 18, 2026
Merged
Conversation
XiaoCow666
approved these changes
Sep 18, 2026
XiaoCow666
left a comment
Owner
There was a problem hiding this comment.
CodeSense 自动评审
核心目标已完成:当沙箱不可用时优先显示“测试环境未就绪”,正常通过状态仍显示通过数。未发现安全风险、明显回归或无法运行的问题。
已有验证信息
- PR 描述提供的定向测试结果:2 passed。
- PR 描述提供的相关测试集合结果:25 passed,303 warnings。
- PR 描述提供的 git diff --check 结果:通过。
评审事件:6b581500-b37b-11f1-80d7-0041f2e8cbfc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更摘要
修复学生查看提交结果时的状态提示误导:当 C++ 测试环境不可用时,结果页不再把它显示成“通过 0/N”,而是显示“测试环境未就绪”。正常的“通过 N/N”提示保持不变。
本 PR 只修改结果模板和回归测试,不修改生产配置、数据库结构、权限、沙箱执行器、队列协议或 AI 服务调用。
阅读范围与调用链
我实际阅读并运行了学生端提交和结果反馈相关路径:
问题与复现证据
事实:沙箱返回 status='unavailable' 时,评测任务仍会保存测试用例总数。结果模板原先先判断 sandbox_total is not none,所以会输出“通过 0/2”;后面的“测试环境未就绪”分支不会执行。
复现方式:在隔离 Flask 测试数据库中创建学生提交,将 sandbox_status 设为 unavailable、sandbox_passed=0、sandbox_total=2,登录后请求 /view_submission/submission_id。
修复前运行:
python -m pytest -q tests/test_submission_knowledge_views.py -k "unavailable_sandbox or passed_sandbox_badge"
结果:1 failed, 1 passed。失败断言确认页面包含误导性的“通过 0/2”。
改动
验证命令与结果
使用系统临时目录中的隔离 Python 3.12 环境运行:
首次在工作区创建虚拟环境时,安装过程因 Windows 文件占用报 WinError 32;改用系统临时目录的全新隔离环境后依赖安装成功。该安装问题不属于代码测试失败。
兼容性、回滚与边界
AI 辅助说明
AI 用于检索目录、解释提交到反馈的调用链、提出候选问题和生成测试草稿。我先核对了实际文件和状态字段,再用修复前测试确认问题;只有失败证据出现后才采用本次模板分支调整。没有采用扩大到 worker、数据库或沙箱实现的建议,因为本问题可以在结果渲染边界内安全修复。