hakurei/helper/export_test.go
Ophestra Umiker d530a9e9f9
helper: stub helper for tests
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-09-29 14:40:01 +09:00

19 lines
405 B
Go

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...)...)
}
}