From ec508012a93d4dfebf462c13db67d0591535514f Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Sat, 23 Nov 2024 17:35:34 +0800 Subject: [PATCH] change: upgrade go-ios to v1.0.161 --- go.mod | 5 ++-- go.sum | 6 ++-- hrp/cmd/adb/install.go | 2 +- hrp/cmd/ios/install.go | 2 +- hrp/cmd/ios/uninstall.go | 2 +- hrp/cmd/ios/xctest.go | 13 ++++----- hrp/internal/version/VERSION | 2 +- hrp/pkg/uixt/ios_device.go | 55 +++++++++++++++--------------------- 8 files changed, 36 insertions(+), 51 deletions(-) diff --git a/go.mod b/go.mod index 5b15aec5..cbff37b3 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69 github.com/Masterminds/semver v1.5.0 github.com/andybalholm/brotli v1.0.4 - github.com/danielpaulus/go-ios v1.0.144 + github.com/danielpaulus/go-ios v1.0.161 github.com/denisbrodbeck/machineid v1.0.1 github.com/fatih/color v1.16.0 github.com/getsentry/sentry-go v0.13.0 @@ -21,7 +21,6 @@ require ( github.com/jinzhu/copier v0.3.5 github.com/jmespath/go-jmespath v0.4.0 github.com/json-iterator/go v1.1.12 - github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40 github.com/maja42/goval v1.2.1 github.com/mitchellh/mapstructure v1.5.0 github.com/olekukonko/tablewriter v0.0.5 @@ -39,7 +38,6 @@ require ( google.golang.org/protobuf v1.34.1 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 - howett.net/plist v1.0.0 ) require ( @@ -124,6 +122,7 @@ require ( google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac // indirect gvisor.dev/gvisor v0.0.0-20240405191320-0878b34101b5 // indirect + howett.net/plist v1.0.0 // indirect software.sslmate.com/src/go-pkcs12 v0.2.0 // indirect ) diff --git a/go.sum b/go.sum index 981a1da8..f4d92d21 100644 --- a/go.sum +++ b/go.sum @@ -78,8 +78,8 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/danielpaulus/go-ios v1.0.144 h1:gojkhtScKYMwC4YHKnoB7u910GmtArg5ugsfAk7W4wY= -github.com/danielpaulus/go-ios v1.0.144/go.mod h1:ZkUcaC59yNba47j/+ULKsCi3dYPFwY9r39PxdmVmLHE= +github.com/danielpaulus/go-ios v1.0.161 h1:HhQO/GqINde9Xrvge5ksHxLQk5hQmUAxE7CcS2bIc4A= +github.com/danielpaulus/go-ios v1.0.161/go.mod h1:ZkUcaC59yNba47j/+ULKsCi3dYPFwY9r39PxdmVmLHE= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -267,8 +267,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= -github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40 h1:EnfXoSqDfSNJv0VBNqY/88RNnhSGYkrHaO0mmFGbVsc= -github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40/go.mod h1:vy1vK6wD6j7xX6O6hXe621WabdtNkou2h7uRtTfRMyg= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= diff --git a/hrp/cmd/adb/install.go b/hrp/cmd/adb/install.go index caa87c2e..bcdaf898 100644 --- a/hrp/cmd/adb/install.go +++ b/hrp/cmd/adb/install.go @@ -19,7 +19,7 @@ var ( var installCmd = &cobra.Command{ Use: "install [flags] PACKAGE", - Short: "Push package to the device and install them atomically", + Short: "push package to the device and install them automatically", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { startTime := time.Now() diff --git a/hrp/cmd/ios/install.go b/hrp/cmd/ios/install.go index 1f60514c..6b564c16 100644 --- a/hrp/cmd/ios/install.go +++ b/hrp/cmd/ios/install.go @@ -13,7 +13,7 @@ import ( var installCmd = &cobra.Command{ Use: "install [flags] PACKAGE", - Short: "Push package to the device and install them atomically", + Short: "push package to the device and install them automatically", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { startTime := time.Now() diff --git a/hrp/cmd/ios/uninstall.go b/hrp/cmd/ios/uninstall.go index b93ed5f4..0f2ec87f 100644 --- a/hrp/cmd/ios/uninstall.go +++ b/hrp/cmd/ios/uninstall.go @@ -13,7 +13,7 @@ import ( var uninstallCmd = &cobra.Command{ Use: "uninstall [flags] PACKAGE", - Short: "uninstall Package atomically", + Short: "uninstall package automatically", Args: cobra.MinimumNArgs(0), RunE: func(cmd *cobra.Command, args []string) (err error) { startTime := time.Now() diff --git a/hrp/cmd/ios/xctest.go b/hrp/cmd/ios/xctest.go index 41c964e9..6c94b41a 100644 --- a/hrp/cmd/ios/xctest.go +++ b/hrp/cmd/ios/xctest.go @@ -1,12 +1,12 @@ package ios import ( + "context" "fmt" "strings" "time" "github.com/pkg/errors" - "github.com/rs/zerolog/log" "github.com/spf13/cobra" "github.com/httprunner/httprunner/v4/hrp/internal/sdk" @@ -33,8 +33,7 @@ var xctestCmd = &cobra.Command{ return err } - log.Info().Str("bundleID", bundleID).Msg("run xctest") - err = device.RunXCTest(bundleID, testRunnerBundleID, xctestConfig) + err = device.RunXCTest(context.Background(), bundleID, testRunnerBundleID, xctestConfig) if err != nil { return errors.Wrap(err, "run xctest failed") } @@ -49,9 +48,9 @@ var ( ) func init() { - xctestCmd.Flags().StringVarP(&udid, "udid", "u", "", "filter by device's udid") - xctestCmd.Flags().StringVarP(&bundleID, "bundleID", "b", "", "specify ios bundleID") - xctestCmd.Flags().StringVarP(&testRunnerBundleID, "testRunnerBundleID", "t", "", "specify ios testRunnerBundleID") - xctestCmd.Flags().StringVarP(&xctestConfig, "xctestConfig", "x", "", "specify ios xctestConfig") + xctestCmd.Flags().StringVarP(&udid, "udid", "u", "", "specify ios device's UDID") + xctestCmd.Flags().StringVarP(&bundleID, "bundleID", "b", "com.gtf.wda.runner.xctrunner", "specify ios bundleID") + xctestCmd.Flags().StringVarP(&testRunnerBundleID, "testRunnerBundleID", "t", "com.gtf.wda.runner.xctrunner", "specify ios testRunnerBundleID") + xctestCmd.Flags().StringVarP(&xctestConfig, "xctestConfig", "x", "GtfWdaRunner.xctest", "specify ios xctestConfig") iosRootCmd.AddCommand(xctestCmd) } diff --git a/hrp/internal/version/VERSION b/hrp/internal/version/VERSION index 6ecbcf35..aa5638c8 100644 --- a/hrp/internal/version/VERSION +++ b/hrp/internal/version/VERSION @@ -1 +1 @@ -v5.0.0+2411231513 +v5.0.0+2411232055 diff --git a/hrp/pkg/uixt/ios_device.go b/hrp/pkg/uixt/ios_device.go index b621b97c..eeecbae8 100644 --- a/hrp/pkg/uixt/ios_device.go +++ b/hrp/pkg/uixt/ios_device.go @@ -9,9 +9,7 @@ import ( "net/http" "net/url" "os" - "os/signal" "strconv" - "syscall" "time" "github.com/Masterminds/semver" @@ -349,7 +347,9 @@ func (dev *IOSDevice) Init() error { } if version.GreaterThan(semver.MustParse("17.4.0")) && dev.STUB { - info, err := tunnel.TunnelInfoForDevice(dev.d.Properties.SerialNumber, ios.HttpApiPort()) + info, err := tunnel.TunnelInfoForDevice( + dev.d.Properties.SerialNumber, + ios.HttpApiHost(), ios.HttpApiPort()) if err != nil { return err } @@ -654,38 +654,31 @@ func (dev *IOSDevice) AutoMountImage(basedir string) (err error) { return nil } -func (dev *IOSDevice) RunXCTest(bundleID, testRunnerBundleID, xctestConfig string) (err error) { - errorChannel := make(chan error) - defer close(errorChannel) - ctx, stopWda := context.WithCancel(context.Background()) - go func() { - _, err = testmanagerd.RunXCUIWithBundleIdsCtx(ctx, bundleID, testRunnerBundleID, xctestConfig, dev.d, []string{}, nil, nil, nil, testmanagerd.NewTestListener(io.Discard, os.Stderr, os.TempDir()), true) - if err != nil { - errorChannel <- err - } - stopWda() - }() - c := make(chan os.Signal, 1) - signal.Notify(c, syscall.SIGINT, syscall.SIGTERM) - select { - case err := <-errorChannel: - log.Error().Err(err).Msg("failed to running WDA") - stopWda() +func (dev *IOSDevice) RunXCTest(ctx context.Context, bundleID, testRunnerBundleID, xctestConfig string) (err error) { + log.Info().Str("bundleID", bundleID). + Str("testRunnerBundleID", testRunnerBundleID). + Str("xctestConfig", xctestConfig). + Msg("run xctest") + listener := testmanagerd.NewTestListener(io.Discard, io.Discard, os.TempDir()) + config := testmanagerd.TestConfig{ + BundleId: bundleID, + TestRunnerBundleId: testRunnerBundleID, + XctestConfigName: xctestConfig, + Device: dev.d, + Listener: listener, + } + _, err = testmanagerd.RunTestWithConfig(ctx, config) + if err != nil { + log.Error().Err(err).Msg("run xctest failed") return err - case <-ctx.Done(): - log.Error().Err(err).Msg("WDA process ended unexpectedly") - return err - case signal := <-c: - log.Info().Msg(fmt.Sprintf("os signal:%d received, closing...", signal)) - stopWda() } return nil } -func (dev *IOSDevice) RunXCTestDaemon(bundleID, testRunnerBundleID, xctestConfig string) { - ctx, stopWda := context.WithCancel(context.Background()) +func (dev *IOSDevice) RunXCTestDaemon(ctx context.Context, bundleID, testRunnerBundleID, xctestConfig string) { + ctx, stopWda := context.WithCancel(ctx) go func() { - _, err := testmanagerd.RunXCUIWithBundleIdsCtx(ctx, bundleID, testRunnerBundleID, xctestConfig, dev.d, []string{}, nil, nil, nil, testmanagerd.NewTestListener(io.Discard, os.Stderr, os.TempDir()), true) + err := dev.RunXCTest(ctx, bundleID, testRunnerBundleID, xctestConfig) if err != nil { log.Error().Err(err).Msg("wda ended") } @@ -702,10 +695,6 @@ func (dev *IOSDevice) getVersion() (version *semver.Version, err error) { return version, nil } -func (dev *IOSDevice) RunGTFDaemon() { - dev.RunXCTestDaemon("com.gtf.wda.runner.xctrunner", "com.gtf.wda.runner.xctrunner", "GtfWdaRunner.xctest") -} - func (dev *IOSDevice) ListProcess(applicationsOnly bool) (processList []instruments.ProcessInfo, err error) { service, err := instruments.NewDeviceInfoService(dev.d) if err != nil {