From 75393cab0f87635e829b45b200cc771a0463b6f4 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 9 Sep 2019 14:47:26 +1000 Subject: [PATCH] ctdb-tests: Recurse into directories instead of explicitly looping 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 Reviewed-by: Amitay Isaacs --- ctdb/tests/run_tests.sh | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/ctdb/tests/run_tests.sh b/ctdb/tests/run_tests.sh index 03ef5fd7d52..31cb9275df9 100755 --- a/ctdb/tests/run_tests.sh +++ b/ctdb/tests/run_tests.sh @@ -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 -- 2.47.3