feat: support override with environment variable WDA_PORT, WDA_MJPEG_PORT

This commit is contained in:
debugtalk
2022-09-29 20:20:48 +08:00
parent 3cfa05f437
commit a248940c81
4 changed files with 26 additions and 3 deletions

View File

@@ -11,7 +11,9 @@ import (
"net"
"net/http"
"net/url"
"os"
"regexp"
"strconv"
"strings"
giDevice "github.com/electricbubble/gidevice"
@@ -46,6 +48,27 @@ func InitWDAClient(device *IOSDevice) (*DriverExt, error) {
if device.UDID != "" {
deviceOptions = append(deviceOptions, WithUDID(device.UDID))
}
wda_port := os.Getenv("WDA_PORT")
if wda_port != "" {
if port, err := strconv.Atoi(wda_port); err == nil {
log.Info().Str("WDA_PORT", wda_port).
Msg("override with environment variable")
device.Port = port
} else {
log.Error().Err(err).Msg("invalid WDA_PORT, ignored")
}
}
wda_mjpeg_port := os.Getenv("WDA_MJPEG_PORT")
if wda_mjpeg_port != "" {
if mjpeg_port, err := strconv.Atoi(wda_mjpeg_port); err == nil {
log.Info().Str("WDA_MJPEG_PORT", wda_mjpeg_port).
Msg("override with environment variable")
device.MjpegPort = mjpeg_port
} else {
log.Error().Err(err).Msg("invalid WDA_MJPEG_PORT, ignored")
}
}
if device.Port != 0 {
deviceOptions = append(deviceOptions, WithPort(device.Port))
}

View File

@@ -1 +1 @@
v4.3.0-beta-09291727
v4.3.0-beta-09292020

View File

@@ -1,4 +1,4 @@
__version__ = "v4.3.0-beta-09291727"
__version__ = "v4.3.0-beta-09292020"
__description__ = "One-stop solution for HTTP(S) testing."

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "httprunner"
version = "v4.3.0-beta-09291727"
version = "v4.3.0-beta-09292020"
description = "One-stop solution for HTTP(S) testing."
license = "Apache-2.0"
readme = "README.md"