diff --git a/ginkgo/testrunner/test_runner.go b/ginkgo/testrunner/test_runner.go index a0113e136..76a8449de 100644 --- a/ginkgo/testrunner/test_runner.go +++ b/ginkgo/testrunner/test_runner.go @@ -8,6 +8,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "strconv" "strings" "syscall" @@ -425,7 +426,11 @@ func (t *TestRunner) cmd(ginkgoArgs []string, stream io.Writer, node int) *exec. path := t.compilationTargetPath if t.Suite.Precompiled { - path, _ = filepath.Abs(filepath.Join(t.Suite.Path, fmt.Sprintf("%s.test", t.Suite.PackageName))) + windowsExt := "" + if runtime.GOOS == "windows" { + windowsExt = ".exe" + } + path, _ = filepath.Abs(filepath.Join(t.Suite.Path, fmt.Sprintf("%s.test%s", t.Suite.PackageName, windowsExt))) } cmd := exec.Command(path, args...) diff --git a/ginkgo/testsuite/test_suite.go b/ginkgo/testsuite/test_suite.go index 9de8c2bb4..da3a6b3e2 100644 --- a/ginkgo/testsuite/test_suite.go +++ b/ginkgo/testsuite/test_suite.go @@ -6,6 +6,7 @@ import ( "os" "path/filepath" "regexp" + "runtime" "strings" ) @@ -26,16 +27,22 @@ func PrecompiledTestSuite(path string) (TestSuite, error) { return TestSuite{}, errors.New("this is a directory, not a file") } - if filepath.Ext(path) != ".test" { - return TestSuite{}, errors.New("this is not a .test binary") + if (runtime.GOOS != "windows" && filepath.Ext(path) != ".test") || + (runtime.GOOS == "windows" && !strings.HasSuffix(path, ".test.exe")) { + return TestSuite{}, errors.New("this is not a .test (.test.exe) binary") } - if info.Mode()&0111 == 0 { + if runtime.GOOS != "windows" && info.Mode()&0111 == 0 { return TestSuite{}, errors.New("this is not executable") } dir := relPath(filepath.Dir(path)) - packageName := strings.TrimSuffix(filepath.Base(path), filepath.Ext(path)) + var packageName string + if strings.HasSuffix(path, ".test.exe") { + packageName = strings.TrimSuffix(filepath.Base(path), ".test.exe") + } else { + packageName = strings.TrimSuffix(filepath.Base(path), filepath.Ext(path)) + } return TestSuite{ Path: dir,