app: skip android test if no device attached
Change-Id: Ie2c81af6cb380ae22d285d0f274755ec421e8d6a
Reviewed-on: https://go-review.googlesource.com/14653
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/app/app_test.go b/app/app_test.go
index dc222da..4ddfacd 100644
--- a/app/app_test.go
+++ b/app/app_test.go
@@ -31,6 +31,22 @@
if _, err := exec.Command("which", "adb").CombinedOutput(); err != nil {
t.Skip("command adb not found, skipping")
}
+ devicesTxt, err := exec.Command("adb", "devices").CombinedOutput()
+ if err != nil {
+ t.Errorf("adb devices failed: %v: %v", err, devicesTxt)
+ }
+ deviceCount := 0
+ for _, d := range strings.Split(strings.TrimSpace(string(devicesTxt)), "\n") {
+ if strings.Contains(d, "List of devices") {
+ continue
+ }
+ // TODO(crawshaw): I believe some unusable devices can appear in the
+ // list with note on them, but I cannot reproduce this right now.
+ deviceCount++
+ }
+ if deviceCount == 0 {
+ t.Skip("no android devices attached")
+ }
run(t, "gomobile", "version")