forked from security/hakurei
helper: stub helper for tests
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
18
helper/export_test.go
Normal file
18
helper/export_test.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package helper
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// replace execCommand to have the resulting *exec.Cmd launch TestHelperChildStub
|
||||
func ReplaceExecCommand(t *testing.T) {
|
||||
t.Cleanup(func() {
|
||||
execCommand = exec.Command
|
||||
})
|
||||
|
||||
execCommand = func(name string, arg ...string) *exec.Cmd {
|
||||
return exec.Command(os.Args[0], append([]string{"-test.run=TestHelperChildStub", "--", name}, arg...)...)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user