forked from AndronixApp/termux-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-runner.sh
More file actions
executable file
·42 lines (36 loc) · 806 Bytes
/
test-runner.sh
File metadata and controls
executable file
·42 lines (36 loc) · 806 Bytes
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
#!/data/data/com.termux/files/usr/bin/bash
if [ $# != 1 ]; then
echo "Specify package to run tests for as only argument"
exit 1
fi
PACKAGE=$1
TEST_DIR=packages/$PACKAGE/tests
if [ ! -d $TEST_DIR ]; then
echo "ERROR: No tests folder for package $PACKAGE"
exit 1
fi
NUM_TESTS=0
NUM_FAILURES=0
for TEST_SCRIPT in $TEST_DIR/*; do
test -t 1 && printf "\033[32m"
echo "Running test ${TEST_SCRIPT}..."
(( NUM_TESTS += 1 ))
test -t 1 && printf "\033[31m"
(
assert_equals() {
FIRST=$1
SECOND=$2
if [ "$FIRST" != "$SECOND" ]; then
echo "assertion failed - expected '$FIRST', got '$SECOND'"
exit 1
fi
}
set -e -u
. $TEST_SCRIPT
)
if [ $? != 0 ]; then
(( NUM_FAILURES += 1 ))
fi
test -t 1 && printf "\033[0m"
done
echo "$NUM_TESTS tests run - $NUM_FAILURES failure(s)"