ctdb-tests: Add function test_case(), tweak unit test header format
authorMartin Schwenke <martin@meltin.net>
Mon, 28 Feb 2022 22:27:50 +0000 (09:27 +1100)
committerAmitay Isaacs <amitay@samba.org>
Wed, 6 Apr 2022 06:34:37 +0000 (06:34 +0000)
Instead of documenting test cases with a comment, this allows them to
be documented via an argument to a function that is printed when the
test case is run.  This makes it easier locate test case failures when
commands used by test cases look similar,

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

index 0290944edd029e1c46fd476a4756f667d54506e2..403ee07c47456ab2f8393e90409a2b16165dac99 100644 (file)
@@ -184,10 +184,20 @@ test_fail()
        return 1
 }
 
+test_case_string=""
+test_case()
+{
+       test_case_string="$*"
+}
+
 test_header_default()
 {
        echo "=================================================="
-       echo "Running \"$*\""
+       if [ -n "$test_case_string" ]; then
+               echo "Summary: ${test_case_string}"
+               test_case_string=""
+       fi
+       echo "Running: $*"
 }
 
 reset_test_header()