From 9b7eb80c576d87d909e4a1ab8fa22a5ffa989de1 Mon Sep 17 00:00:00 2001 From: David Crawshaw Date: Thu, 17 Sep 2015 11:27:57 -0400 Subject: [PATCH] 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 --- app/app_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 @@ func TestAndroidApp(t *testing.T) { 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")