Refactor the test system
[jansson.git] / test / scripts / run-tests.sh
1 # Copyright (c) 2009 Petri Lehtinen <petri@digip.org>
2 #
3 # Jansson is free software; you can redistribute it and/or modify
4 # it under the terms of the MIT license. See LICENSE for details.
5
6 json_process=$bindir/json_process
7
8 suite_name=$1
9 suite_srcdir=$suites_srcdir/$suite_name
10 suite_builddir=$suites_builddir/$suite_name
11 suite_log=$logdir/$suite_name
12
13
14 [ -z "$VERBOSE" ] && VERBOSE=0
15
16 . $scriptdir/valgrind.sh
17
18 rm -rf $suite_log
19 mkdir -p $suite_log
20
21 for test_path in $suite_srcdir/*; do
22     test_name=$(basename $test_path)
23     test_builddir=$suite_builddir/$test_name
24     test_log=$suite_log/$test_name
25
26     [ "$test_name" = "run" ] && continue
27     is_test || continue
28
29     rm -rf $test_log
30     mkdir -p $test_log
31     if [ $VERBOSE -eq 1 ]; then
32         echo -n "$name... "
33     fi
34
35     if run_test; then
36         # Success
37         if [ $VERBOSE -eq 1 ]; then
38             echo "ok"
39         else
40             echo -n "."
41         fi
42         rm -rf $test_log
43     else
44         # Failure
45         if [ $VERBOSE -eq 1 ]; then
46             echo "FAILED"
47         else
48             echo -n "F"
49         fi
50     fi
51 done
52
53 if [ $VERBOSE -eq 0 ]; then
54     echo
55 fi
56
57 if [ -n "$(ls -A $suite_log)" ]; then
58     for test_log in $suite_log/*; do
59         test_name=$(basename $test_log)
60         test_path=$suite_srcdir/$test_name
61         echo "================================================================="
62         echo "$suite_name/$test_name"
63         echo "================================================================="
64         show_error
65         echo
66     done
67     echo "================================================================="
68     exit 1
69 else
70     rm -rf $suite_log
71 fi