mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-04 23:39:33 +08:00
fix: failed to exec command line on windows
This commit is contained in:
@@ -69,6 +69,11 @@ func ensurePython3Venv(venv string, packages ...string) (python3 string, err err
|
|||||||
return python3, nil
|
return python3, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Command(name string, arg ...string) *exec.Cmd {
|
||||||
|
args := strings.Join(arg, " ")
|
||||||
|
return exec.Command("bash", "-c", name, args)
|
||||||
|
}
|
||||||
|
|
||||||
func ExecCommand(cmdName string, args ...string) error {
|
func ExecCommand(cmdName string, args ...string) error {
|
||||||
cmd := exec.Command(cmdName, args...)
|
cmd := exec.Command(cmdName, args...)
|
||||||
log.Info().Str("cmd", cmd.String()).Msg("exec command")
|
log.Info().Str("cmd", cmd.String()).Msg("exec command")
|
||||||
|
|||||||
@@ -100,6 +100,11 @@ func ensurePython3Venv(venvDir string, packages ...string) (python3 string, err
|
|||||||
return python3, nil
|
return python3, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Command(name string, arg ...string) *exec.Cmd {
|
||||||
|
args := strings.Join(arg, " ")
|
||||||
|
return exec.Command("cmd", "/c", name, args)
|
||||||
|
}
|
||||||
|
|
||||||
func ExecCommand(cmdName string, args ...string) error {
|
func ExecCommand(cmdName string, args ...string) error {
|
||||||
// "cmd /c" carries out the command specified by string and then stops
|
// "cmd /c" carries out the command specified by string and then stops
|
||||||
// refer: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/cmd
|
// refer: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/cmd
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/electricbubble/gadb"
|
"github.com/electricbubble/gadb"
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
@@ -260,8 +261,8 @@ func (l *DeviceLogcat) CatchLogcat() (err error) {
|
|||||||
if l.cmd != nil {
|
if l.cmd != nil {
|
||||||
err = fmt.Errorf("logcat already start")
|
err = fmt.Errorf("logcat already start")
|
||||||
}
|
}
|
||||||
command := fmt.Sprintf("adb -s %s logcat -c && adb -s %s logcat -v time -s iesqaMonitor:V", l.serial, l.serial)
|
cmdLine := fmt.Sprintf("adb -s %s logcat -c && adb -s %s logcat -v time -s iesqaMonitor:V", l.serial, l.serial)
|
||||||
l.cmd = exec.Command("bash", "-c", command)
|
l.cmd = builtin.Command(cmdLine)
|
||||||
l.cmd.Stderr = l.logBuffer
|
l.cmd.Stderr = l.logBuffer
|
||||||
l.cmd.Stdout = l.logBuffer
|
l.cmd.Stdout = l.logBuffer
|
||||||
l.cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
l.cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
||||||
@@ -280,8 +281,8 @@ func (l *DeviceLogcat) CatchLogcat() (err error) {
|
|||||||
|
|
||||||
func (l *DeviceLogcat) BufferedLogcat() (err error) {
|
func (l *DeviceLogcat) BufferedLogcat() (err error) {
|
||||||
// -d: dump the current buffered logcat result and exits
|
// -d: dump the current buffered logcat result and exits
|
||||||
command := fmt.Sprintf("adb -s %s logcat -d", l.serial)
|
cmdLine := fmt.Sprintf("adb -s %s logcat -d", l.serial)
|
||||||
cmd := exec.Command("bash", "-c", command)
|
cmd := builtin.Command(cmdLine)
|
||||||
cmd.Stdout = l.logBuffer
|
cmd.Stdout = l.logBuffer
|
||||||
cmd.Stderr = l.logBuffer
|
cmd.Stderr = l.logBuffer
|
||||||
if err = cmd.Run(); err != nil {
|
if err = cmd.Run(); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user