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
30 VALAC
=$topbuilddir/compiler
/valac
$EXEEXT
31 VALAFLAGS
="$VALAFLAGS \
40 -X -DGETTEXT_PACKAGE=\"valac\" \
41 -X -Werror=return-type \
42 -X -Werror=init-self \
44 -X -Werror=sequence-point \
45 -X -Werror=return-type \
46 -X -Werror=uninitialized \
47 -X -Werror=pointer-arith \
48 -X -Werror=int-to-pointer-cast \
49 -X -Werror=pointer-to-int-cast \
51 -X -Werror=format-security \
52 -X -Werror=format-nonliteral \
53 -X -Werror=redundant-decls \
54 -X -Werror=int-conversion"
55 VAPIGEN
=$topbuilddir/vapigen
/vapigen
$EXEEXT
56 VAPIGENFLAGS
="--vapidir $vapidir"
58 # Incorporate the user's CFLAGS. Matters if the user decided to insert
59 # -m32 in CFLAGS, for example.
60 for cflag
in ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
61 VALAFLAGS
="${VALAFLAGS} -X ${cflag}"
64 function testheader
() {
65 if [ "$1" = "Packages:" ]; then
67 PACKAGES
="$PACKAGES $@"
68 elif [ "$*" = "Invalid Code" ]; then
71 testpath
=${testfile/.test/}
75 elif [ "$1" = "D-Bus" ]; then
76 run_prefix
="dbus-run-session -- $run_prefix"
77 elif [ "$1" = "GIR" ]; then
82 function sourceheader
() {
83 if [ "$1" = "Program:" ]; then
84 testpath
=${testfile/.test/}/$2
88 SOURCEFILES
="$SOURCEFILES $SOURCEFILE"
89 echo " case \"/$testpath\": $ns.main (); break;" >> main.vala
90 echo "namespace $ns {" > $SOURCEFILE
91 elif [ $GIRTEST -eq 1 ]; then
92 if [ "$1" = "Input:" ]; then
93 testpath
=${testfile/.test/}
97 cat <<EOF > $SOURCEFILE
99 <repository version="1.2"
100 xmlns="http://www.gtk.org/introspection/core/1.0"
101 xmlns:c="http://www.gtk.org/introspection/c/1.0"
102 xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
103 <include name="GLib" version="2.0"/>
104 <include name="GObject" version="2.0"/>
105 <c:include name="test.h"/>
106 <namespace name="Test"
108 c:identifier-prefixes="Test"
109 c:symbol-prefixes="test">
111 elif [ "$1" = "Output:" ]; then
112 testpath
=${testfile/.test/}
115 SOURCEFILE
=$ns.vapi.ref
120 function sourceend
() {
121 if [ -n "$testpath" ]; then
122 if [ $INVALIDCODE -eq 1 ]; then
123 PACKAGEFLAGS
=$
([ -z "$PACKAGES" ] ||
echo $PACKAGES |
xargs -n 1 echo -n " --pkg")
124 echo "! $VALAC $VALAFLAGS $PACKAGEFLAGS -C $SOURCEFILE" > check
125 elif [ $GIRTEST -eq 1 ]; then
126 if [ $PART -eq 1 ]; then
127 echo " </namespace>" >> $SOURCEFILE
128 echo "</repository>" >> $SOURCEFILE
130 echo "$VAPIGEN $VAPIGENFLAGS --library $ns $ns.gir && tail -n +5 $ns.vapi|sed '\$d'|diff -wu $ns.vapi.ref -" > check
132 echo "}" >> $SOURCEFILE
133 echo "./test$EXEEXT /$testpath" > check
143 echo -n -e "TEST: Building...\033[72G"
145 cat << "EOF" > checkall
150 cat << "EOF" > main.vala
151 void main
(string
[] args
) {
157 for testfile
in "$@"; do
159 echo 'set -e' >> prepare
163 testpath
=${testfile/.vala/}
167 SOURCEFILES
="$SOURCEFILES $SOURCEFILE"
169 echo " case \"/$testpath\": $ns.main (); break;" >> main.vala
170 echo "namespace $ns {" > $SOURCEFILE
171 cat "$srcdir/$testfile" >> $SOURCEFILE
172 echo "}" >> $SOURCEFILE
174 echo "G_DEBUG=fatal-warnings ./test$EXEEXT /$testpath" > check
182 while IFS
="" read -r line
; do
183 if [ $PART -eq 0 ]; then
184 if [ -n "$line" ]; then
190 if [ $INHEADER -eq 1 ]; then
191 if [ -n "$line" ]; then
197 if echo "$line" |
grep -q "^[A-Za-z]\+:"; then
204 echo "$line" >> $SOURCEFILE
208 done < "$srcdir/$testfile"
213 cat prepare check
> $ns.check
214 cat << EOF >> checkall
215 echo -n -e " /$testpath: \033[72G"
217 if $run_prefix bash $ns.check &>log; then
218 echo -e "\033[0;32mOK\033[m"
221 echo -e "\033[0;31mFAIL\033[m"
227 cat << "EOF" >> checkall
228 if [ $fail -eq 0 ]; then
229 echo "All $all tests passed"
231 echo "$fail of $all tests failed"
236 cat << "EOF" >> main.vala
237 default
: assert_not_reached
();
242 cat $SOURCEFILES >> main.vala
244 if $VALAC $VALAFLAGS -o test$EXEEXT $
([ -z "$PACKAGES" ] ||
echo $PACKAGES |
xargs -n 1 echo -n " --pkg") main.vala
&>log
; then
245 echo -e "\033[0;32mOK\033[m"
247 echo -e "\033[0;31mFAIL\033[m"
254 if bash checkall
; then