Skip to content

Commit

Permalink
Check for race conditions on Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
dansimau committed Apr 13, 2016
1 parent b009e2e commit 8de97d4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -18,10 +18,11 @@ env:
- RUN="make lint"
- RUN="make test-unit"
- RUN="make test-integration"
- RUN="make test-race"

matrix:
allow_failures:
- env: RUN=test/update-coveralls
- env: RUN="make test-race"
fast_finish: true

script:
Expand Down
6 changes: 5 additions & 1 deletion Makefile
@@ -1,4 +1,4 @@
.PHONY: clean clean-mocks testpop lint mocks out setup test test-integration test-unit
.PHONY: clean clean-mocks testpop lint mocks out setup test test-integration test-unit test-race

SHELL = /bin/bash

Expand Down Expand Up @@ -66,5 +66,9 @@ test-unit:
go generate ./...
test/go-test-prettify ./...

test-race:
go generate ./...
test/go-test-prettify -race ./...

testpop: clean
go build scripts/testpop/testpop.go
17 changes: 17 additions & 0 deletions test/go-test-prettify
Expand Up @@ -29,11 +29,16 @@ _prettify() {
local -i failed=0
local -i skipped=0
local -i errors=0
local -i races=0

if [[ $1 == "-v"* ]]; then
verbose=true
fi

# Context is a buffer used to store the last test line, so we can print it
# to give context about the current output.
local context=

while IFS= read -r line; do
case $line in
"--- PASS:"*)
Expand All @@ -56,6 +61,7 @@ _prettify() {
# Skip output of "RUN" lines by default
"=== RUN"*)
run=$(($run+1))
context="$line"
;;

# Skip output of mock.go success lines (unicode char is the green tick)
Expand All @@ -71,6 +77,16 @@ _prettify() {
fi
;;

# Data races
"WARNING: DATA RACE"*)
races=$(($races+1))
if ! $verbose; then
echo "$context"
echo "==="
echo "$line"
fi
;;

# Skip and ignore printing junk
PASS|FAIL|\?*)
;;
Expand All @@ -95,6 +111,7 @@ _prettify() {
[ $failed -ne 0 ] && echo "# failed: $failed"
[ $skipped -ne 0 ] && echo "# skipped: $skipped"
[ $errors -ne 0 ] && echo "# errors: $errors"
[ $races -ne 0 ] && echo "# races: $races"
echo
}

Expand Down

0 comments on commit 8de97d4

Please sign in to comment.