forked from FAForever/fa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_lua_tests.sh
More file actions
41 lines (33 loc) · 813 Bytes
/
run_lua_tests.sh
File metadata and controls
41 lines (33 loc) · 813 Bytes
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
#!/bin/bash
# Simple lua code syntax checker using https://github.com/FAForever/lua-lang
# Assumes that FAF lua is installed as `lua`
had_error=0
tests_complete=0
run_test() {
file="$1"
output="$(lua "$file" 2>&1 \
| sed "s:/dev/fd/[0-9]\+:$file:g")"
if [[ $output != "" ]]; then
echo "$output" > /dev/fd/2
if [[ "$output" == *"FAIL"* ]]; then
had_error=1
fi
fi
}
# make sure the test files run in the tests directory
pushd tests >/dev/null
while read file; do
# exclude the unit tester module
if [ "$file" != "./lust.lua" ]; then
run_test "$file"
((tests_complete ++))
fi
done < <(find . -name '*.lua')
popd >/dev/null
echo "Ran $tests_complete tests"
if [[ $had_error != 0 ]]; then
echo "Tests returned errors."
exit $had_error
else
echo "Tests OK."
fi