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
21 # Jürg Billeter <j@bitron.ch>
24 topbuilddir
=$builddir/..
25 srcdir
=$PWD/`dirname $0`
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
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
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
68 echo -n -e "TEST: Building...\033[72G"
70 cat << "EOF" > checkall
75 cat << "EOF" > main.vala
76 void main
(string
[] args
) {
82 for testfile
in "$@"; do
84 echo 'set -e' >> prepare
88 testpath
=${testfile/.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
105 while IFS
="" read -r line
; do
106 if [ $PART -eq 0 ]; then
107 if [ -n "$line" ]; then
113 if [ $INHEADER -eq 1 ]; then
114 if [ -n "$line" ]; then
120 if echo "$line" |
grep -q "^[A-Za-z]\+:"; then
127 echo "$line" >> $SOURCEFILE
131 done < "$srcdir/$testfile"
136 cat prepare check
> $ns.check
137 cat << EOF >> checkall
138 echo -n -e " /$testpath: \033[72G"
140 if bash $ns.check &>log; then
141 echo -e "\033[0;32mOK\033[m"
144 echo -e "\033[0;31mFAIL\033[m"
150 cat << "EOF" >> checkall
151 if [ $fail -eq 0 ]; then
152 echo "All $all tests passed"
154 echo "$fail of $all tests failed"
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"
170 echo -e "\033[0;31mFAIL\033[m"
177 if bash checkall
; then