cmd/gorename: disable TestGeneratedFiles for !cgo builds

Fixes golang/go#21055.

Change-Id: I126cef4496c15424048e39b2af111c95580b90fb
Reviewed-on: https://go-review.googlesource.com/49390
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Chris Broadfoot <cbro@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/cmd/gorename/cgo_test.go b/cmd/gorename/cgo_test.go
new file mode 100644
index 0000000..fd07553
--- /dev/null
+++ b/cmd/gorename/cgo_test.go
@@ -0,0 +1,11 @@
+// Copyright 2017 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 cgo
+
+package main_test
+
+func init() {
+	haveCGO = true
+}
diff --git a/cmd/gorename/gorename_test.go b/cmd/gorename/gorename_test.go
index e598b34..20dbd9e 100644
--- a/cmd/gorename/gorename_test.go
+++ b/cmd/gorename/gorename_test.go
@@ -1,3 +1,7 @@
+// Copyright 2017 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.
+
 package main_test
 
 import (
@@ -12,6 +16,8 @@
 	"testing"
 )
 
+var haveCGO bool
+
 type test struct {
 	offset, from, to string // specify the arguments
 	fileSpecified    bool   // true if the offset or from args specify a specific file
@@ -23,6 +29,10 @@
 
 // Test that renaming that would modify cgo files will produce an error and not modify the file.
 func TestGeneratedFiles(t *testing.T) {
+	if !haveCGO {
+		t.Skipf("skipping test: no cgo")
+	}
+
 	tmp, bin, cleanup := buildGorename(t)
 	defer cleanup()