aboutsummaryrefslogtreecommitdiff
path: root/runtests.sh
blob: 3876b45de58eed42ec3244978123455e7e66a5da (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
#!/bin/sh

EGREP="grep -E"

PLATFORM="`uname -s`"

[ "$PLATFORM" = "SunOS" ] && EGREP=egrep

set -e

do_tests() {
    echo
    cd tests
    ./test.lua | $EGREP 'version|PASS|FAIL'
    cd ..
}

cat <<EOT
Please ensure you do not have the Lua CJSON module installed before
running these tests.

EOT

echo "===== Setting LuaRocks PATH ====="
eval "`luarocks path`"

echo "===== Building UTF-8 test data ====="
( cd tests && ./genutf8.pl; )

echo "===== Cleaning old build data ====="
make clean
rm -f tests/cjson.so

echo "===== Testing LuaRocks build ====="
luarocks make --local
do_tests
luarocks remove --local lua-cjson
make clean

echo "===== Testing Makefile build ====="
make
cp cjson.so tests
do_tests
make clean
rm -f tests/cjson.so

if [ "$PLATFORM" = "Linux" ]
then
	echo "===== Testing RPM build ====="
	make package
	LOG=/tmp/build.$$
	rpmbuild -tb lua-cjson-1.0.4.tar.gz | tee "$LOG"
	RPM="`awk '/^Wrote: / && ! /debuginfo/ { print $2}' < "$LOG"`"
	sudo -- rpm -Uvh \"$RPM\"
	do_tests
	sudo -- rpm -e lua-cjson
	rm -f "$LOG"
fi