From f16143114e76e7064ca84d392bb01d5ed876dd52 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Wed, 7 Mar 2018 22:47:02 +0100 Subject: [PATCH] bind, cmd/gobind/test: remove GOOS build tags from test packages The gobind command is about to get more powerful and able to generate complete and standalone bindings. Platform specific build tags based on GOOS or GOARCH are now meaningless to generate bindings from, so remove them from the test packages. The tags mattered to the reverse bound packages, since the go tool can't build them without the Go wrappers for the imported Java packages. Before this CL, the `android` tag was used to fool the go tool since the host GOOS is unlikely to be android. A fix is to check in the generated Go wrappers, but since the packages are for testing we don't want that. Instead, move the test packages to the testdata directory so the go tool ignores them. Change-Id: I57178e930a400f690ebd7a65758bed894eeb10b0 Reviewed-on: https://go-review.googlesource.com/99315 Reviewed-by: Hyang-Ah Hana Kim --- bind/java/seq_test.go | 10 +++++----- bind/objc/seq_test.go | 8 ++++---- bind/{ => testdata}/testpkg/assets/hello.txt | 0 bind/{ => testdata}/testpkg/javapkg/classes.go | 2 -- bind/{ => testdata}/testpkg/javapkg/java.go | 2 -- bind/{ => testdata}/testpkg/objcpkg/classes.go | 2 -- bind/{ => testdata}/testpkg/objcpkg/objc.go | 2 -- bind/{ => testdata}/testpkg/secondpkg/secondpkg.go | 0 bind/{ => testdata}/testpkg/simplepkg/simplepkg.go | 0 bind/{ => testdata}/testpkg/tagged.go | 0 bind/{ => testdata}/testpkg/testpkg.go | 8 +++----- bind/{ => testdata}/testpkg/unboundpkg/unboundpkg.go | 0 cmd/gobind/gobind_test.go | 10 +++++----- 13 files changed, 17 insertions(+), 27 deletions(-) rename bind/{ => testdata}/testpkg/assets/hello.txt (100%) rename bind/{ => testdata}/testpkg/javapkg/classes.go (99%) rename bind/{ => testdata}/testpkg/javapkg/java.go (98%) rename bind/{ => testdata}/testpkg/objcpkg/classes.go (98%) rename bind/{ => testdata}/testpkg/objcpkg/objc.go (98%) rename bind/{ => testdata}/testpkg/secondpkg/secondpkg.go (100%) rename bind/{ => testdata}/testpkg/simplepkg/simplepkg.go (100%) rename bind/{ => testdata}/testpkg/tagged.go (100%) rename bind/{ => testdata}/testpkg/testpkg.go (98%) rename bind/{ => testdata}/testpkg/unboundpkg/unboundpkg.go (100%) diff --git a/bind/java/seq_test.go b/bind/java/seq_test.go index 6d0fd6f..3e82a56 100644 --- a/bind/java/seq_test.go +++ b/bind/java/seq_test.go @@ -23,21 +23,21 @@ func TestClasses(t *testing.T) { t.Skipf("java importer is not available") } runTest(t, []string{ - "golang.org/x/mobile/bind/testpkg/javapkg", + "golang.org/x/mobile/bind/testdata/testpkg/javapkg", }, "", "ClassesTest") } func TestCustomPkg(t *testing.T) { runTest(t, []string{ - "golang.org/x/mobile/bind/testpkg", + "golang.org/x/mobile/bind/testdata/testpkg", }, "org.golang.custompkg", "CustomPkgTest") } func TestJavaSeqTest(t *testing.T) { runTest(t, []string{ - "golang.org/x/mobile/bind/testpkg", - "golang.org/x/mobile/bind/testpkg/secondpkg", - "golang.org/x/mobile/bind/testpkg/simplepkg", + "golang.org/x/mobile/bind/testdata/testpkg", + "golang.org/x/mobile/bind/testdata/testpkg/secondpkg", + "golang.org/x/mobile/bind/testdata/testpkg/simplepkg", }, "", "SeqTest") } diff --git a/bind/objc/seq_test.go b/bind/objc/seq_test.go index 4dfa334..c3f86f4 100644 --- a/bind/objc/seq_test.go +++ b/bind/objc/seq_test.go @@ -39,9 +39,9 @@ var destination = flag.String("device", "platform=iOS Simulator,name=iPhone 6s P // This requires the xcode command lines tools. func TestObjcSeqTest(t *testing.T) { runTest(t, []string{ - "golang.org/x/mobile/bind/testpkg", - "golang.org/x/mobile/bind/testpkg/secondpkg", - "golang.org/x/mobile/bind/testpkg/simplepkg", + "golang.org/x/mobile/bind/testdata/testpkg", + "golang.org/x/mobile/bind/testdata/testpkg/secondpkg", + "golang.org/x/mobile/bind/testdata/testpkg/simplepkg", }, "xcodetest", "SeqTest.m", false) } @@ -57,7 +57,7 @@ func TestObjcSeqBench(t *testing.T) { // TestObjcSeqWrappers runs ObjC test SeqWrappers.m. // This requires the xcode command lines tools. func TestObjcSeqWrappers(t *testing.T) { - runTest(t, []string{"golang.org/x/mobile/bind/testpkg/objcpkg"}, "xcodewrappers", "SeqWrappers.m", false) + runTest(t, []string{"golang.org/x/mobile/bind/testdata/testpkg/objcpkg"}, "xcodewrappers", "SeqWrappers.m", false) } func runTest(t *testing.T, pkgNames []string, project, testfile string, dumpOutput bool) { diff --git a/bind/testpkg/assets/hello.txt b/bind/testdata/testpkg/assets/hello.txt similarity index 100% rename from bind/testpkg/assets/hello.txt rename to bind/testdata/testpkg/assets/hello.txt diff --git a/bind/testpkg/javapkg/classes.go b/bind/testdata/testpkg/javapkg/classes.go similarity index 99% rename from bind/testpkg/javapkg/classes.go rename to bind/testdata/testpkg/javapkg/classes.go index 2cdcdd7..3f95c48 100644 --- a/bind/testpkg/javapkg/classes.go +++ b/bind/testdata/testpkg/javapkg/classes.go @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build android - package javapkg import ( diff --git a/bind/testpkg/javapkg/java.go b/bind/testdata/testpkg/javapkg/java.go similarity index 98% rename from bind/testpkg/javapkg/java.go rename to bind/testdata/testpkg/javapkg/java.go index cd7367f..948f13a 100644 --- a/bind/testpkg/javapkg/java.go +++ b/bind/testdata/testpkg/javapkg/java.go @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build android - package javapkg import ( diff --git a/bind/testpkg/objcpkg/classes.go b/bind/testdata/testpkg/objcpkg/classes.go similarity index 98% rename from bind/testpkg/objcpkg/classes.go rename to bind/testdata/testpkg/objcpkg/classes.go index b25b207..608dd97 100644 --- a/bind/testpkg/objcpkg/classes.go +++ b/bind/testdata/testpkg/objcpkg/classes.go @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build ios - package objcpkg import ( diff --git a/bind/testpkg/objcpkg/objc.go b/bind/testdata/testpkg/objcpkg/objc.go similarity index 98% rename from bind/testpkg/objcpkg/objc.go rename to bind/testdata/testpkg/objcpkg/objc.go index ab953cf..4c1b07f 100644 --- a/bind/testpkg/objcpkg/objc.go +++ b/bind/testdata/testpkg/objcpkg/objc.go @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build ios - package objcpkg import ( diff --git a/bind/testpkg/secondpkg/secondpkg.go b/bind/testdata/testpkg/secondpkg/secondpkg.go similarity index 100% rename from bind/testpkg/secondpkg/secondpkg.go rename to bind/testdata/testpkg/secondpkg/secondpkg.go diff --git a/bind/testpkg/simplepkg/simplepkg.go b/bind/testdata/testpkg/simplepkg/simplepkg.go similarity index 100% rename from bind/testpkg/simplepkg/simplepkg.go rename to bind/testdata/testpkg/simplepkg/simplepkg.go diff --git a/bind/testpkg/tagged.go b/bind/testdata/testpkg/tagged.go similarity index 100% rename from bind/testpkg/tagged.go rename to bind/testdata/testpkg/tagged.go diff --git a/bind/testpkg/testpkg.go b/bind/testdata/testpkg/testpkg.go similarity index 98% rename from bind/testpkg/testpkg.go rename to bind/testdata/testpkg/testpkg.go index 8ebbcd3..e4ab40a 100644 --- a/bind/testpkg/testpkg.go +++ b/bind/testdata/testpkg/testpkg.go @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin linux - // Package testpkg contains bound functions for testing the cgo-JNI interface. // This is used in tests of golang.org/x/mobile/bind/java. package testpkg @@ -23,9 +21,9 @@ import ( "golang.org/x/mobile/asset" - "golang.org/x/mobile/bind/testpkg/secondpkg" - "golang.org/x/mobile/bind/testpkg/simplepkg" - "golang.org/x/mobile/bind/testpkg/unboundpkg" + "golang.org/x/mobile/bind/testdata/testpkg/secondpkg" + "golang.org/x/mobile/bind/testdata/testpkg/simplepkg" + "golang.org/x/mobile/bind/testdata/testpkg/unboundpkg" ) const ( diff --git a/bind/testpkg/unboundpkg/unboundpkg.go b/bind/testdata/testpkg/unboundpkg/unboundpkg.go similarity index 100% rename from bind/testpkg/unboundpkg/unboundpkg.go rename to bind/testdata/testpkg/unboundpkg/unboundpkg.go diff --git a/cmd/gobind/gobind_test.go b/cmd/gobind/gobind_test.go index 7b771ab..a856da8 100644 --- a/cmd/gobind/gobind_test.go +++ b/cmd/gobind/gobind_test.go @@ -17,11 +17,11 @@ var tests = []struct { pkg string goos string }{ - {"ObjC-Testpkg", "objc", "golang.org/x/mobile/bind/testpkg", ""}, - {"Java-Testpkg", "java", "golang.org/x/mobile/bind/testpkg", ""}, - {"Go-Testpkg", "go", "golang.org/x/mobile/bind/testpkg", ""}, - {"Java-Javapkg", "java", "golang.org/x/mobile/bind/testpkg/javapkg", "android"}, - {"Go-Javapkg", "go", "golang.org/x/mobile/bind/testpkg/javapkg", "android"}, + {"ObjC-Testpkg", "objc", "golang.org/x/mobile/bind/testdata/testpkg", ""}, + {"Java-Testpkg", "java", "golang.org/x/mobile/bind/testdata/testpkg", ""}, + {"Go-Testpkg", "go", "golang.org/x/mobile/bind/testdata/testpkg", ""}, + {"Java-Javapkg", "java", "golang.org/x/mobile/bind/testdata/testpkg/javapkg", "android"}, + {"Go-Javapkg", "go", "golang.org/x/mobile/bind/testdata/testpkg/javapkg", "android"}, } func installGobind() error {