mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 15:37:35 +08:00
refactor: move exec to myexec
This commit is contained in:
@@ -4,13 +4,13 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/myexec"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -46,7 +46,7 @@ func DoCurl(args []string) (err error) {
|
||||
}
|
||||
}()
|
||||
|
||||
cmd := exec.Command("curl", args...)
|
||||
cmd := myexec.Command("curl", args...)
|
||||
var stdout, stderr bytes.Buffer
|
||||
cmd.Stdout = &stdout
|
||||
cmd.Stderr = &stderr
|
||||
@@ -60,11 +60,11 @@ func DoCurl(args []string) (err error) {
|
||||
return
|
||||
}
|
||||
if stdout.String() != "" {
|
||||
fmt.Printf(stdout.String())
|
||||
fmt.Println(stdout.String())
|
||||
curlResult.Result = stdout.String()
|
||||
curlResult.ResultType = normalResult
|
||||
} else if stderr.String() != "" {
|
||||
fmt.Printf(stderr.String())
|
||||
fmt.Println(stderr.String())
|
||||
curlResult.ErrorMsg = stderr.String()
|
||||
curlResult.ResultType = errorResult
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
@@ -18,6 +17,7 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/myexec"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -51,7 +51,7 @@ func DoTraceRoute(traceRouteOptions *TraceRouteOptions, args []string) (err erro
|
||||
traceRouteTarget = strings.Split(parsedURL.Host, ":")[0]
|
||||
}
|
||||
|
||||
cmd := exec.Command("traceroute", "-m", strconv.Itoa(traceRouteOptions.MaxTTL),
|
||||
cmd := myexec.Command("traceroute", "-m", strconv.Itoa(traceRouteOptions.MaxTTL),
|
||||
"-q", strconv.Itoa(traceRouteOptions.Queries), traceRouteTarget)
|
||||
stdout, _ := cmd.StdoutPipe()
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
@@ -49,7 +48,7 @@ func DoTraceRoute(traceRouteOptions *TraceRouteOptions, args []string) (err erro
|
||||
traceRouteTarget = strings.Split(parsedURL.Host, ":")[0]
|
||||
}
|
||||
|
||||
cmd := exec.Command("tracert", "-h", strconv.Itoa(traceRouteOptions.MaxTTL), traceRouteTarget)
|
||||
cmd := myexec.Command("tracert", "-h", strconv.Itoa(traceRouteOptions.MaxTTL), traceRouteTarget)
|
||||
stdout, _ := cmd.StdoutPipe()
|
||||
|
||||
startT := time.Now()
|
||||
|
||||
Reference in New Issue
Block a user