Whamcloud - gitweb
tests: teach test_script the --failed option
authorTheodore Ts'o <tytso@mit.edu>
Tue, 7 Jun 2016 14:47:20 +0000 (10:47 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 7 Jun 2016 14:47:20 +0000 (10:47 -0400)
Teach test_script the --failed option, which asks it to rerun the
tests that had previously failed.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
tests/test_script.in

index 41ad104..9959e30 100644 (file)
@@ -5,24 +5,44 @@
 case "$1" in
     --valgrind)
        export USE_VALGRIND="valgrind -q --sim-hints=lax-ioctls"
-       shift;
+       shift
        ;;
     --valgrind-leakcheck)
        export USE_VALGRIND="valgrind --sim-hints=lax-ioctls --leak-check=full --show-reachable=yes --log-file=/tmp/valgrind-%p.log"
-       shift;
+       shift
+       ;;
+    --failed)
+       DO_FAILED=yes
+       shift
        ;;
 esac
 
-if test "$1"x = x ; then
-  TESTS=`ls -d $SRCDIR/[a-zA-Z]_*`
-else
-  TESTS=
-  for i; do
-    case $i in
+TESTS=
+
+if test -n "$DO_FAILED"; then
+    FAILED=$(find . -maxdepth 1 -name \*.failed)
+    if test -z "$FAILED" ; then
+       echo " "
+       echo "No (more) failed tests!"
+       echo " "
+    fi
+    for fname in $FAILED ; do
+       TESTS="$TESTS $SRCDIR/${fname%%.failed}"
+    done
+fi
+
+for i; do
+  case $i in
        [a-zA-Z])       TESTS="$TESTS $SRCDIR/${i}_*" ;;
        *)              TESTS="$TESTS $SRCDIR/$i" ;;
-    esac
-  done
+  esac
+done
+
+if test "$TESTS"x = x ; then
+    if test -n "DO_FAILED"; then
+       exit 0
+    fi
+    TESTS=`ls -d $SRCDIR/[a-zA-Z]_*`
 fi
 
 for test_dir in $TESTS; do