update for 0.4.0 release
[vala-lang.git] / tests / testrunner.sh
blob8d7122a2f1f97219e2d5104e2b735771b9b5a8da
1 #!/bin/bash
2 # testrunner.sh
4 # Copyright (C) 2006-2008 Jürg Billeter
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 # Author:
21 # Jürg Billeter <j@bitron.ch>
23 builddir=$PWD
24 topbuilddir=$builddir/..
25 srcdir=`dirname $0`
26 topsrcdir=$srcdir/..
27 vapidir=$topsrcdir/vapi
28 exe=$EXEEXT
30 # make sure we detect failed test cases
31 set -o pipefail
33 export G_DEBUG=fatal_warnings
35 VALAC=$topbuilddir/compiler/valac
36 CC="gcc -std=c99"
37 CFLAGS="-O0 -g3 -I$topsrcdir -I$topbuilddir"
38 LDLIBS="-lm ../gee/.libs/libgee.a"
40 CODE=0
42 for testcasesource in "$@"
44 testsrc=${testcasesource/.vala/}
45 testbuild=`basename "$testsrc"`
46 if ! $VALAC -C --vapidir "$vapidir" --pkg gee-1.0 --basedir $topsrcdir -d $topbuilddir $testsrc.vala > $testbuild.err 2>&1
47 then
48 echo "ERROR: Compiling" $testcasesource
49 cat $testbuild.err
50 CODE=1
51 continue
53 if ! $CC $CFLAGS $testbuild.c $(pkg-config --cflags --libs gobject-2.0) -o $testbuild $LDLIBS > $testbuild.err 2>&1
54 then
55 echo "ERROR: Compiling" $testbuild.c
56 cat $testbuild.err
57 CODE=1
58 continue
60 if ./$testbuild 2>&1 | tee $testbuild.err | cmp -s $testsrc.exp
61 then
62 rm $testbuild.c $testbuild.h $testbuild$exe $testbuild.err
63 else
64 echo "ERROR: test failed. This is the difference between" $testbuild.exp "and" $testbuild.err
65 diff -u $testbuild.exp $testbuild.err
66 CODE=1
68 done
70 exit $CODE