This repository has been archived by the owner on Jul 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.sh
executable file
·67 lines (55 loc) · 1.61 KB
/
test.sh
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
#!/bin/bash
SKIP_BUILD=0
while getopts ":s" opt; do
case "$opt" in
s)
SKIP_BUILD=1
;;
esac
done
if [ "$SKIP_BUILD" = "0" ]; then
set -e
(cd build && cmake -DSHADERTOY_BUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=$(pwd)/install/usr/local .. && make -j$(( $(nproc) + 1 )) && cmake -P cmake_install.cmake)
set +e
fi
FAILED_TESTS=0
FAILED_TEST_NAMES=()
DEFAULT_TESTS=debian/tests/*
for TEST_FILE in ${@:-$DEFAULT_TESTS}; do
if [ -x "$TEST_FILE" ] && [[ "$TEST_FILE" != *".sh" ]]; then
TEST_NAME=$(basename "$TEST_FILE")
echo "[==== RUNNING TEST: $TEST_NAME ====]" >&2
# Create temporary directory
TEST_DIR=`mktemp -d`
export AUTOPKGTEST_TMP="$TEST_DIR"
# Setup special vars
export LIBSHADERTOY_DIR=$(pwd)/build/install/usr/local/share/shadertoy
export CMAKE_EXTRA_OPTS="-DCMAKE_PREFIX_PATH=$(pwd)/build/install/usr/local -DCMAKE_MODULE_PATH=$(pwd)/modules -DCMAKE_BUILD_TYPE=Debug"
# Execute test
"$TEST_FILE"
TEST_RESULT=$?
if [ "$TEST_RESULT" -eq 0 ]; then
echo "[==== TEST: $TEST_NAME: PASSED ====]" >&2
# Cleanup
rm -rf "$TEST_DIR"
else
echo "[==== TEST: $TEST_NAME: FAILED ($TEST_RESULT) ====]" >&2
if [ "$TEST_RESULT" -eq 1 ]; then
FAILED_TESTS=$(( FAILED_TESTS + 1 ))
FAILED_TEST_NAMES+=("$TEST_NAME")
elif [ "$TEST_RESULT" -eq 2 ]; then
echo " - Considered non-critical by test script" >&2
fi
fi
fi
done
if [ $FAILED_TESTS -gt 0 ]; then
echo "[==== TEST: SUMMARY OF FAILED TESTS ====]" >&2
for FAILED_TEST_NAME in "${FAILED_TEST_NAMES[@]}"; do
echo " - $FAILED_TEST_NAME" >&2
done
exit 1
else
echo "[==== TEST: ALL TESTS PASSED ====]" >&2
exit 0
fi