tests: Use "make STOP=1 check" to stop on first failure
[jansson.git] / test / scripts / run-tests.sh
1 # Copyright (c) 2009-2011 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 [ -z "$STOP" ] && STOP=0
16
17 . $scriptdir/valgrind.sh
18
19 rm -rf $suite_log
20 mkdir -p $suite_log
21
22 for test_path in $suite_srcdir/*; do
23     test_name=$(basename $test_path)
24     test_builddir=$suite_builddir/$test_name
25     test_log=$suite_log/$test_name
26
27     [ "$test_name" = "run" ] && continue
28     is_test || continue
29
30     rm -rf $test_log
31     mkdir -p $test_log
32     if [ $VERBOSE -eq 1 ]; then
33         echo -n "$test_name... "
34     fi
35
36     if run_test; then
37         # Success
38         if [ $VERBOSE -eq 1 ]; then
39             echo "ok"
40         else
41             echo -n "."
42         fi
43         rm -rf $test_log
44     else
45         # Failure
46         if [ $VERBOSE -eq 1 ]; then
47             echo "FAILED"
48         else
49             echo -n "F"
50         fi
51
52         [ $STOP -eq 1 ] && break
53     fi
54 done
55
56 if [ $VERBOSE -eq 0 ]; then
57     echo
58 fi
59
60 if [ -n "$(ls -A $suite_log)" ]; then
61     for test_log in $suite_log/*; do
62         test_name=$(basename $test_log)
63         test_path=$suite_srcdir/$test_name
64         echo "================================================================="
65         echo "$suite_name/$test_name"
66         echo "================================================================="
67         show_error
68         echo
69     done
70     echo "================================================================="
71     exit 1
72 else
73     rm -rf $suite_log
74 fi