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"
34 function testheader
() {
35 if [ "$1" = "Packages:" ]; then
37 PACKAGES
="$PACKAGES $@"
39 if [ "$pkg" = "dbus-glib-1" ]; then
40 echo 'eval `dbus-launch --sh-syntax`' >> prepare
41 echo 'trap "kill $DBUS_SESSION_BUS_PID" INT TERM EXIT' >> prepare
47 function sourceheader
() {
48 if [ "$1" = "Program:" ]; then
49 testpath
=${testfile/.test/}/$2
53 SOURCEFILES
="$SOURCEFILES $SOURCEFILE"
54 echo " case \"/$testpath\": $ns.main (); break;" >> main.vala
55 echo "namespace $ns {" > $SOURCEFILE
59 function sourceend
() {
60 if [ -n "$testpath" ]; then
61 echo "}" >> $SOURCEFILE
62 echo "./test$EXEEXT /$testpath" > check
71 echo -n -e "TEST: Building...\033[72G"
73 cat << "EOF" > checkall
78 cat << "EOF" > main.vala
79 void main
(string
[] args
) {
85 for testfile
in "$@"; do
87 echo 'set -e' >> prepare
91 testpath
=${testfile/.vala/}
95 SOURCEFILES
="$SOURCEFILES $SOURCEFILE"
97 echo " case \"/$testpath\": $ns.main (); break;" >> main.vala
98 echo "namespace $ns {" > $SOURCEFILE
99 cat "$srcdir/$testfile" >> $SOURCEFILE
100 echo "}" >> $SOURCEFILE
102 echo "./test$EXEEXT /$testpath" > check
108 while IFS
="" read -r line
; do
109 if [ $PART -eq 0 ]; then
110 if [ -n "$line" ]; then
116 if [ $INHEADER -eq 1 ]; then
117 if [ -n "$line" ]; then
123 if echo "$line" |
grep -q "^[A-Za-z]\+:"; then
130 echo "$line" >> $SOURCEFILE
134 done < "$srcdir/$testfile"
139 cat prepare check
> $ns.check
140 cat << EOF >> checkall
141 echo -n -e " /$testpath: \033[72G"
143 if bash $ns.check &>log; then
144 echo -e "\033[0;32mOK\033[m"
147 echo -e "\033[0;31mFAIL\033[m"
153 cat << "EOF" >> checkall
154 if [ $fail -eq 0 ]; then
155 echo "All $all tests passed"
157 echo "$fail of $all tests failed"
162 cat << "EOF" >> main.vala
163 default
: assert_not_reached
();
168 cat $SOURCEFILES >> main.vala
170 if $VALAC $VALAFLAGS -o test$EXEEXT $
(echo $PACKAGES |
xargs -n 1 -r echo -n " --pkg") main.vala
&>log
; then
171 echo -e "\033[0;32mOK\033[m"
173 echo -e "\033[0;31mFAIL\033[m"
180 if bash checkall
; then