gtk+-3.0: Fix gtk_widget_adjust_size_* bindings
[vala-lang.git] / tests / testrunner.sh
blob237f69db26346c43b9b199392a18254a1a447442
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=$PWD/`dirname $0`
26 topsrcdir=$srcdir/..
27 vapidir=$topsrcdir/vapi
29 export G_DEBUG=fatal_warnings
31 VALAC=$topbuilddir/compiler/valac
32 VALAFLAGS="--vapidir $vapidir --disable-warnings --main main --save-temps -X -O0 -X -pipe -X -lm -X -Werror=return-type -X -Werror=init-self -X -Werror=implicit -X -Werror=sequence-point -X -Werror=return-type -X -Werror=uninitialized -X -Werror=pointer-arith -X -Werror=int-to-pointer-cast -X -Werror=pointer-to-int-cast"
34 function testheader() {
35 if [ "$1" = "Packages:" ]; then
36 shift
37 PACKAGES="$PACKAGES $@"
38 elif [ "$1" = "D-Bus" ]; then
39 echo 'eval `dbus-launch --sh-syntax`' >> prepare
40 echo 'trap "kill $DBUS_SESSION_BUS_PID" INT TERM EXIT' >> prepare
44 function sourceheader() {
45 if [ "$1" = "Program:" ]; then
46 testpath=${testfile/.test/}/$2
47 ns=${testpath//\//.}
48 ns=${ns//-/_}
49 SOURCEFILE=$ns.vala
50 SOURCEFILES="$SOURCEFILES $SOURCEFILE"
51 echo " case \"/$testpath\": $ns.main (); break;" >> main.vala
52 echo "namespace $ns {" > $SOURCEFILE
56 function sourceend() {
57 if [ -n "$testpath" ]; then
58 echo "}" >> $SOURCEFILE
59 echo "./test$EXEEXT /$testpath" > check
63 testdir=_test
64 rm -rf $testdir
65 mkdir $testdir
66 cd $testdir
68 echo -n -e "TEST: Building...\033[72G"
70 cat << "EOF" > checkall
71 all=0
72 fail=0
73 EOF
75 cat << "EOF" > main.vala
76 void main (string[] args) {
77 switch (args[1]) {
78 EOF
80 PACKAGES=gio-2.0
81 SOURCEFILES=
82 for testfile in "$@"; do
83 rm -f prepare check
84 echo 'set -e' >> prepare
86 case "$testfile" in
87 *.vala)
88 testpath=${testfile/.vala/}
89 ns=${testpath//\//.}
90 ns=${ns//-/_}
91 SOURCEFILE=$ns.vala
92 SOURCEFILES="$SOURCEFILES $SOURCEFILE"
94 echo " case \"/$testpath\": $ns.main (); break;" >> main.vala
95 echo "namespace $ns {" > $SOURCEFILE
96 cat "$srcdir/$testfile" >> $SOURCEFILE
97 echo "}" >> $SOURCEFILE
99 echo "./test$EXEEXT /$testpath" > check
101 *.test)
102 PART=0
103 INHEADER=1
104 testpath=
105 while IFS="" read -r line; do
106 if [ $PART -eq 0 ]; then
107 if [ -n "$line" ]; then
108 testheader $line
109 else
110 PART=1
112 else
113 if [ $INHEADER -eq 1 ]; then
114 if [ -n "$line" ]; then
115 sourceheader $line
116 else
117 INHEADER=0
119 else
120 if echo "$line" | grep -q "^[A-Za-z]\+:"; then
121 sourceend
122 PART=$(($PART + 1))
123 INHEADER=1
124 testpath=
125 sourceheader $line
126 else
127 echo "$line" >> $SOURCEFILE
131 done < "$srcdir/$testfile"
132 sourceend
134 esac
136 cat prepare check > $ns.check
137 cat << EOF >> checkall
138 echo -n -e " /$testpath: \033[72G"
139 ((all++))
140 if bash $ns.check &>log; then
141 echo -e "\033[0;32mOK\033[m"
142 else
143 ((fail++))
144 echo -e "\033[0;31mFAIL\033[m"
145 cat log
148 done
150 cat << "EOF" >> checkall
151 if [ $fail -eq 0 ]; then
152 echo "All $all tests passed"
153 else
154 echo "$fail of $all tests failed"
155 exit 1
159 cat << "EOF" >> main.vala
160 default: assert_not_reached ();
165 cat $SOURCEFILES >> main.vala
167 if $VALAC $VALAFLAGS -o test$EXEEXT $(echo $PACKAGES | xargs -n 1 -r echo -n " --pkg") main.vala &>log; then
168 echo -e "\033[0;32mOK\033[m"
169 else
170 echo -e "\033[0;31mFAIL\033[m"
171 cat log
173 cd $builddir
174 exit 1
177 if bash checkall; then
178 cd $builddir
179 rm -rf $testdir
180 else
181 cd $builddir
182 exit 1