-
Notifications
You must be signed in to change notification settings - Fork 7
/
test-runner.sh
executable file
·66 lines (54 loc) · 1.83 KB
/
test-runner.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
#!/usr/bin/env bash
GOPATH="${GOPATH:-~/go}"
PATH=$PATH:$GOPATH/bin
TEST_DIR="./tests"
# Override REPORTS_DUMP_DIR if ARTIFACT_DIR is set
if [[ -n "${ARTIFACT_DIR}" ]]; then
# `export` passes the variable down to a child process,
# which is needed because of the `eval`
export REPORTS_DUMP_DIR=${ARTIFACT_DIR}
fi
# Check that TEST_FEATURES environment variable has been set
if [[ -z "${TEST_FEATURES}" ]]; then
echo "TEST_FEATURES environment variable is undefined"
exit 1
fi
# Set feature_dirs to top-level test directory when "all" feature provided
if [[ "${TEST_FEATURES}" == "all" ]]; then
feature_dirs=${TEST_DIR}
else
# Find all test directories matching provided features
for feature in ${TEST_FEATURES}; do
discovered_features=$(find $TEST_DIR -depth -name "${feature}" -not -path '*/internal/*' 2> /dev/null)
if [[ ! -z $discovered_features ]]; then
feature_dirs+=" "$discovered_features
else
if [[ "${VERBOSE_SCRIPT}" == "true" ]]; then
echo "Could not find any feature directories matching ${feature}"
fi
fi
done
if [[ -z "${feature_dirs}" ]]; then
echo "Could not find any feature directories for provided features: ${TEST_FEATURES}"
exit 1
fi
if [[ "${VERBOSE_SCRIPT}" == "true" ]]; then
echo "Found feature directories:"
for directory in $feature_dirs; do printf "$directory\n"; done
fi
fi
# Build ginkgo command
cmd="ginkgo -timeout=24h --keep-going --require-suite -r"
if [[ "${TEST_VERBOSE}" == "true" ]]; then
cmd+=" -vv"
fi
if [[ "${TEST_TRACE}" == "true" ]]; then
cmd+=" --trace"
fi
if [[ ! -z "${TEST_LABELS}" ]]; then
cmd+=" --label-filter=\"${TEST_LABELS}\""
fi
cmd+=" "$feature_dirs" $@" # + user args --xxx=yyy...
# Execute ginkgo command
echo $cmd
eval $cmd