mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-02 14:29:44 +08:00
feat: 新增监听安装
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -474,7 +475,15 @@ func (dev *IOSDevice) StopPcap() string {
|
||||
|
||||
func (dev *IOSDevice) Install(appPath string, opts *InstallOptions) (err error) {
|
||||
for i := 0; i <= opts.RetryTime; i++ {
|
||||
err = builtin.RunCommand("ideviceinstaller", "-u", dev.UDID, "-i", appPath)
|
||||
err = builtin.RunCommandWithCallback("ideviceinstaller", []string{"-u", dev.UDID, "-i", appPath}, func(line string) bool {
|
||||
if strings.Contains(line, "Complete") {
|
||||
return true
|
||||
}
|
||||
if strings.Contains(line, "90%") {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -483,7 +492,15 @@ func (dev *IOSDevice) Install(appPath string, opts *InstallOptions) (err error)
|
||||
}
|
||||
|
||||
func (dev *IOSDevice) Uninstall(bundleId string) error {
|
||||
return builtin.RunCommand("ideviceinstaller", "-u", dev.UDID, "-U", bundleId)
|
||||
return builtin.RunCommandWithCallback("ideviceinstaller", []string{"-u", dev.UDID, "-U", bundleId}, func(line string) bool {
|
||||
if strings.Contains(line, "Complete") {
|
||||
return true
|
||||
}
|
||||
if strings.Contains(line, "90%") {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
func (dev *IOSDevice) forward(localPort, remotePort int) error {
|
||||
|
||||
@@ -7,6 +7,8 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -39,7 +41,8 @@ func TestViaUSB(t *testing.T) {
|
||||
|
||||
func TestInstall(t *testing.T) {
|
||||
setup(t)
|
||||
err := iOSDriverExt.Install("/Users/bytedance/workcode/httprunner/hrp/pkg/uixt/1722942152176906000", NewInstallOptions(WithRetryTime(5)))
|
||||
err := iOSDriverExt.Install("/Users/bytedance/Downloads/com.yueyou.cyreader_1387717110_7.54.20.ipa", NewInstallOptions(WithRetryTime(5)))
|
||||
log.Error().Err(err)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user