-
Notifications
You must be signed in to change notification settings - Fork 96
/
run_tests
executable file
·38 lines (32 loc) · 1.13 KB
/
run_tests
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
#!/bin/bash
DOCKER_IMAGE="libremesh/luatest:1.2"
if ! docker inspect --type=image $DOCKER_IMAGE > /dev/null 2>&1; then
echo "Pulling docker image '$DOCKER_IMAGE'."
echo "If you want to build it locally run 'docker build -f Dockerfiles/Dockerfile.unittests -t $DOCKER_IMAGE .'"
docker pull "$DOCKER_IMAGE"
fi
export DOCKER_IMAGE
TESTS_PATHS='packages/*/tests/test*.lua tests/test*.lua'
LIB_PATHS='tests/fakes/?.lua;packages/safe-upgrade/files/usr/sbin/?'
# autodiscover more LIB_PATHS
for pkg in packages/*/files/usr/lib/lua/; do
LIB_PATHS="$LIB_PATHS;$pkg?.lua"
done
# append default paths
LIB_PATHS="$LIB_PATHS;;"
LUA_PATH=$LIB_PATHS
export LUA_PATH
# create a temporaty script file to be able to run multiple commands inside docker
temp_file=$(mktemp /tmp/lime_test.XXXX)
trap "rm -f ${temp_file}" 0 2 3 15
chmod +x ${temp_file}
if [[ -z "${LUA_ENABLE_LOGGING}" ]]; then
LOGGING="LUA_DISABLE_LOGGING=1"
else
LOGGING="LUA_ENABLE_LOGGING=1"
fi
cat > ${temp_file}<< SCRIPT
#!/bin/bash
${LOGGING} LUA_PATH='$LUA_PATH' busted -v --coverage ${TESTS_PATHS} --lpath='${LIB_PATHS}' ${1} && luacov
SCRIPT
./tools/dockertestshell "${temp_file}"