Inline helper code
This commit is contained in:
parent
813340abe6
commit
e106b1a2f1
@ -10,12 +10,10 @@ import (
|
|||||||
"github.com/derekparker/delve/proctl"
|
"github.com/derekparker/delve/proctl"
|
||||||
)
|
)
|
||||||
|
|
||||||
type testfunc func(p *proctl.DebuggedProcess)
|
func WithTestProcess(name string, t *testing.T, fn func(p *proctl.DebuggedProcess)) {
|
||||||
|
|
||||||
func WithTestProcess(name string, t *testing.T, fn testfunc) {
|
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
base, err := compileTestProg(name)
|
base := filepath.Base(name)
|
||||||
if err != nil {
|
if err := exec.Command("go", "build", "-gcflags=-N -l", "-o", base, name+".go").Run(); err != nil {
|
||||||
t.Fatalf("Could not compile %s due to %s", name, err)
|
t.Fatalf("Could not compile %s due to %s", name, err)
|
||||||
}
|
}
|
||||||
defer os.Remove("./" + base)
|
defer os.Remove("./" + base)
|
||||||
@ -29,8 +27,3 @@ func WithTestProcess(name string, t *testing.T, fn testfunc) {
|
|||||||
|
|
||||||
fn(p)
|
fn(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func compileTestProg(source string) (string, error) {
|
|
||||||
base := filepath.Base(source)
|
|
||||||
return base, exec.Command("go", "build", "-gcflags=-N -l", "-o", base, source+".go").Run()
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user