mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-13 04:30:41 +08:00
refactor: rename env package to config
This commit is contained in:
@@ -17,7 +17,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/sdk"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/version"
|
||||
)
|
||||
@@ -107,7 +107,7 @@ func (pt *pluginTemplate) generate(tmpl, output string) error {
|
||||
func (pt *pluginTemplate) generatePy(output string) error {
|
||||
// specify output file path
|
||||
if output == "" {
|
||||
output = filepath.Join(env.RootDir, PluginPySourceGenFile)
|
||||
output = filepath.Join(config.RootDir, PluginPySourceGenFile)
|
||||
} else if builtin.IsFolderPathExists(output) {
|
||||
output = filepath.Join(output, PluginPySourceGenFile)
|
||||
}
|
||||
@@ -155,7 +155,7 @@ func (pt *pluginTemplate) generateGo(output string) error {
|
||||
|
||||
// specify output file path
|
||||
if output == "" {
|
||||
output = filepath.Join(env.RootDir, PluginHashicorpGoBuiltFile)
|
||||
output = filepath.Join(config.RootDir, PluginHashicorpGoBuiltFile)
|
||||
} else if builtin.IsFolderPathExists(output) {
|
||||
output = filepath.Join(output, PluginHashicorpGoBuiltFile)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"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/sdk"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||
)
|
||||
@@ -51,7 +51,7 @@ var pcapCmd = &cobra.Command{
|
||||
log.Fatal().Err(err).Msg("failed to init ios device")
|
||||
}
|
||||
|
||||
err = builtin.EnsureFolderExists(env.ResultsPath)
|
||||
err = builtin.EnsureFolderExists(config.ResultsPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"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/sdk"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||
)
|
||||
@@ -58,7 +58,7 @@ var perfCmd = &cobra.Command{
|
||||
log.Fatal().Err(err).Msg("failed to init ios device")
|
||||
}
|
||||
|
||||
err = builtin.EnsureFolderExists(env.ResultsPath)
|
||||
err = builtin.EnsureFolderExists(config.ResultsPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package env
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/httprunner/httprunner/v4/hrp"
|
||||
"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/sdk"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/version"
|
||||
)
|
||||
@@ -96,10 +96,10 @@ func CreateScaffold(projectName string, pluginType PluginType, venv string, forc
|
||||
if err := builtin.CreateFolder(filepath.Join(projectName, "testcases")); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := builtin.CreateFolder(filepath.Join(projectName, env.ResultsDirName)); err != nil {
|
||||
if err := builtin.CreateFolder(filepath.Join(projectName, config.ResultsDirName)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := builtin.CreateFile(filepath.Join(projectName, env.ResultsDirName, ".keep"), ""); err != nil {
|
||||
if err := builtin.CreateFile(filepath.Join(projectName, config.ResultsDirName, ".keep"), ""); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
v5.0.0-beta-2410161532
|
||||
v5.0.0-beta-2410161536
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -12,7 +12,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/internal/sdk"
|
||||
)
|
||||
|
||||
@@ -185,5 +185,5 @@ func GetProjectRootDirPath(path string) (rootDir string, err error) {
|
||||
// failed to locate project root dir
|
||||
// maybe project plugin debugtalk.xx and proj.json are not exist
|
||||
// use current dir instead
|
||||
return env.RootDir, nil
|
||||
return config.RootDir, nil
|
||||
}
|
||||
|
||||
@@ -13,7 +13,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"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/version"
|
||||
)
|
||||
|
||||
@@ -27,7 +27,7 @@ func NewSummary() *Summary {
|
||||
Success: true,
|
||||
Stat: &Stat{},
|
||||
Time: &TestCaseTime{
|
||||
StartAt: env.StartTime,
|
||||
StartAt: config.StartTime,
|
||||
},
|
||||
Platform: platForm,
|
||||
}
|
||||
@@ -62,12 +62,12 @@ func (s *Summary) AddCaseSummary(caseSummary *TestCaseSummary) {
|
||||
s.rootDir = caseSummary.RootDir
|
||||
} else if s.rootDir != caseSummary.RootDir {
|
||||
// if multiple testcases have different root path, use current working dir
|
||||
s.rootDir = env.RootDir
|
||||
s.rootDir = config.RootDir
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Summary) GenHTMLReport() error {
|
||||
reportsDir := filepath.Join(s.rootDir, env.ResultsDir)
|
||||
reportsDir := filepath.Join(s.rootDir, config.ResultsDir)
|
||||
err := builtin.EnsureFolderExists(reportsDir)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -97,7 +97,7 @@ func (s *Summary) GenHTMLReport() error {
|
||||
}
|
||||
|
||||
func (s *Summary) GenSummary() (path string, err error) {
|
||||
reportsDir := filepath.Join(s.rootDir, env.ResultsDir)
|
||||
reportsDir := filepath.Join(s.rootDir, config.ResultsDir)
|
||||
err = builtin.EnsureFolderExists(reportsDir)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
Reference in New Issue
Block a user