Explorar o código

added test run scripts

Nick Hildebrant %!s(int64=10) %!d(string=hai) anos
pai
achega
85e02e34dc

+ 2 - 1
.gitignore

@@ -246,4 +246,5 @@ tags
 ##########################
 ## Travis Build Dir
 ##########################
-.travis/build
+.travis/lua
+

+ 7 - 4
.travis.yml

@@ -5,8 +5,11 @@ compiler:
   - gcc
   - clang
 
-script: make WITH_LUA=1 WITH_DEBUG=1 WITH_IPV6=1 WITH_WEBSOCKET=1
+install: make WITH_LUA=1 WITH_DEBUG=1 WITH_IPV6=1 WITH_WEBSOCKET=1
 
-before_install:
-  - bash .travis/setup_lua.sh
-  - bash .travis/install_rocks.sh
+before_script:
+  - .travis/setup_lua.sh
+  - .travis/install_rocks.sh
+
+script:
+  - .travis/run_ci_tests.sh

+ 9 - 8
.travis/install_rocks.sh

@@ -1,13 +1,14 @@
 #!/bin/bash
+set -ev
 
-set -e
+source .travis/lua_env.sh
 
-LUAROCKS=$TRAVIS_BUILD_DIR/build/lua/bin/luarocks
-PATH=$($LUAROCKS path --bin):$PATH
-LUA_PATH=$($LUAROCKS path --lr-path)
-LUA_CPATH=$($LUAROCKS path --lr-cpath)
-
-$LUAROCKS install lunitx
-$LUAROCKS install lua-curl
+# add any rocks required for ci_tests to this list
+# lua-curl depends on a libcurl development package (i.e. libcurl4-openssl-dev)
+ROCKS=(lunitx lua-curl)
 
+for ROCK in ${ROCKS[*]}
+do
+  $LUAROCKS install $ROCK
+done
 

+ 9 - 0
.travis/lua_env.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+set -ev
+
+export LUAROCKS=.travis/lua/bin/luarocks
+export PATH=$($LUAROCKS path --bin):$PATH
+export LUA_PATH=$($LUAROCKS path --lr-path)
+export LUA_CPATH=$($LUAROCKS path --lr-cpath)
+
+

+ 0 - 0
.travis/platform.sh


+ 19 - 0
.travis/run_ci_tests.sh

@@ -0,0 +1,19 @@
+#!/bin/bash
+set -ev
+
+source .travis/lua_env.sh
+
+CI_TEST_DIRS=$(ls -d test/ci_test*)
+
+for DIR in $CI_TEST_DIRS
+do
+  echo starting tests in $DIR
+  SCRIPTS=$(ls -f $DIR/*test*.lua)
+  for SCRIPT in $SCRIPTS
+  do
+    echo starting test script $SCRIPT
+    #lua $SCRIPT
+  done
+done
+
+

+ 27 - 16
.travis/setup_lua.sh

@@ -1,50 +1,61 @@
 #! /bin/bash
-set -e
+set -ev
+
+# this script installs a lua / luarocks environment in .travis/lua
+# this is necessary because travis docker architecture (the fast way)
+# does not permit sudo, and does not contain a useful lua installation
+
+# After this script is finished, you can configure your environment to
+# use it by sourcing lua_env.sh
 
 source .travis/platform.sh
 
+# The current versions when this script was written
 LUA_VERSION=5.2.4
 LUAROCKS_VERSION=2.2.2
 
 # directory where this script is located
 SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
-BUILD_DIR=${TRAVIS_BUILD_DIR:=$SCRIPT_DIR}/build
-echo @BUILD_DIR = $BUILD_DIR
-mkdir -p $BUILD_DIR
-cd $BUILD_DIR
 
+# civetweb base dir
+PROJECT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )
+
+# fetch and unpack lua src
+cd $SCRIPT_DIR
 LUA_BASE=lua-$LUA_VERSION
 rm -rf $LUA_BASE
 curl http://www.lua.org/ftp/$LUA_BASE.tar.gz | tar zx
 
+# build lua
 cd $LUA_BASE
 make $PLATFORM
 make local
 
-LUA_DIR=$BUILD_DIR/lua
+# mv built lua install to target Lua dir
+LUA_DIR=$SCRIPT_DIR/lua
 rm -rf $LUA_DIR
-mv install/ $LUA_DIR
+mv $SCRIPT_DIR/$LUA_BASE/install $LUA_DIR
+
+# add to path required by luarocks installer
 export PATH=$LUA_DIR/bin:$PATH
 
-cd $BUILD_DIR
 
+# fetch and unpack luarocks
+cd $SCRIPT_DIR
 LUAROCKS_BASE=luarocks-$LUAROCKS_VERSION
 rm -rf ${LUAROCKS_BASE}
 LUAROCKS_URL=http://luarocks.org/releases/${LUAROCKS_BASE}.tar.gz
+# -L because it's a 302 redirect
 curl -L $LUAROCKS_URL | tar xzp
 cd $LUAROCKS_BASE
 
+# build luarocks
 ./configure --prefix=$LUA_DIR
-make build 
+make build
 make install
 
-cd $BUILD_DIR
-
+# cleanup source dirs
+cd $SCRIPT_DIR
 rm -rf $LUAROCKS_BASE
 rm -rf $LUA_BASE
 
-echo you need to run the following commands to setup the env vars
-echo export PATH=\$\($LUA_DIR/bin/luarocks path --bin\):\$PATH
-echo export LUA_PATH=\$\(${LUA_DIR}/bin/luarocks path --lr-path\)
-echo export LUA_CPATH=\$\(${LUA_DIR}/bin/luarocks path --lr-cpath\)
-

BIN=BIN
civetweb_test


+ 8 - 0
test/ci_test_basic/test_test.lua

@@ -0,0 +1,8 @@
+local lunit = require('lunitx')
+local cURL = require("cURL")
+
+_ENV = lunit.module('enhanced','seeall')
+
+function test_success() 
+  assert_true (true, 'tests work')
+end

+ 9 - 0
test/ci_test_basic/test_test2.lua

@@ -0,0 +1,9 @@
+local lunit = require('lunitx')
+local cURL = require("cURL")
+
+_ENV = lunit.module('enhanced','seeall')
+
+function test_success_again() 
+  assert_true (true, 'more tests work')
+end
+