mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-15 20:38:44 +08:00
refactor: get current dir
This commit is contained in:
@@ -3,7 +3,6 @@ package convert
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -13,6 +12,7 @@ import (
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/env"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/myexec"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||
)
|
||||
@@ -192,8 +192,7 @@ func (c *TCaseConverter) genOutputPath(suffix string) string {
|
||||
if c.OutputDir != "" {
|
||||
return filepath.Join(c.OutputDir, outFileFullName)
|
||||
} else {
|
||||
curWorkDir, _ := os.Getwd()
|
||||
return filepath.Join(curWorkDir, outFileFullName)
|
||||
return filepath.Join(env.RootDir, outFileFullName)
|
||||
}
|
||||
}
|
||||
outFileFullName = builtin.GetFileNameWithoutExtension(c.InputSample) + "_test" + suffix
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/env"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
@@ -234,6 +235,13 @@ func NewDriverExt(device Device, driver WebDriver) (dExt *DriverExt, err error)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// create results directory
|
||||
if err = builtin.EnsureFolderExists(env.ResultsPath); err != nil {
|
||||
return nil, errors.Wrap(err, "create results directory failed")
|
||||
}
|
||||
if err = builtin.EnsureFolderExists(env.ScreenShotsPath); err != nil {
|
||||
return nil, errors.Wrap(err, "create screenshots directory failed")
|
||||
}
|
||||
return dExt, nil
|
||||
}
|
||||
|
||||
@@ -291,11 +299,7 @@ func (dExt *DriverExt) ScreenShot(fileName string) (string, error) {
|
||||
return "", errors.Wrap(err, "screenshot failed")
|
||||
}
|
||||
|
||||
screenshotsDir := env.ScreenShotsPath
|
||||
if err = os.MkdirAll(screenshotsDir, os.ModePerm); err != nil {
|
||||
return "", errors.Wrap(err, "create screenshots directory failed")
|
||||
}
|
||||
fileName = filepath.Join(screenshotsDir, fileName)
|
||||
fileName = filepath.Join(env.ScreenShotsPath, fileName)
|
||||
path, err := saveScreenShot(raw, fileName)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "save screenshot failed")
|
||||
|
||||
Reference in New Issue
Block a user