Welcome to mirror list, hosted at ThFree Co, Russian Federation.

runtests.sh - github.com/mpx/lua-cjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d313db33c15be57ea78e6000ed430d3f90ae5534 (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
#!/bin/sh

PLATFORM="`uname -s`"
[ "$1" ] && VERSION="$1" || VERSION="1.0devel"

set -e

# Portable "ggrep -A" replacement
# contextgrep PATTERN POST_MATCH_LINES
contextgrep() {
    awk "/$1/ { count = ($2 + 1) } count { count--; print }"
}

do_tests() {
    echo
    cd tests
    lua -e 'require "cjson"; print("Testing Lua CJSON version " .. cjson.version)'
    ./test.lua | contextgrep 'FAIL|Summary' 3 | grep -v PASS | cut -c -70
    cd ..
}

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 "===== Verifying cjson.so is not installed ====="

cd tests
if lua -e 'require "cjson"' 2>/dev/null
then
    cat <<EOT
Please ensure you do not have the Lua CJSON module installed before
running these tests.
EOT
    exit
fi
cd ..

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

echo "===== Testing Cmake build ====="
mkdir build
cd build
cmake ..
make
cd ..
cp build/cjson.so tests
do_tests
rm -rf build tests/cjson.so

if [ "$PLATFORM" = "Linux" ]
then
    echo "===== Testing RPM build ====="
    SRCTGZ=""
    TGZ=lua-cjson-$VERSION.tar.gz
    for D in .. packages .
    do
        [ -r "$D/$TGZ" ] && SRCTGZ="$D/$TGZ"
    done
    if [ "$SRCTGZ" ]
    then
        LOG=/tmp/build.$$
        rpmbuild -tb "$SRCTGZ" > "$LOG"
        RPM="`awk '/^Wrote: / && ! /debuginfo/ { print $2}' < "$LOG"`"
        sudo -- rpm -Uvh \"$RPM\"
        do_tests
        sudo -- rpm -e lua-cjson
        rm -f "$LOG"
    else
        echo "==> skipping, $TGZ not found"
    fi
fi

# vi:ai et sw=4 ts=4: