@@ -21,13 +21,16 @@ var tests = []struct {
21
21
lang string
22
22
pkg string
23
23
goos string
24
+ // reverse is true if the test needs to generate reverse bindings using
25
+ // external tools such as javap.
26
+ reverse bool
24
27
}{
25
- {"ObjC-Testpkg" , "objc" , "golang.org/x/mobile/bind/testdata/testpkg" , "" },
26
- {"Java-Testpkg" , "java" , "golang.org/x/mobile/bind/testdata/testpkg" , "" },
27
- {"Go-Testpkg" , "go" , "golang.org/x/mobile/bind/testdata/testpkg" , "" },
28
- {"Java-Javapkg" , "java" , "golang.org/x/mobile/bind/testdata/testpkg/javapkg" , "android" },
29
- {"Go-Javapkg" , "go" , "golang.org/x/mobile/bind/testdata/testpkg/javapkg" , "android" },
30
- {"Go-Javapkg" , "go,java,objc" , "golang.org/x/mobile/bind/testdata/cgopkg" , "android" },
28
+ {"ObjC-Testpkg" , "objc" , "golang.org/x/mobile/bind/testdata/testpkg" , "" , false },
29
+ {"Java-Testpkg" , "java" , "golang.org/x/mobile/bind/testdata/testpkg" , "" , false },
30
+ {"Go-Testpkg" , "go" , "golang.org/x/mobile/bind/testdata/testpkg" , "" , false },
31
+ {"Java-Javapkg" , "java" , "golang.org/x/mobile/bind/testdata/testpkg/javapkg" , "android" , true },
32
+ {"Go-Javapkg" , "go" , "golang.org/x/mobile/bind/testdata/testpkg/javapkg" , "android" , true },
33
+ {"Go-Javapkg" , "go,java,objc" , "golang.org/x/mobile/bind/testdata/cgopkg" , "android" , false },
31
34
}
32
35
33
36
var gobindBin string
@@ -68,8 +71,12 @@ func runGobind(t testing.TB, lang, pkg, goos string) error {
68
71
}
69
72
70
73
func TestGobind (t * testing.T ) {
74
+ _ , javapErr := exec .LookPath ("javap" )
71
75
for _ , test := range tests {
72
76
t .Run (test .name , func (t * testing.T ) {
77
+ if test .reverse && javapErr != nil {
78
+ t .Skip ("reverse bind test requires javap which is not available" )
79
+ }
73
80
if err := runGobind (t , test .lang , test .pkg , test .goos ); err != nil {
74
81
t .Error (err )
75
82
}
@@ -117,8 +124,12 @@ type Struct struct{
117
124
}
118
125
119
126
func BenchmarkGobind (b * testing.B ) {
127
+ _ , javapErr := exec .LookPath ("javap" )
120
128
for _ , test := range tests {
121
129
b .Run (test .name , func (b * testing.B ) {
130
+ if test .reverse && javapErr != nil {
131
+ b .Skip ("reverse bind test requires javap which is not available" )
132
+ }
122
133
for i := 0 ; i < b .N ; i ++ {
123
134
if err := runGobind (b , test .lang , test .pkg , test .goos ); err != nil {
124
135
b .Error (err )
0 commit comments