]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tests: Recurse into directories instead of explicitly looping
authorMartin Schwenke <martin@meltin.net>
Mon, 9 Sep 2019 04:47:26 +0000 (14:47 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 26 Sep 2019 04:45:37 +0000 (04:45 +0000)
run_tests() already has a loop, so use it.

This means collections of test suites can be handled - but explicitly
check valid collection names to avoid running junk.

Add special cases for simple and complex.  These will be removed when
those test suites are moved to collections.  This seems to be the
smallest amount of churn to support bisection.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/run_tests.sh

index 03ef5fd7d527b3689fb1eb6e0190e45fdc011e1a..31cb9275df9491f86aea797970473d8777ba6732 100755 (executable)
@@ -237,17 +237,35 @@ run_tests ()
                fi
 
                if [ -d "$f" ] ; then
-                       local i
-                       for i in "${f%/}/"*".sh" ; do
-                               # Probably empty directory
-                               if [ ! -f "$i" ] ; then
-                                       break
+                       local test_dir dir reldir subtests
+
+                       test_dir=$(cd "$CTDB_TEST_DIR" && pwd)
+                       dir=$(cd "$f" && pwd)
+                       reldir="${dir#${test_dir}/}"
+
+                       case "$reldir" in
+                       */*/*)
+                               die "test \"$f\" is not recognised"
+                               ;;
+                       */*|simple|complex)
+                               # A single test suite
+                               subtests=$(echo "${f%/}/"*".sh")
+                               if [ "$subtests" = "${f%/}/*.sh" ] ; then
+                                       # Probably empty directory
+                                       die "test \"$f\" is not recognised"
                                fi
-                               run_one_test "$i"
-                               if $exit_on_fail && [ $status -ne 0 ] ; then
-                                       break
-                               fi
-                       done
+                               ;;
+                       UNIT)
+                               # A collection of test suites
+                               subtests=$(echo "${f%/}/"*)
+                               ;;
+                       *)
+                               die "test \"$f\" is not recognised"
+                       esac
+
+                       # Recurse - word-splitting wanted
+                       # shellcheck disable=SC2086
+                       run_tests $subtests
                elif [ -f "$f" ] ; then
                        run_one_test "$f"
                else