/
build-tests-noserv.sh
executable file
·208 lines (183 loc) · 5.05 KB
/
build-tests-noserv.sh
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#!/bin/bash
if [[ $1 != "" ]]; then
if [[ ("$1" == "--help") || ("$1" == "-h") ]]; then
echo "Usage: ./$0 [OPTIONS]
OPTIONS
--clean: removes all .o/.c/.h which have the same base name as .ooc files
(e.g. blah.ooc will yield the removal of blah.o, blah.c, blah.h, if they
exist), and do not compile anything
--help: this message
"
exit 0
fi
fi
rm -f "tests-log.txt"
basePath=`pwd`
ooc_dist="$basePath/../"
total=0
compiled=0
passed=0
notCompiledList=""
failedList=""
passedList=""
if [[ $1 == "--clean" ]]; then
mode="clean"
else
mode="compile"
fi
dirList="."
for i in `ls -R`; do
if [[ -d $i ]]; then
end=${i:${#i}-6}
if [[ $end == "-tests" ]]; then
dirList="$dirList $i"
fi
fi
done
if [[ $mode == "compile" ]]; then
tries=0
# launch the daemon
#java -jar $ooc_dist/dist/ooc.jar -daemon:14269 &> "build-log.txt" &
#ooc -daemon:14269 &> "build-log.txt" &
#sleep 0.3
# connect to the compiler daemon
#while ! exec 3<> /dev/tcp/127.0.0.1/14269; do
# tries=$(( tries + 1 ))
# if [[ "$tries" -eq 42 ]]; then
# echo "All connection tries failed, abandoning..."
# exit 1
# fi
# echo "Connecting... try $tries"
# sleep 0.1
#done
#echo "timing-on" 1>&3
#echo "backend-set gcc" 1>&3
#echo "verbose-on" 1>&3
#echo "libpath-add $ooc_dist/libs" 1>&3
fi
for dir in $dirList; do
if [[ $mode == "clean" ]]; then
echo "Cleaning up tests in $dir"
fi
cd $basePath/$dir
rm -f "test-log.txt"
#if [[ $mode != "clean" ]]; then
# echo "sourcepath-clear" 1>&3
# echo "sourcepath-add `pwd`" 1>&3
# echo "sourcepath-add $ooc_dist/sdk" 1>&3
#fi
for i in *.ooc; do
if [[ $i == "*.ooc" ]]; then
continue
fi
test=${i:0:(${#i}-4)}
if [[ $mode == "clean" ]]; then
rm -f $basePath/$dir/$test.o
rm -f $basePath/$dir/$test.c
rm -f $basePath/$dir/$test.h
rm -f $basePath/$dir/$test
continue
fi
# echo "clear-cache" 1>&3
# echo "outpath-set `pwd`" 1>&3
total=$(( total + 1 ))
# echo "compile $test" 1>&3
ooc $test &> $basePath/build-log.txt
REPLY=$?
#echo "Compiling $dir/$test"
tabbedTest="$dir/$test......................................................................................................................."
tabbedTest="${tabbedTest:0:50}"
printf "\033[1;33mbuilding \033[m$tabbedTest\033[m"
end=${test:${#test}-11}
#read 0<&3;
if [[ "$REPLY" -eq 0 ]]; then
compiled=$(( compiled + 1 ))
printf "compile \033[1;32m[ OK ]\033[m..";
# This is quite characteristic of Windows, I think..
if [[ $WINDIR != "" ]]; then
strip $test.exe
./$test.exe >> "$basePath/tests-log.txt"
code=$?
else
strip $test
./$test --test >> "$basePath/tests-log.txt"
code=$?
fi
if [[ $end == "-shouldfail" ]]; then
if [[ "$code" -eq 0 ]]; then
printf "test \033[1;31m[FAIL]\033[m\n";
failedList="$failedList
$dir/$test"
else
printf "test \033[1;32m[ OK ]\033[m\n";
passed=$(( passed + 1 ))
passedList="$passedList
$dir/$test"
fi
else
if [[ "$code" -eq 0 ]]; then
printf "test \033[1;32m[ OK ]\033[m\n";
passed=$(( passed + 1 ))
passedList="$passedList
$dir/$test"
else
printf "test \033[1;31m[FAIL]\033[m\n";
failedList="$failedList
$dir/$test"
fi
fi
else
if [[ $end == "-shouldfail" ]]; then
printf "compile \033[1;32m[ OK ]\033[m..test \033[1;32m[ OK ]\033[m\n";
compiled=$(( compiled + 1 ))
passed=$(( passed + 1 ))
passedList="$passedList
$dir/$test"
else
printf "compile \033[1;31m[FAIL]\033[m\n";
notCompiledList="$notCompiledList
$dir/$test"
fi
fi
done
done
if [[ $mode == "compiler" ]]; then
echo "halt" 1>&3 # shutdown the compiler daemon
exec 3<&- # disconnect
fi
if [[ $mode == "clean" ]]; then
printf "\033[1;34m======================================================================\033[m\n"
echo "all tests cleaned =)"
printf "\033[1;34m======================================================================\033[m\n"
else
echo
printf "\033[1;34m======================================================================\033[m\n"
echo "all tests finished building"
if [[ $compiled -lt $total ]]; then
printf "\033[1;31m"
else
printf "\033[1;32m"
fi
printf "$compiled / $total tests compiled\033[m\n"
if [[ $passed -lt $compiled ]]; then
printf "\033[1;31m"
else
printf "\033[1;32m"
fi
printf "$passed / $compiled compiled tests passed\033[m\n"
printf "\033[1;34m----------------------------------------------------------------------\033[m\n"
if [[ $notCompiledList != "" ]]; then
printf "\033[4mnot compiled:\033[m $notCompiledList\n"
printf "\033[1;34m----------------------------------------------------------------------\033[m\n"
fi
if [[ $failedList != "" ]]; then
printf "\033[4mfailed tests:\033[m $failedList\n"
printf "\033[1;34m----------------------------------------------------------------------\033[m\n"
fi
if [[ $notCompiledList != "" ]]; then
printf "\033[4mpassed tests:\033[m $passedList\n"
printf "\033[1;34m----------------------------------------------------------------------\033[m\n"
fi
echo "hope you had a good time =)"
printf "\033[1;34m======================================================================\033[m\n"
fi