繁体   English   中英

Travis脚本退出代码永远不会失败,即使它应该

[英]Travis script exit code never fails even when it should

我的Travis yml文件的脚本部分如下所示:

script:
- ./run_tests.sh

该脚本本身在Sauce Labs上运行一些测试。 如果脚本由于测试失败而失败,它仍将以代码0退出,并且构建也继续通过。 如果测试失败,为什么脚本不显示失败代码?

当我从脚本文件的末尾输出退出代码时,我得到0。当在脚本命令之后立即在.travis.yml文件中输出退出代码时,我得到1:

echo $?
0
The command "./run_tests.sh" exited with 0.
$ echo $?
1

我意识到这是因为我实际上是在使用unittest.TextTestRunner运行测试,并且这些测试的退出代码始终为0,除非您专门捕获测试失败并根据失败退出:

ret = not runner.run(test_suite).wasSuccessful()
sys.exit(ret)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM