Skip to content

Commit 2b10575

Browse files
xaionaro@dx.centerxaionaro@dx.center
authored andcommitted
fix: skip ADB-dependent tests when ADB server is unavailable
The interop/gadb tests require a running ADB server with a connected device. In CI (GitHub Actions) there is no ADB server, causing connection refused errors that fail the entire test suite. Add requireADB() helpers that skip tests gracefully when the ADB server is unreachable.
1 parent e6197db commit 2b10575

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

interop/gadb/proxy/proxy_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"testing"
66

7+
"github.com/electricbubble/gadb"
78
"github.com/stretchr/testify/assert"
89
"github.com/stretchr/testify/require"
910

@@ -14,7 +15,17 @@ import (
1415

1516
const testDeviceSerial = "41041JEKB08092"
1617

18+
// requireADB skips the test if the ADB server is not reachable.
19+
func requireADB(t *testing.T) {
20+
t.Helper()
21+
if _, err := gadb.NewClient(); err != nil {
22+
t.Skipf("ADB server not available: %v", err)
23+
}
24+
}
25+
1726
func TestSession(t *testing.T) {
27+
requireADB(t)
28+
1829
ctx := context.Background()
1930

2031
session, err := proxy.NewSession(ctx, testDeviceSerial)

interop/gadb/runner/runner_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,25 @@ import (
99
"testing"
1010
"time"
1111

12-
"github.com/AndroidGoLab/binder/interop/gadb/runner"
12+
"github.com/electricbubble/gadb"
1313
"github.com/stretchr/testify/assert"
1414
"github.com/stretchr/testify/require"
15+
16+
"github.com/AndroidGoLab/binder/interop/gadb/runner"
1517
)
1618

1719
const testDeviceSerial = "41041JEKB08092"
1820

21+
// requireADB skips the test if the ADB server is not reachable.
22+
func requireADB(t *testing.T) {
23+
t.Helper()
24+
if _, err := gadb.NewClient(); err != nil {
25+
t.Skipf("ADB server not available: %v", err)
26+
}
27+
}
28+
1929
func TestDiscoverDevices(t *testing.T) {
30+
requireADB(t)
2031
ctx := context.Background()
2132

2233
devices, err := runner.DiscoverDevices(ctx)
@@ -35,6 +46,8 @@ func TestDiscoverDevices(t *testing.T) {
3546
}
3647

3748
func TestPushAndRun(t *testing.T) {
49+
requireADB(t)
50+
3851
ctx := context.Background()
3952

4053
// Cross-compile examples/list_services for arm64.
@@ -68,6 +81,8 @@ func TestPushAndRun(t *testing.T) {
6881
}
6982

7083
func TestRunWithTimeout(t *testing.T) {
84+
requireADB(t)
85+
7186
ctx := context.Background()
7287

7388
dr, err := runner.NewDeviceRunner(testDeviceSerial)

0 commit comments

Comments
 (0)