-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rerun failed tests once in CI (#328)
- Loading branch information
Slavek Kabrda
authored
Jun 9, 2020
1 parent
67aa4ff
commit 701368e
Showing
2 changed files
with
18 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.travis.yml | ||
git_push.sh | ||
gotestsum.json | ||
coverage.txt | ||
.env* | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
#!/usr/bin/env sh | ||
set -e | ||
echo "Ensuring all dependencies are present in LICENSE-3rdparty.csv ..." | ||
go mod tidy | ||
ALL_DEPS=`cat go.sum | awk '{print $1}' | uniq | sort | sed "s|^\(.*\)|go.sum,\1,|"` | ||
DEPS_NOT_FOUND="" | ||
for one_dep in `echo $ALL_DEPS`; do | ||
set +e | ||
cat LICENSE-3rdparty.csv | grep "$one_dep" > /dev/null 2>&1 | ||
if [ $? -ne 0 ]; then | ||
DEPS_NOT_FOUND="${DEPS_NOT_FOUND}\n${one_dep}<LICENSE>,<COPYRIGHT>" | ||
fi | ||
set -e | ||
done | ||
if [ -n "$DEPS_NOT_FOUND" ]; then | ||
echo "Some dependencies were not found in LICENSE-3rdparty.csv, please add: $DEPS_NOT_FOUND" | ||
|
@@ -28,5 +25,21 @@ GO111MODULE=on go get -u gotest.tools/[email protected] | |
cd - | ||
|
||
golint ./... | ||
gotestsum --format testname -- -coverpkg=$(go list ./... | grep -v /test | paste -sd "," -) -coverprofile=coverage.txt -covermode=atomic -v $(go list ./...) | ||
declare -i RESULT=0 | ||
gotestsum --jsonfile gotestsum.json --format testname -- -coverpkg=$(go list ./... | grep -v /test | paste -sd "," -) -coverprofile=coverage.txt -covermode=atomic -v $(go list ./...) | ||
RESULT+=$? | ||
if [ "$CI" == "true" -a "$RESULT" -ne 0 ]; then | ||
RESULT=0 | ||
echo "\n============= Rerunning failed tests =============\n" | ||
# NOTE: since `go test` (and `gotestsum`) don't allow specifying multiple different test cases | ||
# from different test modules with `-run`, we run them one by one in form of: | ||
# gotestsum <arguments> github.com/DataDog/datadog-api-client-go/tests/api/v<version>/datadog -run ^TestCaseName$ | ||
while read -r i ; do | ||
gotestsum --format testname -- -v $i | ||
RESULT+=$? | ||
done <<EOF | ||
`cat gotestsum.json | jq -s -r -c '.[] | select(.Action=="fail") | select (.Test!=null) | "\(.Package) -run ^\(.Test)$"'` | ||
EOF | ||
fi | ||
go mod tidy | ||
exit $RESULT |