runtests.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/sh
  2. PLATFORM="`uname -s`"
  3. [ "$1" ] && VERSION="$1" || VERSION="2.1devel"
  4. set -e
  5. # Portable "ggrep -A" replacement.
  6. # Work around Solaris awk record limit of 2559 bytes.
  7. # contextgrep PATTERN POST_MATCH_LINES
  8. contextgrep() {
  9. cut -c -2500 | awk "/$1/ { count = ($2 + 1) } count > 0 { count--; print }"
  10. }
  11. do_tests() {
  12. echo
  13. cd tests
  14. lua -e 'print("Testing Lua CJSON version " .. require("cjson")._VERSION)'
  15. ./test.lua | contextgrep 'FAIL|Summary' 3 | grep -v PASS | cut -c -150
  16. cd ..
  17. }
  18. echo "===== Setting LuaRocks PATH ====="
  19. eval "`luarocks path`"
  20. echo "===== Building UTF-8 test data ====="
  21. ( cd tests && ./genutf8.pl; )
  22. echo "===== Cleaning old build data ====="
  23. make clean
  24. rm -f tests/cjson.so
  25. echo "===== Verifying cjson.so is not installed ====="
  26. cd tests
  27. if lua -e 'require "cjson"' 2>/dev/null
  28. then
  29. cat <<EOT
  30. Please ensure you do not have the Lua CJSON module installed before
  31. running these tests.
  32. EOT
  33. exit
  34. fi
  35. cd ..
  36. echo "===== Testing LuaRocks build ====="
  37. luarocks make --local
  38. do_tests
  39. luarocks remove --local lua-cjson
  40. make clean
  41. echo "===== Testing Makefile build ====="
  42. make
  43. cp -r lua/cjson cjson.so tests
  44. do_tests
  45. make clean
  46. rm -rf tests/cjson{,.so}
  47. echo "===== Testing Cmake build ====="
  48. mkdir build
  49. cd build
  50. cmake ..
  51. make
  52. cd ..
  53. cp -r lua/cjson build/cjson.so tests
  54. do_tests
  55. rm -rf build tests/cjson{,.so}
  56. if [ "$PLATFORM" = "Linux" ]
  57. then
  58. echo "===== Testing RPM build ====="
  59. SRCTGZ=""
  60. TGZ=lua-cjson-$VERSION.tar.gz
  61. for D in .. packages .
  62. do
  63. [ -r "$D/$TGZ" ] && SRCTGZ="$D/$TGZ"
  64. done
  65. if [ "$SRCTGZ" ]
  66. then
  67. LOG=/tmp/build.$$
  68. rpmbuild -tb "$SRCTGZ" > "$LOG"
  69. RPM="`awk '/^Wrote: / && ! /debuginfo/ { print $2}' < "$LOG"`"
  70. sudo -- rpm -Uvh \"$RPM\"
  71. do_tests
  72. sudo -- rpm -e lua-cjson
  73. rm -f "$LOG"
  74. else
  75. echo "==> skipping, $TGZ not found"
  76. fi
  77. fi
  78. # vi:ai et sw=4 ts=4: