aboutsummaryrefslogtreecommitdiff
path: root/runtests.sh
diff options
context:
space:
mode:
Diffstat (limited to 'runtests.sh')
-rwxr-xr-xruntests.sh91
1 files changed, 91 insertions, 0 deletions
diff --git a/runtests.sh b/runtests.sh
new file mode 100755
index 0000000..d313db3
--- /dev/null
+++ b/runtests.sh
@@ -0,0 +1,91 @@
1#!/bin/sh
2
3PLATFORM="`uname -s`"
4[ "$1" ] && VERSION="$1" || VERSION="1.0devel"
5
6set -e
7
8# Portable "ggrep -A" replacement
9# contextgrep PATTERN POST_MATCH_LINES
10contextgrep() {
11 awk "/$1/ { count = ($2 + 1) } count { count--; print }"
12}
13
14do_tests() {
15 echo
16 cd tests
17 lua -e 'require "cjson"; print("Testing Lua CJSON version " .. cjson.version)'
18 ./test.lua | contextgrep 'FAIL|Summary' 3 | grep -v PASS | cut -c -70
19 cd ..
20}
21
22echo "===== Setting LuaRocks PATH ====="
23eval "`luarocks path`"
24
25echo "===== Building UTF-8 test data ====="
26( cd tests && ./genutf8.pl; )
27
28echo "===== Cleaning old build data ====="
29make clean
30rm -f tests/cjson.so
31
32echo "===== Verifying cjson.so is not installed ====="
33
34cd tests
35if lua -e 'require "cjson"' 2>/dev/null
36then
37 cat <<EOT
38Please ensure you do not have the Lua CJSON module installed before
39running these tests.
40EOT
41 exit
42fi
43cd ..
44
45echo "===== Testing LuaRocks build ====="
46luarocks make --local
47do_tests
48luarocks remove --local lua-cjson
49make clean
50
51echo "===== Testing Makefile build ====="
52make
53cp cjson.so tests
54do_tests
55make clean
56rm -f tests/cjson.so
57
58echo "===== Testing Cmake build ====="
59mkdir build
60cd build
61cmake ..
62make
63cd ..
64cp build/cjson.so tests
65do_tests
66rm -rf build tests/cjson.so
67
68if [ "$PLATFORM" = "Linux" ]
69then
70 echo "===== Testing RPM build ====="
71 SRCTGZ=""
72 TGZ=lua-cjson-$VERSION.tar.gz
73 for D in .. packages .
74 do
75 [ -r "$D/$TGZ" ] && SRCTGZ="$D/$TGZ"
76 done
77 if [ "$SRCTGZ" ]
78 then
79 LOG=/tmp/build.$$
80 rpmbuild -tb "$SRCTGZ" > "$LOG"
81 RPM="`awk '/^Wrote: / && ! /debuginfo/ { print $2}' < "$LOG"`"
82 sudo -- rpm -Uvh \"$RPM\"
83 do_tests
84 sudo -- rpm -e lua-cjson
85 rm -f "$LOG"
86 else
87 echo "==> skipping, $TGZ not found"
88 fi
89fi
90
91# vi:ai et sw=4 ts=4: