mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-11 18:11:21 +08:00
Merge branch 'refactor-hrp-interface' into 'feat/yuhongzheng/harmony'
# Conflicts: # hrp/internal/version/VERSION
This commit is contained in:
@@ -24,7 +24,7 @@ var (
|
||||
LoadYAMLError = errors.New("load yaml error") // 12
|
||||
LoadEnvError = errors.New("load .env error") // 13
|
||||
LoadCSVError = errors.New("load csv error") // 14
|
||||
InvalidCaseFormat = errors.New("invalid case format") // 15
|
||||
InvalidCaseError = errors.New("invalid case error") // 15
|
||||
UnsupportedFileExtension = errors.New("unsupported file extension") // 16
|
||||
ReferencedFileNotFound = errors.New("referenced file not found") // 17
|
||||
InvalidPluginFile = errors.New("invalid plugin file") // 18
|
||||
@@ -64,6 +64,7 @@ var (
|
||||
DeviceConnectionError = errors.New("device general connection error") // 50
|
||||
DeviceHTTPDriverError = errors.New("device HTTP driver error") // 51
|
||||
DeviceUSBDriverError = errors.New("device USB driver error") // 52
|
||||
DeviceGetInfoError = errors.New("device get info error") // 60
|
||||
DeviceShellExecError = errors.New("device shell exec error") // 62
|
||||
DeviceOfflineError = errors.New("device offline") // 63
|
||||
DeviceScreenShotError = errors.New("device screenshot error") // 65
|
||||
@@ -121,7 +122,7 @@ var errorsMap = map[error]int{
|
||||
LoadYAMLError: 12,
|
||||
LoadEnvError: 13,
|
||||
LoadCSVError: 14,
|
||||
InvalidCaseFormat: 15,
|
||||
InvalidCaseError: 15,
|
||||
UnsupportedFileExtension: 16,
|
||||
ReferencedFileNotFound: 17,
|
||||
InvalidPluginFile: 18,
|
||||
@@ -153,6 +154,7 @@ var errorsMap = map[error]int{
|
||||
DeviceConnectionError: 50,
|
||||
DeviceHTTPDriverError: 51,
|
||||
DeviceUSBDriverError: 52,
|
||||
DeviceGetInfoError: 60,
|
||||
DeviceShellExecError: 62,
|
||||
DeviceOfflineError: 63,
|
||||
DeviceScreenShotError: 65,
|
||||
|
||||
@@ -1 +1 @@
|
||||
v4.6.6
|
||||
v5.0.0-beta-2409191642
|
||||
@@ -117,15 +117,17 @@ func (ad *adbDriver) WindowSize() (size Size, err error) {
|
||||
ad.windowSize = &size
|
||||
}
|
||||
|
||||
orientation, err := ad.Orientation()
|
||||
if err != nil {
|
||||
log.Warn().Err(err).Msgf("window size get orientation failed, use default orientation")
|
||||
orientation, err2 := ad.Orientation()
|
||||
if err2 != nil {
|
||||
orientation = OrientationPortrait
|
||||
log.Warn().Err(err2).Msgf(
|
||||
"get window orientation failed, use default %s", orientation)
|
||||
}
|
||||
if orientation != OrientationPortrait {
|
||||
size.Width, size.Height = size.Height, size.Width
|
||||
}
|
||||
return
|
||||
// Notice: do not return err if get window orientation failed
|
||||
return size, nil
|
||||
}
|
||||
|
||||
func (ad *adbDriver) Screen() (screen Screen, err error) {
|
||||
@@ -535,7 +537,7 @@ func (ad *adbDriver) Screenshot() (raw *bytes.Buffer, err error) {
|
||||
if err == nil {
|
||||
return bytes.NewBuffer(resp), nil
|
||||
}
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "adb screencap failed")
|
||||
}
|
||||
|
||||
func (ad *adbDriver) Source(srcOpt ...SourceOption) (source string, err error) {
|
||||
|
||||
@@ -42,14 +42,6 @@ func TestAndroidDevice_GetPackageInfo(t *testing.T) {
|
||||
t.Log(appInfo)
|
||||
}
|
||||
|
||||
func TestIOSDevice_GetPackageInfo(t *testing.T) {
|
||||
device, err := NewIOSDevice()
|
||||
checkErr(t, err)
|
||||
appInfo, err := device.GetPackageInfo("com.apple.Preferences")
|
||||
checkErr(t, err)
|
||||
t.Log(appInfo)
|
||||
}
|
||||
|
||||
func TestDriver_NewSession(t *testing.T) {
|
||||
driver, err := NewUIADriver(nil, uiaServerURL)
|
||||
if err != nil {
|
||||
|
||||
@@ -564,7 +564,7 @@ func (wd *wdaDriver) DragFloat(fromX, fromY, toX, toY float64, options ...Action
|
||||
// update data options in post data for extra WDA configurations
|
||||
actionOptions.updateData(data)
|
||||
// wda 43 version
|
||||
_, err = wd.httpPOST(data, "/session", wd.session.ID, "/wda/drag")
|
||||
_, err = wd.httpPOST(data, "/session", wd.session.ID, "/wda/dragfromtoforduration")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ func TestNewIOSDevice(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNewWDAHTTPDriver(t *testing.T) {
|
||||
device, _ := NewIOSDevice()
|
||||
device, _ := NewIOSDevice(WithWDAPort(8700), WithWDAMjpegPort(8800))
|
||||
var err error
|
||||
_, err = device.NewHTTPDriver(nil)
|
||||
if err != nil {
|
||||
@@ -85,6 +85,14 @@ func TestNewUSBDriver(t *testing.T) {
|
||||
// t.Log(driver.IsWdaHealthy())
|
||||
}
|
||||
|
||||
func TestIOSDevice_GetPackageInfo(t *testing.T) {
|
||||
device, err := NewIOSDevice(WithWDAPort(8700))
|
||||
checkErr(t, err)
|
||||
appInfo, err := device.GetPackageInfo("com.apple.Preferences")
|
||||
checkErr(t, err)
|
||||
t.Log(appInfo)
|
||||
}
|
||||
|
||||
func TestDriver_DeviceScaleRatio(t *testing.T) {
|
||||
setup(t)
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *S
|
||||
|
||||
windowSize, err = dExt.Driver.WindowSize()
|
||||
if err != nil {
|
||||
lastErr = errors.Wrap(code.MobileUIDriverError, err.Error())
|
||||
lastErr = errors.Wrap(code.DeviceGetInfoError, err.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -19,14 +19,14 @@ func assertRelative(p float64) bool {
|
||||
func (dExt *DriverExt) SwipeRelative(fromX, fromY, toX, toY float64, options ...ActionOption) error {
|
||||
if !assertRelative(fromX) || !assertRelative(fromY) ||
|
||||
!assertRelative(toX) || !assertRelative(toY) {
|
||||
return errors.Wrap(code.MobileUISwipeError,
|
||||
return errors.Wrap(code.InvalidCaseError,
|
||||
fmt.Sprintf("fromX(%f), fromY(%f), toX(%f), toY(%f) must be less than 1",
|
||||
fromX, fromY, toX, toY))
|
||||
}
|
||||
|
||||
windowSize, err := dExt.Driver.WindowSize()
|
||||
if err != nil {
|
||||
return errors.Wrap(code.MobileUISwipeError, err.Error())
|
||||
return errors.Wrap(code.DeviceGetInfoError, err.Error())
|
||||
}
|
||||
width := windowSize.Width
|
||||
height := windowSize.Height
|
||||
|
||||
@@ -32,7 +32,7 @@ func (path *TestCasePath) GetTestCase() (*TestCase, error) {
|
||||
return nil, err
|
||||
}
|
||||
if tc.Steps == nil {
|
||||
return nil, errors.Wrap(code.InvalidCaseFormat,
|
||||
return nil, errors.Wrap(code.InvalidCaseError,
|
||||
"invalid testcase format, missing teststeps!")
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ func (tc *TestCase) loadISteps() (*TestCase, error) {
|
||||
} else {
|
||||
apiMap, ok := step.API.(map[string]interface{})
|
||||
if !ok {
|
||||
return nil, errors.Wrap(code.InvalidCaseFormat,
|
||||
return nil, errors.Wrap(code.InvalidCaseError,
|
||||
fmt.Sprintf("referenced api should be map or path(string), got %v", step.API))
|
||||
}
|
||||
api := &API{}
|
||||
@@ -183,7 +183,7 @@ func (tc *TestCase) loadISteps() (*TestCase, error) {
|
||||
}
|
||||
_, ok = step.API.(*API)
|
||||
if !ok {
|
||||
return nil, errors.Wrap(code.InvalidCaseFormat,
|
||||
return nil, errors.Wrap(code.InvalidCaseError,
|
||||
fmt.Sprintf("failed to handle referenced API, got %v", step.TestCase))
|
||||
}
|
||||
testCase.TestSteps = append(testCase.TestSteps, &StepAPIWithOptionalArgs{
|
||||
@@ -207,7 +207,7 @@ func (tc *TestCase) loadISteps() (*TestCase, error) {
|
||||
} else {
|
||||
testCaseMap, ok := step.TestCase.(map[string]interface{})
|
||||
if !ok {
|
||||
return nil, errors.Wrap(code.InvalidCaseFormat,
|
||||
return nil, errors.Wrap(code.InvalidCaseError,
|
||||
fmt.Sprintf("referenced testcase should be map or path(string), got %v", step.TestCase))
|
||||
}
|
||||
tCase := &TestCase{}
|
||||
@@ -223,7 +223,7 @@ func (tc *TestCase) loadISteps() (*TestCase, error) {
|
||||
}
|
||||
_, ok = step.TestCase.(*TestCase)
|
||||
if !ok {
|
||||
return nil, errors.Wrap(code.InvalidCaseFormat,
|
||||
return nil, errors.Wrap(code.InvalidCaseError,
|
||||
fmt.Sprintf("failed to handle referenced testcase, got %v", step.TestCase))
|
||||
}
|
||||
testCase.TestSteps = append(testCase.TestSteps, &StepTestCaseWithOptionalArgs{
|
||||
@@ -309,7 +309,7 @@ func convertCompatValidator(Validators []interface{}) (err error) {
|
||||
validatorMap[strKey] = value
|
||||
}
|
||||
} else {
|
||||
return errors.Wrap(code.InvalidCaseFormat,
|
||||
return errors.Wrap(code.InvalidCaseError,
|
||||
fmt.Sprintf("unexpected validator format: %v", iValidator))
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ func convertCompatValidator(Validators []interface{}) (err error) {
|
||||
for assertMethod, iValidatorContent := range validatorMap {
|
||||
validatorContent := iValidatorContent.([]interface{})
|
||||
if len(validatorContent) > 3 {
|
||||
return errors.Wrap(code.InvalidCaseFormat,
|
||||
return errors.Wrap(code.InvalidCaseError,
|
||||
fmt.Sprintf("unexpected validator format: %v", validatorMap))
|
||||
}
|
||||
validator.Check = validatorContent[0].(string)
|
||||
@@ -349,7 +349,7 @@ func convertCompatValidator(Validators []interface{}) (err error) {
|
||||
Validators[i] = validator
|
||||
continue
|
||||
}
|
||||
return errors.Wrap(code.InvalidCaseFormat,
|
||||
return errors.Wrap(code.InvalidCaseError,
|
||||
fmt.Sprintf("unexpected validator format: %v", validatorMap))
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/bin/bash
|
||||
# build hrp cli binary for testing
|
||||
# release will be triggered on github actions, see .github/workflows/release.yml
|
||||
|
||||
# Usage:
|
||||
# $ make bump version=v4.3.0
|
||||
# or
|
||||
# $ bash scripts/bump_version.sh v4.3.0
|
||||
|
||||
set -e
|
||||
|
||||
version=$1
|
||||
|
||||
if [ -z "$version" ]; then
|
||||
echo "version is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $version != v* ]]; then
|
||||
version="v$version"
|
||||
fi
|
||||
|
||||
echo "bump hrp version to $version"
|
||||
echo -n "$version" > hrp/internal/version/VERSION
|
||||
|
||||
echo "bump httprunner version to $version"
|
||||
sed -i'.bak' "s/__version__ = \".*\"/__version__ = \"$version\"/g" httprunner/__init__.py
|
||||
|
||||
echo "bump pyproject.toml version to $version"
|
||||
sed -i'.bak' "s/^version = \".*\"/version = \"$version\"/g" pyproject.toml
|
||||
@@ -18,6 +18,7 @@ function install() {
|
||||
# 1. gofumpt go files automatically
|
||||
# 2. goimports-reviser go files automatically
|
||||
# 3. black python files automatically
|
||||
# 4. bump hrp version
|
||||
|
||||
# make sure gofumpt is installed
|
||||
# What does each letter mean in "ACMRTUXB"?
|
||||
@@ -38,6 +39,22 @@ do
|
||||
black "$file"
|
||||
git add "$file"
|
||||
done
|
||||
|
||||
# bump hrp version
|
||||
version_file=hrp/internal/version/VERSION
|
||||
|
||||
# get current date
|
||||
current_date=$(date +"%y%m%d%H%M")
|
||||
|
||||
# update version
|
||||
sed -i '' "s/[0-9]\{10\}/${current_date}/" "$version_file"
|
||||
|
||||
# add change to stage
|
||||
git add $version_file
|
||||
|
||||
# print updated version
|
||||
updated_version=$(cat "$version_file")
|
||||
echo "update hrp version to $updated_version"
|
||||
EOF
|
||||
|
||||
chmod +x $PRE_COMMIT_FILE
|
||||
|
||||
Reference in New Issue
Block a user