test/suites/api: Detect tests correctly
authorPetri Lehtinen <petri@digip.org>
Tue, 2 Feb 2010 18:37:00 +0000 (20:37 +0200)
committerPetri Lehtinen <petri@digip.org>
Tue, 2 Feb 2010 18:37:02 +0000 (20:37 +0200)
The C++ test case didn't work correctly in VPATH builds or with
VALGRIND=1.

test/suites/api/run

index 8688e0f..48c3e7e 100755 (executable)
@@ -6,16 +6,29 @@
 # it under the terms of the MIT license. See LICENSE for details.
 
 is_test() {
-    [ "${test_name%.c}" != "$test_name" ] && return 0
-    [ -x $test_path -a ! -f $test_path.c ] && return 0
-    return 1
+    case "$test_name" in
+        *.c|*.cpp|check-exports)
+            return 0
+            ;;
+        *)
+            return 1
+            ;;
+    esac
 }
 
 run_test() {
-    if [ -x $test_path ]; then
+    if [ "$test_name" = "check-exports" ]; then
         test_log=$test_log $test_path >$test_log/stdout 2>$test_log/stderr
     else
-        $test_runner $suite_builddir/${test_name%.c} \
+        case "$test_name" in
+            *.c)
+                test_bin=${test_name%.c}
+                ;;
+            *.cpp)
+                test_bin=${test_name%.cpp}
+                ;;
+        esac
+        $test_runner $suite_builddir/$test_bin \
             >$test_log/stdout \
             2>$test_log/stderr \
             || return 1