Add test sub command

Allows compiling a test binary and debugging it.
This commit is contained in:
Derek Parker
2015-03-08 22:59:37 -05:00
parent 0125e300cd
commit bb4356b713
3 changed files with 27 additions and 1 deletions

View File

@ -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 {