Skip to content

Commit ebeb87b

Browse files
committed
Return non zero if any test fails
1 parent 7dabc85 commit ebeb87b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ wheel:
1313
test:
1414
@echo "Testing..."
1515
cd tests && python3 run_all.py
16-
@echo "Done."
1716

1817
pub:
1918
@echo "Publishing wheel..."

tests/run_all.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
import unittest
44

5-
# 使用 TestLoader() 加载所有测试模块
65
test_loader = unittest.TestLoader()
76
test_suite = test_loader.discover('./')
87

9-
# 使用 TextTestRunner() 运行测试套件
108
test_runner = unittest.TextTestRunner()
11-
test_runner.run(test_suite)
9+
ret = test_runner.run(test_suite)
10+
11+
# if any test fails, exit with non-zero code
12+
if len(ret.failures) > 0 or len(ret.errors) > 0:
13+
exit(1)
14+
else:
15+
exit(0)

0 commit comments

Comments
 (0)