From ee04fb570298f751e01ec40143f91871430778ad Mon Sep 17 00:00:00 2001 From: debugtalk Date: Fri, 11 Aug 2023 15:34:49 +0800 Subject: [PATCH] update hrp plugin (#1668) * change: upgrade go mod zerolog * change: relocate ocr_test * refactor: init logger * change: hrp exit log * change: update logs * change: upgrade funplugin to 0.5.2 * change: update change log --- docs/CHANGELOG.md | 3 +- examples/worldcup/cli.go | 28 --------------- go.mod | 26 +++++++------- go.sum | 58 ++++++++++++++---------------- hrp/build.go | 4 +-- hrp/cmd/boom.go | 6 ++-- hrp/cmd/build.go | 3 -- hrp/cmd/convert.go | 3 -- hrp/cmd/pytest.go | 9 ++--- hrp/cmd/root.go | 44 ++++++++++++++++------- hrp/cmd/run.go | 3 -- hrp/cmd/scaffold.go | 3 -- hrp/cmd/wiki.go | 3 -- hrp/internal/code/code.go | 5 +-- hrp/parser.go | 6 ++-- hrp/pkg/uixt/android_adb_driver.go | 2 +- hrp/pkg/uixt/ocr_test.go | 18 ---------- hrp/pkg/uixt/opencv.go | 6 ++-- hrp/pkg/uixt/service_vedem.go | 12 +++---- hrp/pkg/uixt/service_vedem_test.go | 11 ++++++ hrp/plugin.go | 2 +- hrp/runner.go | 2 ++ 22 files changed, 113 insertions(+), 144 deletions(-) delete mode 100644 hrp/pkg/uixt/ocr_test.go diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index c6e4f3d9..371757c2 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## v4.3.6-beta (2023-08-01) +## v4.3.6-beta (2023-08-11) - feat: support to reset driver (or session only) automatically when UIA2 / WDA crashed or WebDriver request failed - feat: `tap_cv` action supports ui type detection and tap @@ -9,6 +9,7 @@ - fix: add default options for `swipe_to_tap_app` action - refactor: ui validation methods - fix: reuse the same request body during `GetImage` retry +- change: upgrade funplugin to 0.5.2 ## v4.3.5 (2023-07-23) diff --git a/examples/worldcup/cli.go b/examples/worldcup/cli.go index f28eed1d..0950f63d 100644 --- a/examples/worldcup/cli.go +++ b/examples/worldcup/cli.go @@ -3,9 +3,7 @@ package main import ( "errors" "os" - "strings" - "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/spf13/cobra" @@ -16,13 +14,6 @@ var rootCmd = &cobra.Command{ Use: "wcl", Short: "Monitor FIFA World Cup Live", Version: "2022.12.03.0018", - PreRun: func(cmd *cobra.Command, args []string) { - log.Logger = zerolog.New( - zerolog.ConsoleWriter{NoColor: false, Out: os.Stderr}, - ).With().Timestamp().Logger() - zerolog.SetGlobalLevel(zerolog.InfoLevel) - setLogLevel(logLevel) - }, RunE: func(cmd *cobra.Command, args []string) error { var device uixt.Device var bundleID string @@ -78,22 +69,3 @@ func main() { os.Exit(1) } } - -func setLogLevel(level string) { - level = strings.ToUpper(level) - log.Info().Str("level", level).Msg("Set log level") - switch level { - case "DEBUG": - zerolog.SetGlobalLevel(zerolog.DebugLevel) - case "INFO": - zerolog.SetGlobalLevel(zerolog.InfoLevel) - case "WARN": - zerolog.SetGlobalLevel(zerolog.WarnLevel) - case "ERROR": - zerolog.SetGlobalLevel(zerolog.ErrorLevel) - case "FATAL": - zerolog.SetGlobalLevel(zerolog.FatalLevel) - case "PANIC": - zerolog.SetGlobalLevel(zerolog.PanicLevel) - } -} diff --git a/go.mod b/go.mod index 00d52c6b..6eab55e0 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/go-openapi/spec v0.20.7 github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/gorilla/websocket v1.5.0 - github.com/httprunner/funplugin v0.5.1 + github.com/httprunner/funplugin v0.5.2 github.com/jinzhu/copier v0.3.5 github.com/jmespath/go-jmespath v0.4.0 github.com/json-iterator/go v1.1.12 @@ -20,22 +20,22 @@ require ( github.com/olekukonko/tablewriter v0.0.5 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.13.0 - github.com/rs/zerolog v1.29.1 + github.com/rs/zerolog v1.30.0 github.com/satori/go.uuid v1.2.0 github.com/shirou/gopsutil v3.21.11+incompatible github.com/spf13/cobra v1.5.0 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 gocv.io/x/gocv v0.32.1 - golang.org/x/net v0.9.0 - golang.org/x/oauth2 v0.6.0 - google.golang.org/grpc v1.54.0 - google.golang.org/protobuf v1.30.0 + golang.org/x/net v0.14.0 + golang.org/x/oauth2 v0.8.0 + google.golang.org/grpc v1.57.0 + google.golang.org/protobuf v1.31.0 gopkg.in/yaml.v3 v3.0.1 howett.net/plist v1.0.0 ) require ( - cloud.google.com/go/compute v1.19.0 // indirect + cloud.google.com/go/compute v1.20.1 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect @@ -48,14 +48,14 @@ require ( github.com/go-openapi/swag v0.22.3 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/hashicorp/go-hclog v1.5.0 // indirect - github.com/hashicorp/go-plugin v1.4.9 // indirect + github.com/hashicorp/go-plugin v1.4.10 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/inconshreveable/mousetrap v1.0.1 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.18 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect github.com/mattn/go-runewidth v0.0.14 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect @@ -73,10 +73,10 @@ require ( github.com/tklauser/go-sysconf v0.3.10 // indirect github.com/tklauser/numcpus v0.5.0 // indirect github.com/yusufpapurcu/wmi v1.2.2 // indirect - golang.org/x/sys v0.7.0 // indirect - golang.org/x/text v0.9.0 // indirect + golang.org/x/sys v0.11.0 // indirect + golang.org/x/text v0.12.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index c98c671d..026836fa 100644 --- a/go.sum +++ b/go.sum @@ -19,8 +19,8 @@ cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvf cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/compute v1.19.0 h1:+9zda3WGgW1ZSTlVppLCYFIr48Pa35q1uG2N1itbCEQ= -cloud.google.com/go/compute v1.19.0/go.mod h1:rikpw2y+UMidAe9tISo04EHNOIf42RLYF/q8Bs93scU= +cloud.google.com/go/compute v1.20.1 h1:6aKEtlUiwEpJzM001l0yFkpXmUVXaN8W+fbkb2AZNbg= +cloud.google.com/go/compute v1.20.1/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= @@ -165,14 +165,14 @@ github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWm github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= -github.com/hashicorp/go-plugin v1.4.9 h1:ESiK220/qE0aGxWdzKIvRH69iLiuN/PjoLTm69RoWtU= -github.com/hashicorp/go-plugin v1.4.9/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= +github.com/hashicorp/go-plugin v1.4.10 h1:xUbmA4jC6Dq163/fWcp8P3JuHilrHHMLNRxzGQJ9hNk= +github.com/hashicorp/go-plugin v1.4.10/go.mod h1:6/1TEzT0eQznvI/gV2CM29DLSkAK/e58mUWKVsPaph0= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= -github.com/httprunner/funplugin v0.5.1 h1:7CbdN0jfSn8GOWgdxiHqqModIZ6pintqVZwPRw9Koww= -github.com/httprunner/funplugin v0.5.1/go.mod h1:o6l442jWROJgQytrEa9E/PgmL2uKA8c2AWeaYH4wSkg= +github.com/httprunner/funplugin v0.5.2 h1:VgDkHXNEo55KRgNZz+1oW8JboSNpfufNOfPD7l0LGyI= +github.com/httprunner/funplugin v0.5.2/go.mod h1:YZzBBSOSdLZEpHZz0P2E5SOQ+o1+Fbn30oWS4RGHBz0= github.com/hybridgroup/mjpeg v0.0.0-20140228234708-4680f319790e/go.mod h1:eagM805MRKrioHYuU7iKLUyFPVKqVV6um5DAvCkUtXs= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= @@ -225,8 +225,8 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= -github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= @@ -290,9 +290,9 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= -github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= +github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= @@ -308,18 +308,14 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw= github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= @@ -404,8 +400,8 @@ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= -golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -413,8 +409,8 @@ golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.6.0 h1:Lh8GPgSKBfWSwFvtuWOfeI3aAAnbXTSutYxJiOJFgIw= -golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= +golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8= +golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -470,8 +466,8 @@ golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -481,8 +477,8 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -583,8 +579,8 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 h1:wukfNtZmZUurLN/atp2hiIeTKn7QJWIQdHzqmsOnAOk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -597,8 +593,8 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag= -google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= +google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= +google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -611,8 +607,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/hrp/build.go b/hrp/build.go index c11a0073..0eaa2922 100644 --- a/hrp/build.go +++ b/hrp/build.go @@ -10,7 +10,7 @@ import ( "regexp" "strings" - "github.com/httprunner/funplugin/shared" + "github.com/httprunner/funplugin/fungo" "github.com/pkg/errors" "github.com/rs/zerolog/log" @@ -142,7 +142,7 @@ func (pt *pluginTemplate) generateGo(output string) error { // download plugin dependency // funplugin version should be locked - funplugin := fmt.Sprintf("github.com/httprunner/funplugin@%s", shared.Version) + funplugin := fmt.Sprintf("github.com/httprunner/funplugin@%s", fungo.Version) if err := myexec.ExecCommandInDir(myexec.Command("go", "get", funplugin), pluginDir); err != nil { return errors.Wrap(err, "go get funplugin failed") } diff --git a/hrp/cmd/boom.go b/hrp/cmd/boom.go index b2447ebe..6ef66506 100644 --- a/hrp/cmd/boom.go +++ b/hrp/cmd/boom.go @@ -4,6 +4,7 @@ import ( "strings" "time" + "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/spf13/cobra" "golang.org/x/net/context" @@ -26,9 +27,10 @@ var boomCmd = &cobra.Command{ PreRun: func(cmd *cobra.Command, args []string) { boomer.SetUlimit(10240) // ulimit -n 10240 if !strings.EqualFold(logLevel, "DEBUG") { - logLevel = "WARN" // disable info logs for load testing + // disable info logs for load testing + log.Info().Msg("Set global log level to WARN for load testing") + zerolog.SetGlobalLevel(zerolog.WarnLevel) } - setLogLevel(logLevel) }, RunE: func(cmd *cobra.Command, args []string) (err error) { startTime := time.Now() diff --git a/hrp/cmd/build.go b/hrp/cmd/build.go index 7e022177..59eb281f 100644 --- a/hrp/cmd/build.go +++ b/hrp/cmd/build.go @@ -17,9 +17,6 @@ var buildCmd = &cobra.Command{ Example: ` $ hrp build plugin/debugtalk.go $ hrp build plugin/debugtalk.py`, Args: cobra.ExactArgs(1), - PreRun: func(cmd *cobra.Command, args []string) { - setLogLevel(logLevel) - }, RunE: func(cmd *cobra.Command, args []string) (err error) { startTime := time.Now() defer func() { diff --git a/hrp/cmd/convert.go b/hrp/cmd/convert.go index 203896f5..bc7752d8 100644 --- a/hrp/cmd/convert.go +++ b/hrp/cmd/convert.go @@ -19,9 +19,6 @@ var convertCmd = &cobra.Command{ Short: "convert multiple source format to HttpRunner JSON/YAML/gotest/pytest cases", Args: cobra.MinimumNArgs(1), SilenceUsage: false, - PreRun: func(cmd *cobra.Command, args []string) { - setLogLevel(logLevel) - }, RunE: func(cmd *cobra.Command, args []string) error { caseConverter := convert.NewConverter(outputDir, profilePath) diff --git a/hrp/cmd/pytest.go b/hrp/cmd/pytest.go index 5687711e..9946f0ec 100644 --- a/hrp/cmd/pytest.go +++ b/hrp/cmd/pytest.go @@ -15,12 +15,9 @@ import ( ) var pytestCmd = &cobra.Command{ - Use: "pytest $path ...", - Short: "run API test with pytest", - Args: cobra.MinimumNArgs(1), - PreRun: func(cmd *cobra.Command, args []string) { - setLogLevel(logLevel) - }, + Use: "pytest $path ...", + Short: "run API test with pytest", + Args: cobra.MinimumNArgs(1), DisableFlagParsing: true, // allow to pass any args to pytest RunE: func(cmd *cobra.Command, args []string) (err error) { startTime := time.Now() diff --git a/hrp/cmd/root.go b/hrp/cmd/root.go index 2cc888e8..cf8c4e82 100644 --- a/hrp/cmd/root.go +++ b/hrp/cmd/root.go @@ -4,9 +4,11 @@ import ( "os" "runtime" "strings" + "time" "github.com/rs/zerolog" "github.com/rs/zerolog/log" + "github.com/rs/zerolog/pkgerrors" "github.com/spf13/cobra" "github.com/httprunner/httprunner/v4/hrp/cmd/adb" @@ -36,14 +38,7 @@ Website: https://httprunner.com Github: https://github.com/httprunner/httprunner Copyright 2017 debugtalk`, PersistentPreRun: func(cmd *cobra.Command, args []string) { - noColor := false - if runtime.GOOS == "windows" { - noColor = true - } - if !logJSON { - log.Logger = zerolog.New(zerolog.ConsoleWriter{NoColor: noColor, Out: os.Stderr}).With().Timestamp().Logger() - log.Info().Msg("Set log to color console") - } + initLogger(logLevel, logJSON) }, Version: version.VERSION, TraverseChildren: true, // parses flags on all parents before executing child command @@ -60,7 +55,7 @@ var ( // This is called by main.main(). It only needs to happen once to the rootCmd. func Execute() int { rootCmd.PersistentFlags().StringVarP(&logLevel, "log-level", "l", "INFO", "set log level") - rootCmd.PersistentFlags().BoolVar(&logJSON, "log-json", false, "set log to json format") + rootCmd.PersistentFlags().BoolVar(&logJSON, "log-json", false, "set log to json format (default colorized console)") rootCmd.PersistentFlags().StringVar(&venv, "venv", "", "specify python3 venv path") ios.Init(rootCmd) @@ -70,9 +65,34 @@ func Execute() int { return code.GetErrorCode(err) } -func setLogLevel(level string) { - level = strings.ToUpper(level) - log.Info().Str("level", level).Msg("Set log level") +func initLogger(logLevel string, logJSON bool) { + // Error Logging with Stacktrace + zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack + + if !logJSON { + // log a human-friendly, colorized output + noColor := false + if runtime.GOOS == "windows" { + noColor = true + } + + log.Logger = zerolog.New( + zerolog.ConsoleWriter{ + Out: os.Stderr, + TimeFormat: time.RFC3339, + NoColor: noColor, + }, + ).With().Timestamp().Logger() + log.Info().Msg("log with colorized console") + } else { + // default logger + log.Info().Msg("log with json output") + log.Logger = zerolog.New(os.Stderr).With().Timestamp().Logger() + } + + // Setting Global Log Level + level := strings.ToUpper(logLevel) + log.Info().Str("log_level", level).Msg("set global log level") switch level { case "DEBUG": zerolog.SetGlobalLevel(zerolog.DebugLevel) diff --git a/hrp/cmd/run.go b/hrp/cmd/run.go index f46f4efc..e042a5b7 100644 --- a/hrp/cmd/run.go +++ b/hrp/cmd/run.go @@ -15,9 +15,6 @@ var runCmd = &cobra.Command{ $ hrp run demo.yaml # run specified yaml testcase file $ hrp run examples/ # run testcases in specified folder`, Args: cobra.MinimumNArgs(1), - PreRun: func(cmd *cobra.Command, args []string) { - setLogLevel(logLevel) - }, RunE: func(cmd *cobra.Command, args []string) error { var paths []hrp.ITestCase for _, arg := range args { diff --git a/hrp/cmd/scaffold.go b/hrp/cmd/scaffold.go index b127b0ab..32c57c6c 100644 --- a/hrp/cmd/scaffold.go +++ b/hrp/cmd/scaffold.go @@ -14,9 +14,6 @@ var scaffoldCmd = &cobra.Command{ Aliases: []string{"scaffold"}, Short: "create a scaffold project", Args: cobra.ExactValidArgs(1), - PreRun: func(cmd *cobra.Command, args []string) { - setLogLevel(logLevel) - }, RunE: func(cmd *cobra.Command, args []string) error { if !ignorePlugin && !genPythonPlugin && !genGoPlugin { return errors.New("please specify function plugin type") diff --git a/hrp/cmd/wiki.go b/hrp/cmd/wiki.go index d7f29be1..478b1530 100644 --- a/hrp/cmd/wiki.go +++ b/hrp/cmd/wiki.go @@ -14,9 +14,6 @@ var wikiCmd = &cobra.Command{ Use: "wiki", Aliases: []string{"info", "docs", "doc"}, Short: "visit https://httprunner.com", - PreRun: func(cmd *cobra.Command, args []string) { - setLogLevel(logLevel) - }, RunE: func(cmd *cobra.Command, args []string) (err error) { startTime := time.Now() defer func() { diff --git a/hrp/internal/code/code.go b/hrp/internal/code/code.go index 0940eb9d..630f7fa9 100644 --- a/hrp/internal/code/code.go +++ b/hrp/internal/code/code.go @@ -1,8 +1,9 @@ package code import ( + "fmt" + "github.com/pkg/errors" - "github.com/rs/zerolog/log" ) // general: [0, 2) @@ -167,6 +168,6 @@ func GetErrorCode(err error) (errCode int) { errCode = GeneralFail } - log.Warn().Int("code", errCode).Msg("hrp exit") + fmt.Printf("hrp exit %d\n", errCode) return } diff --git a/hrp/parser.go b/hrp/parser.go index 211101fb..68394529 100644 --- a/hrp/parser.go +++ b/hrp/parser.go @@ -11,7 +11,7 @@ import ( "strings" "github.com/httprunner/funplugin" - "github.com/httprunner/funplugin/shared" + "github.com/httprunner/funplugin/fungo" "github.com/maja42/goval" "github.com/pkg/errors" "github.com/rs/zerolog/log" @@ -283,7 +283,7 @@ func (p *Parser) callFunc(funcName string, arguments ...interface{}) (interface{ if p.plugin.Has(funcName) { return p.plugin.Call(funcName, arguments...) } - commonName := shared.ConvertCommonName(funcName) + commonName := fungo.ConvertCommonName(funcName) if p.plugin.Has(commonName) { return p.plugin.Call(commonName, arguments...) } @@ -297,7 +297,7 @@ func (p *Parser) callFunc(funcName string, arguments ...interface{}) (interface{ fn := reflect.ValueOf(function) // call with builtin function - return shared.CallFunc(fn, arguments...) + return fungo.CallFunc(fn, arguments...) } // merge two variables mapping, the first variables have higher priority diff --git a/hrp/pkg/uixt/android_adb_driver.go b/hrp/pkg/uixt/android_adb_driver.go index ed91b407..4577c104 100644 --- a/hrp/pkg/uixt/android_adb_driver.go +++ b/hrp/pkg/uixt/android_adb_driver.go @@ -73,7 +73,7 @@ func (ad *adbDriver) WindowSize() (size Size, err error) { var resolution string sizeList := strings.Split(output, "\n") - log.Info().Msgf("window size: %v", sizeList) + log.Trace().Msgf("window size: %v", sizeList) for _, size := range sizeList { if strings.Contains(size, matchedSizeType) { resolution = strings.Split(size, ": ")[1] diff --git a/hrp/pkg/uixt/ocr_test.go b/hrp/pkg/uixt/ocr_test.go deleted file mode 100644 index da8ed745..00000000 --- a/hrp/pkg/uixt/ocr_test.go +++ /dev/null @@ -1,18 +0,0 @@ -//go:build ocr - -package uixt - -import ( - "testing" -) - -func TestDriverExtOCR(t *testing.T) { - driverExt, err := iosDevice.NewDriver(nil) - checkErr(t, err) - - point, err := driverExt.FindScreenText("抖音") - checkErr(t, err) - - t.Logf("point.X: %v, point.Y: %v", point.X, point.Y) - driverExt.Driver.TapFloat(point.X, point.Y-20) -} diff --git a/hrp/pkg/uixt/opencv.go b/hrp/pkg/uixt/opencv.go index 75c1d0ca..c72480df 100644 --- a/hrp/pkg/uixt/opencv.go +++ b/hrp/pkg/uixt/opencv.go @@ -8,11 +8,11 @@ import ( "image" "image/color" "io/ioutil" - "log" "math" "os" "github.com/pkg/errors" + "github.com/rs/zerolog/log" "gocv.io/x/gocv" "github.com/httprunner/httprunner/v4/hrp/internal/builtin" @@ -409,14 +409,14 @@ func getMatchingLocation(matImage gocv.Mat, matTpl gocv.Mat, threshold float32, val, loc = getValLoc(minVal, maxVal, minLoc, maxLoc, matchMode) if debug == DmEachMatch { - log.Println(fmt.Sprintf(dmOutputMsg, val, threshold)) + log.Debug().Msg(fmt.Sprintf(dmOutputMsg, val, threshold)) } if val >= threshold { return loc, nil } else { if debug == DmNotMatch { - log.Println(fmt.Sprintf(dmOutputMsg, val, threshold)) + log.Debug().Msg(fmt.Sprintf(dmOutputMsg, val, threshold)) } return image.Point{}, errors.New("no such target search image") } diff --git a/hrp/pkg/uixt/service_vedem.go b/hrp/pkg/uixt/service_vedem.go index b4d3ed41..3b2b36af 100644 --- a/hrp/pkg/uixt/service_vedem.go +++ b/hrp/pkg/uixt/service_vedem.go @@ -170,12 +170,12 @@ func newVEDEMImageService() (*veDEMImageService, error) { // veDEMImageService implements IImageService interface // actions: // -// ocr - get ocr texts -// upload - get image uploaded url -// liveType - get live type -// popup - get popup windows -// close - get close popup -// ui - get ui position by type(s) +// ocr - get ocr texts +// upload - get image uploaded url +// liveType - get live type +// popup - get popup windows +// close - get close popup +// ui - get ui position by type(s) type veDEMImageService struct{} type ( actionOptions []string diff --git a/hrp/pkg/uixt/service_vedem_test.go b/hrp/pkg/uixt/service_vedem_test.go index 1004855a..606fc3de 100644 --- a/hrp/pkg/uixt/service_vedem_test.go +++ b/hrp/pkg/uixt/service_vedem_test.go @@ -86,3 +86,14 @@ func TestTapUIWithScreenshot(t *testing.T) { t.Fatal(err) } } + +func TestDriverExtOCR(t *testing.T) { + driverExt, err := iosDevice.NewDriver(nil) + checkErr(t, err) + + point, err := driverExt.FindScreenText("抖音") + checkErr(t, err) + + t.Logf("point.X: %v, point.Y: %v", point.X, point.Y) + driverExt.Driver.TapFloat(point.X, point.Y-20) +} diff --git a/hrp/plugin.go b/hrp/plugin.go index 41b6d599..839d2d9f 100644 --- a/hrp/plugin.go +++ b/hrp/plugin.go @@ -53,7 +53,7 @@ func initPlugin(path, venv string, logOn bool) (plugin funplugin.IPlugin, err er return p.(funplugin.IPlugin), nil } - pluginOptions := []funplugin.Option{funplugin.WithLogOn(logOn)} + pluginOptions := []funplugin.Option{funplugin.WithDebugLogger(logOn)} if strings.HasSuffix(pluginPath, ".py") { // register funppy plugin diff --git a/hrp/runner.go b/hrp/runner.go index 6cf0031b..e393f043 100644 --- a/hrp/runner.go +++ b/hrp/runner.go @@ -429,6 +429,7 @@ func (r *CaseRunner) parseConfig() error { } iosDeviceConfig.UDID = udid.(string) } + device, err := uixt.NewIOSDevice(uixt.GetIOSDeviceOptions(iosDeviceConfig)...) if err != nil { return errors.Wrap(err, "init iOS device failed") @@ -447,6 +448,7 @@ func (r *CaseRunner) parseConfig() error { } androidDeviceConfig.SerialNumber = sn.(string) } + device, err := uixt.NewAndroidDevice(uixt.GetAndroidDeviceOptions(androidDeviceConfig)...) if err != nil { return errors.Wrap(err, "init Android device failed")