go/internal/gcimporter: skip stdlib tests in race mode as they are too slow

The duration causes them to be flakey on the builders.

Change-Id: I968c6418054e42e3758a6ba4030750f12c4d4b66
Reviewed-on: https://go-review.googlesource.com/c/tools/+/180844
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
diff --git a/go/internal/gcimporter/bexport_test.go b/go/internal/gcimporter/bexport_test.go
index 3c98a5e..89870b1 100644
--- a/go/internal/gcimporter/bexport_test.go
+++ b/go/internal/gcimporter/bexport_test.go
@@ -22,6 +22,8 @@
 	"golang.org/x/tools/go/loader"
 )
 
+var isRace = false
+
 func TestBExportData_stdlib(t *testing.T) {
 	if runtime.Compiler == "gccgo" {
 		t.Skip("gccgo standard library is inaccessible")
@@ -29,6 +31,9 @@
 	if runtime.GOOS == "android" {
 		t.Skipf("incomplete std lib on %s", runtime.GOOS)
 	}
+	if isRace {
+		t.Skipf("stdlib tests take too long in race mode and flake on builders")
+	}
 
 	// Load, parse and type-check the program.
 	ctxt := build.Default // copy
diff --git a/go/internal/gcimporter/iexport_test.go b/go/internal/gcimporter/iexport_test.go
index efb8d75..3c91810 100644
--- a/go/internal/gcimporter/iexport_test.go
+++ b/go/internal/gcimporter/iexport_test.go
@@ -35,6 +35,9 @@
 	if runtime.GOOS == "android" {
 		t.Skipf("incomplete std lib on %s", runtime.GOOS)
 	}
+	if isRace {
+		t.Skipf("stdlib tests take too long in race mode and flake on builders")
+	}
 
 	// Load, parse and type-check the program.
 	ctxt := build.Default // copy
diff --git a/go/internal/gcimporter/israce_test.go b/go/internal/gcimporter/israce_test.go
new file mode 100644
index 0000000..af8e52b
--- /dev/null
+++ b/go/internal/gcimporter/israce_test.go
@@ -0,0 +1,11 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build race
+
+package gcimporter_test
+
+func init() {
+	isRace = true
+}