-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·92 lines (74 loc) · 2.46 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
# ##############################################################################
# test.sh - Driver script to invoke LOC test suites.
# ##############################################################################
Me=$(basename "$0")
set -euo pipefail
pushd "$(dirname "$0")" > /dev/null 2>&1
# shellcheck disable=SC2046
CurrDir="$(pwd)"
popd > /dev/null 2>&1
# Location of binaries, which live under $BUILD_ROOT, if set.
Build_dir="${BUILD_ROOT:-build}"
Build_mode="${BUILD_MODE:-release}"
Bindir="${BINDIR:-${Build_dir}/${Build_mode}/bin}"
Unit_test="${Bindir}/unit_test"
# ##################################################################
# Print help / usage
# ##################################################################
function usage() {
echo "Usage: $Me [--help | --list] | [ < test-name > ]"
echo "To run quick smoke tests : ./${Me}"
}
# ##################################################################
function run_pytests() {
set -x
pushd "${CurrDir}"/tests > /dev/null 2>&1
pytest -v
popd > /dev/null 2>&1
set +x
}
# ##################################################################
function run_unit_tests() {
set -x
${Unit_test}
set +x
}
# List of functions each driving one kind of test.
Tests=( "run_pytests"
"run_unit_tests"
)
# ##################################################################
# List the set of tests that can be run.
function list_tests() {
echo "${Me}: List of tests that can be run:"
list_items_in_array "${Tests[@]}"
}
# --------------------------------------------------------------------------
# Minion to print the contents of a step-array passed-in.
# Ref: https://askubuntu.com/questions/674333/how-to-pass-an-array-as-function-argument
function list_items_in_array() {
local tests_array=("$@")
for str in "${tests_array[@]}"; do
echo " ${str}"
done
}
# ##################################################################
# main() begins here
# ##################################################################
if [ $# -eq 1 ]; then
if [ "$1" == "--help" ]; then
usage
exit 0
fi
if [ "$1" == "--list" ]; then
list_tests
exit 0
fi
# Run the only arg provided, expecting it to be a valid test-fn-name
$1
exit 0
fi
echo "$Me: $(TZ="America/Los_Angeles" date) Start LOC Test Suite Execution."
run_pytests
echo "$Me: $(TZ="America/Los_Angeles" date) LOC Test Suite Execution completed."