执行摘要
修复 CI 中 bare pytest.main 导致失败被吞没
run_files in python/sglang/test/ci/ci_utils.py decides whether a test file passed by reading the wrapping python script's process.returncode. Files using if __name__ == "__main__": pytest.main([__file__]) discard pytest's exit code, so the script returns 0 even when assertions fail. The CI runner then logs the file as PASSED while pytest's stdout reports the failure — silently masking real regressions. (Discovered when test_norm_tanh_mul_add_norm_scale.py printed 1 failed, 47 passed but the CI suite stayed green.)
该PR是典型的CI可靠性修复,设计思路清晰(AST扫描而非侵入式修改运行器)。建议阅读test_no_bare_pytest_main.py的实现,了解如何用AST做仓库级别的规则检查。对于贡献者,在提交包含pytest.main的测试文件时,务必使用sys.exit(pytest.main(...))。
该PR未引发实质性的review讨论,Reviewer DarkSharpness直接批准。实现过程中曾有一个包含冗余行为检查的版本,后简化为仅保留AST扫描(commit 2bbf631)。
参与讨论