forked from DataDog/datadog-api-client-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-go-tests.sh
executable file
·32 lines (30 loc) · 1.02 KB
/
run-go-tests.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
#!/usr/bin/env bash
set -e
# Match test scenarios
RE_TEST='\^TestScenarios\$.*'
# Only match scenarios and not individual features or steps
RE_SCENARIO='\^TestScenarios\$/v[0-9]+/\^Feature_[^/]+/Scenario_[^/]+\$'
COVERAGE_OPTIONS="-coverpkg=$(go list ./... | grep -v examples | grep -v /test | paste -sd ',' -) -coverprofile=coverage.txt -covermode=atomic"
cd tests
CMD=( go test $(go list ./...) -json -v )
if [ "$#" -ne 2 ]; then
# Run only BDD tests if we specify BDD_TAGS to run
if [ -z $BDD_TAGS ]; then
"${CMD[@]}" $COVERAGE_OPTIONS
else
"${CMD[@]}" -run "TestScenarios"
fi
else
RUN=$(echo $1 | sed 's/-test.run=//')
if [[ ${RUN} =~ ${RE_TEST} ]] && [[ ! ${RUN} =~ ${RE_SCENARIO} ]]; then
TEST=$(echo $RUN | tr -d '$^')
echo "{\"Time\":\"$(date --rfc-3339=ns | tr ' ' 'T')\",\"Action\":\"skip\",\"Package\":\"$2\",\"Test\":\"${TEST//\"/\\\"}\",\"Elapsed\":0}"
else
if [[ ${RERECORD_FAILED_TESTS} == "true" ]]; then
RECORD=true "${CMD[@]}" -run "$RUN" "$2"
else
"${CMD[@]}" -run "$RUN" "$2"
fi
fi
fi
cd ..