refactor: rename env package to config

This commit is contained in:
lilong.129
2024-10-16 15:36:37 +08:00
parent a4236eea39
commit f9044eabe3
13 changed files with 33 additions and 33 deletions

View File

@@ -19,7 +19,7 @@ import (
"github.com/rs/zerolog/log"
"github.com/httprunner/httprunner/v4/hrp/code"
"github.com/httprunner/httprunner/v4/hrp/internal/env"
"github.com/httprunner/httprunner/v4/hrp/internal/config"
"github.com/httprunner/httprunner/v4/hrp/pkg/gadb"
"github.com/httprunner/httprunner/v4/hrp/pkg/utf7"
)
@@ -699,10 +699,10 @@ func (ad *adbDriver) StopCaptureLog() (result interface{}, err error) {
// 没有解析到打点日志,走兜底逻辑
if len(pointRes) == 0 {
log.Info().Msg("action log is null, use action file >>>")
logFilePathPrefix := fmt.Sprintf("%v/data", env.ActionLogFilePath)
logFilePathPrefix := fmt.Sprintf("%v/data", config.ActionLogFilePath)
files := []string{}
myexec.RunCommand("adb", "-s", ad.adbClient.Serial(), "pull", env.DeviceActionLogFilePath, env.ActionLogFilePath)
err = filepath.Walk(env.ActionLogFilePath, func(path string, info fs.FileInfo, err error) error {
myexec.RunCommand("adb", "-s", ad.adbClient.Serial(), "pull", config.DeviceActionLogFilePath, config.ActionLogFilePath)
err = filepath.Walk(config.ActionLogFilePath, func(path string, info fs.FileInfo, err error) error {
// 只是需要日志文件
if ok := strings.Contains(path, logFilePathPrefix); ok {
files = append(files, path)

View File

@@ -23,7 +23,7 @@ import (
"github.com/httprunner/httprunner/v4/hrp/code"
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
"github.com/httprunner/httprunner/v4/hrp/internal/env"
"github.com/httprunner/httprunner/v4/hrp/internal/config"
"github.com/httprunner/httprunner/v4/hrp/internal/json"
"github.com/httprunner/httprunner/v4/hrp/pkg/gadb"
)
@@ -195,7 +195,7 @@ type AndroidDevice struct {
func (dev *AndroidDevice) Init() error {
dev.d.RunShellCommand("ime", "enable", "io.appium.settings/.UnicodeIME")
dev.d.RunShellCommand("rm", "-r", env.DeviceActionLogFilePath)
dev.d.RunShellCommand("rm", "-r", config.DeviceActionLogFilePath)
if dev.UIA2 {
// uiautomator2 server must be started before

View File

@@ -10,7 +10,7 @@ import (
"github.com/rs/zerolog/log"
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
"github.com/httprunner/httprunner/v4/hrp/internal/env"
"github.com/httprunner/httprunner/v4/hrp/internal/config"
)
type DriverExt struct {
@@ -42,10 +42,10 @@ func newDriverExt(device IDevice, driver IWebDriver, options ...DriverOption) (d
}
if driverOptions.withResultFolder {
// create results directory
if err = builtin.EnsureFolderExists(env.ResultsPath); err != nil {
if err = builtin.EnsureFolderExists(config.ResultsPath); err != nil {
return nil, errors.Wrap(err, "create results directory failed")
}
if err = builtin.EnsureFolderExists(env.ScreenShotsPath); err != nil {
if err = builtin.EnsureFolderExists(config.ScreenShotsPath); err != nil {
return nil, errors.Wrap(err, "create screenshots directory failed")
}
}

View File

@@ -19,7 +19,7 @@ import (
"github.com/httprunner/httprunner/v4/hrp/code"
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
"github.com/httprunner/httprunner/v4/hrp/internal/env"
"github.com/httprunner/httprunner/v4/hrp/internal/config"
"github.com/httprunner/httprunner/v4/hrp/pkg/gidevice"
)
@@ -383,7 +383,7 @@ func (dev *IOSDevice) StartPerf() error {
return err
}
dev.perfFile = filepath.Join(env.ResultsPath, "perf.data")
dev.perfFile = filepath.Join(config.ResultsPath, "perf.data")
file, err := os.OpenFile(dev.perfFile,
os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0o755)
if err != nil {
@@ -428,7 +428,7 @@ func (dev *IOSDevice) StartPcap() error {
return err
}
dev.pcapFile = filepath.Join(env.ResultsPath, "dump.pcap")
dev.pcapFile = filepath.Join(config.ResultsPath, "dump.pcap")
file, err := os.OpenFile(dev.pcapFile,
os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0o755)
if err != nil {

View File

@@ -16,7 +16,7 @@ import (
"github.com/httprunner/httprunner/v4/hrp/code"
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
"github.com/httprunner/httprunner/v4/hrp/internal/env"
"github.com/httprunner/httprunner/v4/hrp/internal/config"
)
type ScreenResult struct {
@@ -181,7 +181,7 @@ func (dExt *DriverExt) GetScreenShot(fileName string) (raw *bytes.Buffer, path s
}
// save screenshot to file
path = filepath.Join(env.ScreenShotsPath, fileName)
path = filepath.Join(config.ScreenShotsPath, fileName)
path, err = saveScreenShot(raw, path)
if err != nil {
log.Error().Err(err).Msg("save screenshot file failed")