cmd/go: skip tests that do not work with gccgo

These tests fail for various reasons, most commonly because gccgo
doesn't really have GOROOT, so things like `go build errors` fail.

Change-Id: I4c0cb95a661be552725b10675dd4cca7f132323a
Reviewed-on: https://go-review.googlesource.com/45696
Reviewed-by: Than McIntosh <thanm@google.com>
diff --git a/libgo/go/cmd/go/go_test.go b/libgo/go/cmd/go/go_test.go
index fa78578..eaa8685 100644
--- a/libgo/go/cmd/go/go_test.go
+++ b/libgo/go/cmd/go/go_test.go
@@ -100,7 +100,7 @@
 
 		switch runtime.GOOS {
 		case "linux", "darwin", "freebsd", "windows":
-			canRace = canCgo && runtime.GOARCH == "amd64"
+			canRace = canCgo && runtime.GOARCH == "amd64" && runtime.Compiler != "gccgo"
 		}
 	}
 
@@ -143,6 +143,13 @@
 	stdout, stderr bytes.Buffer
 }
 
+// skipIfGccgo skips the test if using gccgo.
+func skipIfGccgo(t *testing.T, msg string) {
+	if runtime.Compiler == "gccgo" {
+		t.Skipf("skipping test not supported on gccgo: %s", msg)
+	}
+}
+
 // testgo sets up for a test that runs testgo.
 func testgo(t *testing.T) *testgoData {
 	testenv.MustHaveGoBuild(t)
@@ -632,6 +639,7 @@
 }
 
 func TestProgramNameInCrashMessages(t *testing.T) {
+	skipIfGccgo(t, "gccgo does not use cmd/link")
 	tg := testgo(t)
 	defer tg.cleanup()
 	tg.parallel()
@@ -757,6 +765,7 @@
 }
 
 func TestGoListStandard(t *testing.T) {
+	skipIfGccgo(t, "gccgo does not GOROOT")
 	tg := testgo(t)
 	defer tg.cleanup()
 	// TODO: tg.parallel()
@@ -854,6 +863,7 @@
 }
 
 func TestGoInstallDetectsRemovedFiles(t *testing.T) {
+	skipIfGccgo(t, "gccgo does not yet support package build IDs")
 	tg := testgo(t)
 	defer tg.cleanup()
 	tg.parallel()
@@ -923,6 +933,7 @@
 }
 
 func TestGoInstallDetectsRemovedFilesInPackageMain(t *testing.T) {
+	skipIfGccgo(t, "gccgo does not yet support package build IDs")
 	tg := testgo(t)
 	defer tg.cleanup()
 	tg.parallel()
@@ -1060,6 +1071,7 @@
 }
 
 func TestInternalPackagesInGOROOTAreRespected(t *testing.T) {
+	skipIfGccgo(t, "gccgo does not have GOROOT")
 	tg := testgo(t)
 	defer tg.cleanup()
 	tg.runFail("build", "-v", "./testdata/testinternal")
@@ -1397,6 +1409,7 @@
 
 // Issue 12690
 func TestPackageNotStaleWithTrailingSlash(t *testing.T) {
+	skipIfGccgo(t, "gccgo does not have GOROOT")
 	tg := testgo(t)
 	defer tg.cleanup()
 
@@ -1587,6 +1600,7 @@
 }
 
 func TestGoListCmdOnlyShowsCommands(t *testing.T) {
+	skipIfGccgo(t, "gccgo has no GOROOT")
 	tg := testgo(t)
 	defer tg.cleanup()
 	tg.parallel()
@@ -1791,6 +1805,7 @@
 }
 
 func TestLdflagsArgumentsWithSpacesIssue3941(t *testing.T) {
+	skipIfGccgo(t, "gccgo does not support -ldflags -X")
 	tg := testgo(t)
 	defer tg.cleanup()
 	tg.parallel()
@@ -1804,6 +1819,7 @@
 }
 
 func TestGoTestCpuprofileLeavesBinaryBehind(t *testing.T) {
+	skipIfGccgo(t, "gccgo has no standard packages")
 	tg := testgo(t)
 	defer tg.cleanup()
 	// TODO: tg.parallel()
@@ -1814,6 +1830,7 @@
 }
 
 func TestGoTestCpuprofileDashOControlsBinaryLocation(t *testing.T) {
+	skipIfGccgo(t, "gccgo has no standard packages")
 	tg := testgo(t)
 	defer tg.cleanup()
 	// TODO: tg.parallel()
@@ -1824,6 +1841,7 @@
 }
 
 func TestGoTestMutexprofileLeavesBinaryBehind(t *testing.T) {
+	skipIfGccgo(t, "gccgo has no standard packages")
 	tg := testgo(t)
 	defer tg.cleanup()
 	// TODO: tg.parallel()
@@ -1834,6 +1852,7 @@
 }
 
 func TestGoTestMutexprofileDashOControlsBinaryLocation(t *testing.T) {
+	skipIfGccgo(t, "gccgo has no standard packages")
 	tg := testgo(t)
 	defer tg.cleanup()
 	// TODO: tg.parallel()
@@ -1844,6 +1863,7 @@
 }
 
 func TestGoTestDashCDashOControlsBinaryLocation(t *testing.T) {
+	skipIfGccgo(t, "gccgo has no standard packages")
 	tg := testgo(t)
 	defer tg.cleanup()
 	tg.parallel()
@@ -1853,6 +1873,7 @@
 }
 
 func TestGoTestDashOWritesBinary(t *testing.T) {
+	skipIfGccgo(t, "gccgo has no standard packages")
 	tg := testgo(t)
 	defer tg.cleanup()
 	tg.parallel()
@@ -1862,6 +1883,7 @@
 }
 
 func TestGoTestDashIDashOWritesBinary(t *testing.T) {
+	skipIfGccgo(t, "gccgo has no standard packages")
 	tg := testgo(t)
 	defer tg.cleanup()
 	tg.parallel()
@@ -2057,6 +2079,7 @@
 }
 
 func TestShadowingLogic(t *testing.T) {
+	skipIfGccgo(t, "gccgo has no standard packages")
 	tg := testgo(t)
 	defer tg.cleanup()
 	pwd := tg.pwd()
@@ -2267,6 +2290,7 @@
 }
 
 func TestCoverageWithCgo(t *testing.T) {
+	skipIfGccgo(t, "gccgo has no cover tool")
 	if !canCgo {
 		t.Skip("skipping because cgo not enabled")
 	}
@@ -3009,6 +3033,7 @@
 }
 
 func TestGoInstallPkgdir(t *testing.T) {
+	skipIfGccgo(t, "gccgo has no standard packages")
 	tg := testgo(t)
 	tg.parallel()
 	defer tg.cleanup()
@@ -3022,6 +3047,8 @@
 }
 
 func TestGoTestRaceInstallCgo(t *testing.T) {
+	skipIfGccgo(t, "gccgo has no race detector")
+
 	switch sys := runtime.GOOS + "/" + runtime.GOARCH; sys {
 	case "darwin/amd64", "freebsd/amd64", "linux/amd64", "windows/amd64":
 		// ok
@@ -3244,6 +3271,7 @@
 }
 
 func TestGoBuildOutput(t *testing.T) {
+	skipIfGccgo(t, "gccgo has no standard packages")
 	tg := testgo(t)
 	defer tg.cleanup()
 
@@ -3323,6 +3351,7 @@
 }
 
 func TestIssue13655(t *testing.T) {
+	skipIfGccgo(t, "gccgo has no standard packages")
 	tg := testgo(t)
 	defer tg.cleanup()
 	for _, pkg := range []string{"runtime", "runtime/internal/atomic"} {
@@ -3709,6 +3738,7 @@
 
 func TestLinkXImportPathEscape(t *testing.T) {
 	// golang.org/issue/16710
+	skipIfGccgo(t, "gccgo does not support -ldflags -X")
 	tg := testgo(t)
 	defer tg.cleanup()
 	tg.parallel()
@@ -3738,6 +3768,7 @@
 // Issue 18225.
 // This is really a cmd/asm issue but this is a convenient place to test it.
 func TestConcurrentAsm(t *testing.T) {
+	skipIfGccgo(t, "gccgo does not use cmd/asm")
 	tg := testgo(t)
 	defer tg.cleanup()
 	tg.parallel()
diff --git a/libgo/go/cmd/go/note_test.go b/libgo/go/cmd/go/note_test.go
index 2ee013f..7b5568f 100644
--- a/libgo/go/cmd/go/note_test.go
+++ b/libgo/go/cmd/go/note_test.go
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// +build gc
+
 package main_test
 
 import (