feat: add pytest sub-command to run pytest scripts

This commit is contained in:
debugtalk
2022-04-09 00:08:18 +08:00
parent ce3afd871a
commit 318e1173a2
6 changed files with 56 additions and 6 deletions
+23
View File
@@ -0,0 +1,23 @@
package pytest
import (
"os/exec"
"strings"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
)
func RunPytest(args []string) error {
cmd := exec.Command("pytest", args...)
log.Info().Str("cmd", cmd.String()).Msg("run pytest")
output, err := cmd.CombinedOutput()
if err != nil {
return errors.Wrap(err, "pytest running failed")
}
out := strings.TrimSpace(string(output))
println(out)
return nil
}