Skip to content

Commit d3739f8

Browse files
committed
cmd/gobind: fix tests on the linux-amd64-longtest builder
The builder doesn't have javap nor the Android fonts installed. Change-Id: Ia3965be967482aa76b0c8c83b951deb30ebe5645 Reviewed-on: https://go-review.googlesource.com/c/mobile/+/167057 Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
1 parent d2e1c1c commit d3739f8

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

cmd/gobind/gobind_test.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@ var tests = []struct {
2121
lang string
2222
pkg string
2323
goos string
24+
// reverse is true if the test needs to generate reverse bindings using
25+
// external tools such as javap.
26+
reverse bool
2427
}{
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},
3134
}
3235

3336
var gobindBin string
@@ -68,8 +71,12 @@ func runGobind(t testing.TB, lang, pkg, goos string) error {
6871
}
6972

7073
func TestGobind(t *testing.T) {
74+
_, javapErr := exec.LookPath("javap")
7175
for _, test := range tests {
7276
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+
}
7380
if err := runGobind(t, test.lang, test.pkg, test.goos); err != nil {
7481
t.Error(err)
7582
}
@@ -117,8 +124,12 @@ type Struct struct{
117124
}
118125

119126
func BenchmarkGobind(b *testing.B) {
127+
_, javapErr := exec.LookPath("javap")
120128
for _, test := range tests {
121129
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+
}
122133
for i := 0; i < b.N; i++ {
123134
if err := runGobind(b, test.lang, test.pkg, test.goos); err != nil {
124135
b.Error(err)

exp/font/font_test.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,22 @@ func looksLikeATTF(b []byte) error {
3636
return nil
3737
}
3838

39-
func TestLoadFonts(t *testing.T) {
40-
if err := looksLikeATTF(Default()); err != nil {
39+
func TestLoadDefault(t *testing.T) {
40+
def, err := buildDefault()
41+
if err != nil {
42+
t.Skip("default font not found")
43+
}
44+
if err := looksLikeATTF(def); err != nil {
4145
t.Errorf("default font: %v", err)
4246
}
43-
if err := looksLikeATTF(Monospace()); err != nil {
47+
}
48+
49+
func TestLoadMonospace(t *testing.T) {
50+
mono, err := buildMonospace()
51+
if err != nil {
52+
t.Skip("mono font not found")
53+
}
54+
if err := looksLikeATTF(mono); err != nil {
4455
t.Errorf("monospace font: %v", err)
4556
}
4657
}

0 commit comments

Comments
 (0)