fix: unittests

This commit is contained in:
debugtalk
2022-10-16 14:22:53 +08:00
parent 47020148a8
commit efbc89a8df
23 changed files with 21 additions and 1369 deletions

View File

@@ -3,9 +3,12 @@
package myexec
import (
"os"
"os/exec"
"path/filepath"
"syscall"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
)
@@ -48,7 +51,7 @@ func ensurePython3Venv(venvDir string, packages ...string) (python3 string, err
// check if .venv exists
if _, err := os.Stat(venvDir); err == nil {
// .venv exists, remove first
if err := ExecCommand("del", "/q", venvDir); err != nil {
if err := RunCommand("del", "/q", venvDir); err != nil {
return "", errors.Wrap(err, "remove existed venv failed")
}
}
@@ -56,10 +59,10 @@ func ensurePython3Venv(venvDir string, packages ...string) (python3 string, err
// create python3 .venv
// notice: --symlinks should be specified for windows
// https://github.com/actions/virtual-environments/issues/2690
if err := ExecCommand(systemPython, "-m", "venv", "--symlinks", venvDir); err != nil {
if err := RunCommand(systemPython, "-m", "venv", "--symlinks", venvDir); err != nil {
// fix: failed to symlink on Windows
log.Warn().Msg("failed to create python3 .venv by using --symlinks, try to use --copies")
if err := ExecCommand(systemPython, "-m", "venv", "--copies", venvDir); err != nil {
if err := RunCommand(systemPython, "-m", "venv", "--copies", venvDir); err != nil {
return "", errors.Wrap(err, "create python3 venv failed")
}
}

View File

@@ -1 +1 @@
v4.3.0-beta-10160931
v4.3.0-beta-10161439

View File

@@ -1,3 +1,5 @@
//go:build localtest
package demo
import (