electricbubble / gidevice

communicate with iOS devices implemented with Golang
MIT License
274 stars 68 forks source link

XCTest multiple-start fail #23

Closed ZhouYixun closed 2 years ago

ZhouYixun commented 2 years ago

多次重复启动wda会造成失败 详见https://github.com/SonicCloudOrg/sonic-ios-bridge/issues/21 我cli多了自动挂载镜像处理,我这边debug了应该不是cli问题 请问有想法吗? 我启动wda的gofile https://github.com/SonicCloudOrg/sonic-ios-bridge/blob/main/cmd/wda.go

electricbubble commented 2 years ago

我这边的设备无法复现问题

func TestIssues23(t *testing.T) {
    for i := 0; i < 500; i++ {
        t.Run(fmt.Sprintf("[%3d] issues 23", i), Test_device_InstallationProxyLookup)
    }
}

func Test_device_InstallationProxyLookup(t *testing.T) {
    um, err := NewUsbmux()
    if err != nil {
        t.Fatal(err)
    }
    devices, err := um.Devices()
    if err != nil {
        t.Fatal(err)
    }

    if len(devices) == 0 {
        t.Fatal("No Device")
    }

    dev := devices[0]
    bundleID := "com.leixipaopao.WebDriverAgentRunner.xctrunner"

    lookupResult, err := dev.InstallationProxyLookup(WithBundleIDs(bundleID))
    if err != nil {
        t.Fatal(err)
    }

    if lookupResult == nil {
        t.Fatal("caught you: lookupResult")
    }

    ret := lookupResult.(map[string]interface{})

    if ret == nil {
        t.Fatal("caught you: lookupResult.(map[string]interface{})")
    }

    if ret[bundleID] == nil {
        t.Fatal("caught you: ret[bundleID]")
    }
}
ZhouYixun commented 2 years ago

好的,我这边检查下我的代码,感谢解答