mirror of
https://github.com/go-delve/delve.git
synced 2025-11-02 04:36:29 +08:00
Add test sub command
Allows compiling a test binary and debugging it.
This commit is contained in:
@ -6,8 +6,9 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
sys "golang.org/x/sys/unix"
|
||||
|
||||
@ -41,6 +42,24 @@ func Run(args []string) {
|
||||
if err != nil {
|
||||
die(1, "Could not launch program:", err)
|
||||
}
|
||||
case "test":
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
die(1, err)
|
||||
}
|
||||
base := filepath.Base(wd)
|
||||
cmd := exec.Command("go", "test", "-c", "-gcflags", "-N -l")
|
||||
err = cmd.Run()
|
||||
if err != nil {
|
||||
die(1, "Could not compile program:", err)
|
||||
}
|
||||
debugname := "./" + base + ".test"
|
||||
defer os.Remove(debugname)
|
||||
|
||||
dbp, err = proctl.Launch(append([]string{debugname}, args...))
|
||||
if err != nil {
|
||||
die(1, "Could not launch program:", err)
|
||||
}
|
||||
case "attach":
|
||||
pid, err := strconv.Atoi(args[1])
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user