Ver código fonte

Use a dedicated script to determine whether to use race detector.

This makes the output of "make test" cleaner, and only show the command that
was actually run (instead of a shell if statement).

Also use the race detector on more supported platforms.
Qi Xiao 3 anos atrás
pai
commit
b235dc10ff
2 arquivos alterados com 14 adições e 5 exclusões
  1. 1 5
      Makefile
  2. 13 0
      tools/run-race.sh

+ 1 - 5
Makefile

@@ -16,11 +16,7 @@ generate:
 # Windows port supports race detection, but requires GCC, so we don't enable it
 # there.
 test:
-	if echo `go env GOOS GOARCH CGO_ENABLED` | egrep -qx '(linux|freebsd|darwin) amd64 1'; then \
-		go test -race ./... ; \
-	else \
-		go test ./... ; \
-	fi
+	go test $(shell ./tools/run-race.sh) ./...
 
 # Generate a basic test coverage report. This will open the report in your
 # browser. See also https://codecov.io/gh/elves/elvish/.

+ 13 - 0
tools/run-race.sh

@@ -0,0 +1,13 @@
+#!/bin/sh
+# Prints "-race" if tests should be run with the race detector.
+#
+# This is a subset of all platforms that actually support the race detector,
+# which is documented in
+# https://golang.org/doc/articles/race_detector#Supported_Systems.
+#
+# We don't run with race detectors on Windows because it requires GCC, which is
+# not always available.
+if echo `go env GOOS GOARCH CGO_ENABLED` |
+   egrep -qx '((linux|darwin|freebsd|netbsd) amd64|(linux|darwin) arm64) 1'; then
+  printf %s -race
+fi