2
0
mirror of synced 2025-02-20 13:38:20 +00:00

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>
This commit is contained in:
David Crawshaw 2015-09-17 11:27:57 -04:00
parent ef84e0538a
commit 9b7eb80c57

View File

@ -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")