blob: c06dda3581b23d9e32e96b82596046e2d29353b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
#!/usr/bin/env bash
# testrunner.sh
#
# Copyright (C) 2006-2008 Jürg Billeter
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# Author:
# Jürg Billeter <j@bitron.ch>
builddir=$PWD
topbuilddir=$TOPBUILDDIR
topsrcdir=$TOPSRCDIR
vapidir=$topsrcdir/vapi
export G_DEBUG=fatal_warnings
export PKG_CONFIG_PATH=$topbuilddir:$topbuilddir/libvaladoc
export LD_LIBRARY_PATH=$topbuilddir/vala/.libs:$topbuilddir/libvaladoc/.libs
VALAC=$topbuilddir/compiler/valac$EXEEXT
VALAFLAGS="$VALAFLAGS \
-X -D -X TOP_SRC_DIR=\"$topsrcdir\" \
--vapidir $vapidir --pkg libgvc \
--vapidir $topsrcdir/vala --pkg libvala$PACKAGE_SUFFIX \
--vapidir $topsrcdir/libvaladoc --pkg valadoc$PACKAGE_SUFFIX \
--disable-warnings \
--main main \
--save-temps \
--cc $CC \
-X -g \
-X -O0 \
-X -pipe \
-X -lm \
-X -L$topbuilddir/vala/.libs -X -lvala$PACKAGE_SUFFIX \
-X -L$topbuilddir/libvaladoc/.libs -X -lvaladoc$PACKAGE_SUFFIX \
-X -I$topsrcdir/gee \
-X -I$topsrcdir/vala \
-X -I$topsrcdir/libvaladoc \
$topsrcdir/valadoc/tests/libvaladoc/parser/generic-scanner.vala"
# Incorporate the TEST_CFLAGS.
for cflag in ${TEST_CFLAGS}; do
VALAFLAGS="${VALAFLAGS} -X ${cflag}"
done
# Incorporate the user's CFLAGS. Matters if the user decided to insert
# -m32 in CFLAGS, for example.
for cflag in ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
if [[ ! $cflag =~ ^\-O[0-9]$ ]]; then
VALAFLAGS="${VALAFLAGS} -X ${cflag}"
fi
done
testdir=_test
rm -rf $testdir
mkdir $testdir
cd $testdir
echo -n -e "TEST: Building...\033[72G"
cat << "EOF" > checkall
all=0
fail=0
EOF
cat << "EOF" > main.vala
void main (string[] args) {
switch (args[1]) {
EOF
PACKAGES=gio-2.0
SOURCEFILES=
for testfile in "$@"; do
rm -f prepare check
echo 'set -e' >> prepare
case "$testfile" in
*.vala)
testpath=${testfile/.vala/}
ns=${testpath//\//.}
ns=${ns//-/_}
SOURCEFILE=$ns.vala
SOURCEFILES="$SOURCEFILES $SOURCEFILE"
echo " case \"/$testpath\": $ns.main (); break;" >> main.vala
echo "namespace $ns {" > $SOURCEFILE
cat "$topsrcdir/valadoc/tests/$testfile" >> $SOURCEFILE
echo "}" >> $SOURCEFILE
echo "./test$EXEEXT /$testpath" > check
;;
esac
cat prepare check > $ns.check
cat << EOF >> checkall
echo -n -e " /$testpath: \033[72G"
((all++))
if bash $ns.check &>log; then
echo -e "\033[0;32mOK\033[m"
else
((fail++))
echo -e "\033[0;31mFAIL\033[m"
cat log
fi
EOF
done
cat << "EOF" >> checkall
if [ $fail -eq 0 ]; then
echo "All $all tests passed"
else
echo "$fail of $all tests failed"
exit 1
fi
EOF
cat << "EOF" >> main.vala
default: assert_not_reached ();
}
}
EOF
cat $SOURCEFILES >> main.vala
if $VALAC $VALAFLAGS -o test$EXEEXT $([ -z "$PACKAGES" ] || echo $PACKAGES | xargs -n 1 echo -n " --pkg") main.vala &>log; then
echo -e "\033[0;32mOK\033[m"
else
echo -e "\033[0;31mFAIL\033[m"
cat log
cd $builddir
exit 1
fi
if bash checkall; then
cd $builddir
rm -rf $testdir
else
cd $builddir
exit 1
fi
|