diff options
| author | Dan Smith <danms@us.ibm.com> | 2012-10-11 10:11:24 -0700 |
|---|---|---|
| committer | Dan Smith <danms@us.ibm.com> | 2012-10-12 07:10:39 -0700 |
| commit | bd30d411c4d17a4f37fe1e321d796f75e6e457c1 (patch) | |
| tree | 09e2e68d4aeef1322227302e34284fcd4ac355d2 | |
| parent | ba585524e32965697c1a44c8fd743dea060bb1af (diff) | |
Make run_tests.sh fail if no tests are actually run
Right now, run_tests seems to report test success if there is a
catastrophic failure early in the process. This can happen if you
have a python file that fails to parse, or if something else in
the test environment setup fails to initialize (such as creating
the empty database for the test run). Nosetests will report
success, but indicate that zero tests were run.
This patch snatches the output of nosetests and, if zero tests
ran, reports to the user that something is broken and offers a few
suggestions.
Change-Id: Ide6fd8b212f0650cb227f60b25d4b4e62ee150ac
| -rwxr-xr-x | run_tests.sh | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/run_tests.sh b/run_tests.sh index 0b7f52a55..b77e97a2c 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -88,7 +88,7 @@ function run_tests { # Cleanup *pyc ${wrapper} find . -type f -name "*.pyc" -delete # Just run the test suites in current environment - ${wrapper} $NOSETESTS + ${wrapper} $NOSETESTS | tee nosetests.log # If we get some short import error right away, print the error log directly RESULT=$? if [ "$RESULT" -ne "0" ]; @@ -98,6 +98,17 @@ function run_tests { then cat run_tests.log fi + else + tests_run=$(awk '/^Ran/ {print $2}' nosetests.log) + if [ "$tests_run" -eq 0 ]; + then + echo "ERROR: Zero tests ran, something is wrong!" + echo "This is usually caused by a parse error in some python" + echo "file or a failure to set up the environment (i.e. during" + echo "temporary database preparation). Running nosetests directly" + echo "may offer more clues." + return 1 + fi fi return $RESULT } |
