sudo: required
dist: trusty

os: linux

language: c

compiler:
  - gcc
  - clang

env:
  matrix:
    - LUA=lua5.1-dev LUA_DEV=liblua5.1-dev LUA_INCLUDE_DIR=/usr/include/lua5.1 LUA_CMODULE_DIR=/lib LUALIB=-llua5.1
    - LUA=libluajit-5.1-dev LUA_DEV=libluajit-5.1-dev LUA_INCLUDE_DIR=/usr/include/luajit-2.0 LUA_CMODULE_DIR=/lib LUALIB=-lluajit-5.1

install:
    - sudo apt-get update
    - sudo apt-get install -qq -y $LUA luarocks cppcheck valgrind
    - sudo apt-get install -qq -y cpanminus libipc-run3-perl > build.log 2>&1 || (cat build.log && exit 1)
    - sudo cpanm --notest Test::Base Test::LongString > build.log 2>&1 || (cat build.log && exit 1)

script:
  - cppcheck --force --error-exitcode=1 --enable=warning . > build.log 2>&1 || (cat build.log && exit 1)
  - sh runtests.sh
  - make
  - prove -Itests tests
  - TEST_LUA_USE_VALGRIND=1 prove -Itests tests > build.log 2>&1
  - cat build.log
  - grep -E '^==[0-9]+==' build.log; if [ "$?" == 0 ]; then exit 1; else exit 0; fi
