change: exit with InvalidPython3Venv code

This commit is contained in:
lilong.129
2023-08-20 13:21:39 +08:00
parent 00396d4b75
commit 226fb64a73
4 changed files with 9 additions and 4 deletions

View File

@@ -6,10 +6,12 @@ import (
"path/filepath"
"github.com/httprunner/funplugin/myexec"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
"github.com/httprunner/httprunner/v4/hrp/internal/code"
"github.com/httprunner/httprunner/v4/hrp/internal/version"
"github.com/httprunner/httprunner/v4/hrp/pkg/convert"
)
@@ -46,7 +48,7 @@ var convertCmd = &cobra.Command{
_, err := myexec.EnsurePython3Venv(venv, packages...)
if err != nil {
log.Error().Err(err).Msg("python3 venv is not ready")
return err
return errors.Wrap(code.InvalidPython3Venv, err.Error())
}
outputType = convert.OutputTypePyTest

View File

@@ -6,9 +6,11 @@ import (
"time"
"github.com/httprunner/funplugin/myexec"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/httprunner/httprunner/v4/hrp/internal/code"
"github.com/httprunner/httprunner/v4/hrp/internal/pytest"
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
"github.com/httprunner/httprunner/v4/hrp/internal/version"
@@ -35,7 +37,7 @@ var pytestCmd = &cobra.Command{
_, err = myexec.EnsurePython3Venv(venv, packages...)
if err != nil {
log.Error().Err(err).Msg("python3 venv is not ready")
return err
return errors.Wrap(code.InvalidPython3Venv, err.Error())
}
return pytest.RunPytest(args)
},

View File

@@ -14,6 +14,7 @@ import (
"github.com/httprunner/httprunner/v4/hrp"
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
"github.com/httprunner/httprunner/v4/hrp/internal/code"
"github.com/httprunner/httprunner/v4/hrp/internal/env"
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
"github.com/httprunner/httprunner/v4/hrp/internal/version"
@@ -216,7 +217,7 @@ func createPythonPlugin(projectName, venv string) error {
}
_, err = myexec.EnsurePython3Venv(venv, packages...)
if err != nil {
return err
return errors.Wrap(code.InvalidPython3Venv, err.Error())
}
return nil

View File

@@ -73,7 +73,7 @@ func initPlugin(path, venv string, logOn bool) (plugin funplugin.IPlugin, err er
log.Error().Err(err).
Interface("packages", packages).
Msg("python3 venv is not ready")
return nil, err
return nil, errors.Wrap(code.InvalidPython3Venv, err.Error())
}
pluginOptions = append(pluginOptions, funplugin.WithPython3(python3))
}