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:
parent
ef84e0538a
commit
9b7eb80c57
@ -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")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user