]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix for bug 877525
authorBrad Hall <brad@nicira.com>
Sat, 5 Nov 2011 11:42:16 +0000 (04:42 -0700)
committerBrad Hall <brad@nicira.com>
Sat, 5 Nov 2011 11:48:54 +0000 (04:48 -0700)
We now have a verbose flag (-v) for run_tests.sh if you want ot see all that
crap printed to the screen.  The default behavior is just to print "test nam
.. OK".  Also, we took the code from nova to cat run_tests.log if there is a
error so that if we hit an import error we will see it in the console jenkin
output.

Change-Id: Id8997c658a61691bf9f25b1c01e6a5db0eca428f

run_tests.sh

index eca9b8ccde49a19378ce1b7061fc0e9ab9fc343d..ef3e3db9056f0ff7030b9adce28696b0fed0b47b 100755 (executable)
@@ -23,6 +23,7 @@ function process_option {
     -N|--no-virtual-env) let always_venv=0; let never_venv=1;;
     -f|--force) let force=1;;
     -c|--coverage) coverage=1;;
+    -v|--verbose) verbose=1;;
     -*) noseopts="$noseopts $1";;
     *) noseargs="$noseargs $1"
   esac
@@ -36,6 +37,7 @@ force=0
 noseargs=
 wrapper=""
 coverage=0
+verbose=0
 
 for arg in "$@"; do
   process_option $arg
@@ -49,7 +51,22 @@ fi
 function run_tests {
   # Just run the test suites in current environment
   ${wrapper} rm -f ./$PLUGIN_DIR/tests.sqlite
-  ${wrapper} $NOSETESTS
+  if [ $verbose -eq 1 ]; then
+    ${wrapper} $NOSETESTS
+  else
+    ${wrapper} $NOSETESTS 2> run_tests.log
+  fi
+  # If we get some short import error right away, print the error log directly
+  RESULT=$?
+  if [ "$RESULT" -ne "0" ];
+  then
+    ERRSIZE=`wc -l run_tests.log | awk '{print \$1}'`
+    if [ $verbose -eq 0 -a "$ERRSIZE" -lt "40" ];
+    then
+        cat run_tests.log
+    fi
+  fi
+  return $RESULT
 }
 
 NOSETESTS="python ./$PLUGIN_DIR/run_tests.py $noseopts $noseargs"
@@ -83,7 +100,7 @@ then
       if [ "x$use_ve" = "xY" -o "x$use_ve" = "x" -o "x$use_ve" = "xy" ]; then
         # Install the virtualenv and run the test suite in it
         python tools/install_venv.py
-                   wrapper=${with_venv}
+        wrapper=${with_venv}
       fi
     fi
   fi