зеркало из https://github.com/github/vitess-gh.git
Fix make unit_test_race such that it fails in case of errors.
Before this, the command always succeeded, even if races were found. I'm grepping over the output of go test -race to check if there is race because there is no other way to distinguish between a found race and a flaky test.
This commit is contained in:
Родитель
9aaac37c97
Коммит
941ce6279e
2
Makefile
2
Makefile
|
@ -61,7 +61,7 @@ unit_test_cover: build
|
||||||
godep go test $(VT_GO_PARALLEL) -cover ./go/... | misc/parse_cover.py
|
godep go test $(VT_GO_PARALLEL) -cover ./go/... | misc/parse_cover.py
|
||||||
|
|
||||||
unit_test_race: build
|
unit_test_race: build
|
||||||
godep go test $(VT_GO_PARALLEL) -race ./go/...
|
tools/unit_test_race.sh
|
||||||
|
|
||||||
# Run coverage and upload to coveralls.io.
|
# Run coverage and upload to coveralls.io.
|
||||||
# Requires the secret COVERALLS_TOKEN env variable to be set.
|
# Requires the secret COVERALLS_TOKEN env variable to be set.
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Copyright 2015, Google Inc. All rights reserved.
|
||||||
|
# Use of this source code is governed by a BSD-style
|
||||||
|
# license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
temp_log_file="$(mktemp --suffix .unit_test_race.log)"
|
||||||
|
trap '[ -f "$temp_log_file" ] && rm $temp_log_file' EXIT
|
||||||
|
|
||||||
|
# Wrapper around go test -race.
|
||||||
|
|
||||||
|
# This script exists because the -race test doesn't allow to distinguish
|
||||||
|
# between a failed (e.g. flaky) unit test and a found data race.
|
||||||
|
# Although Go 1.5 says 'exit status 66' in case of a race, it exits with 1.
|
||||||
|
# Therefore, we manually check the output of 'go test' for data races and
|
||||||
|
# exit with an error if one was found.
|
||||||
|
|
||||||
|
# NOTE: Go binaries <1.5 had a bug which prevented go test -race from exiting
|
||||||
|
# with a non-zero code when a race is found.
|
||||||
|
# The fix for the bug seems to be: https://go-review.googlesource.com/#/c/4371/
|
||||||
|
# To work-around bugged go (<1.5) binaries, we enable "halt_on_error".
|
||||||
|
GORACE=halt_on_error=1 go test $VT_GO_PARALLEL -race ./go/vt/... 2>&1 | tee $temp_log_file
|
||||||
|
if [ ${PIPESTATUS[0]} -ne 0 ]; then
|
||||||
|
grep "WARNING: DATA RACE" -q $temp_log_file
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo
|
||||||
|
echo "ERROR: go test -race found a data race. See log above."
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "SUCCESS: No data race was found."
|
Загрузка…
Ссылка в новой задаче