diff --git a/ginkgo/internal/test_suite.go b/ginkgo/internal/test_suite.go index 6d83b5400..e42b3a5a0 100644 --- a/ginkgo/internal/test_suite.go +++ b/ginkgo/internal/test_suite.go @@ -186,16 +186,17 @@ func precompiledTestSuite(path string) (TestSuite, error) { return TestSuite{}, errors.New("this is a directory, not a file") } - if filepath.Ext(path) != ".test" { + if filepath.Ext(path) != ".test" && filepath.Ext(path) != ".exe" { return TestSuite{}, errors.New("this is not a .test binary") } - if info.Mode()&0111 == 0 { + if filepath.Ext(path) == ".test" && 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)) + packageName := strings.TrimSuffix(filepath.Base(path), ".exe") + packageName = strings.TrimSuffix(packageName, ".test") path, err = filepath.Abs(path) if err != nil { diff --git a/ginkgo/internal/testsuite_test.go b/ginkgo/internal/testsuite_test.go index d054489f6..09f6032d4 100644 --- a/ginkgo/internal/testsuite_test.go +++ b/ginkgo/internal/testsuite_test.go @@ -82,6 +82,8 @@ var _ = Describe("TestSuite", func() { //a precompiled ginkgo test writeFile("/precompiled-dir", "precompiled.test", `fake-binary-file`, 0777) writeFile("/precompiled-dir", "some-other-binary", `fake-binary-file`, 0777) + writeFile("/precompiled-dir", "windows.test.exe", `fake-binary-file`, 0666) + writeFile("/precompiled-dir", "windows.exe", `fake-binary-file`, 0666) writeFile("/precompiled-dir", "nonexecutable.test", `fake-binary-file`, 0666) }) @@ -241,6 +243,24 @@ var _ = Describe("TestSuite", func() { }) }) + Context("when pointed at a precompiled test suite on windows", func() { + It("returns the precompiled suite", func() { + path, err := filepath.Abs("./precompiled-dir/windows.exe") + Ω(err).ShouldNot(HaveOccurred()) + suites := FindSuites([]string{"precompiled-dir/windows.exe"}, cliConf, true) + Ω(suites).Should(ConsistOf( + PTS("./precompiled-dir", "windows", true, path, TestSuiteStateCompiled), + )) + + path, err = filepath.Abs("./precompiled-dir/windows.test.exe") + Ω(err).ShouldNot(HaveOccurred()) + suites = FindSuites([]string{"precompiled-dir/windows.test.exe"}, cliConf, true) + Ω(suites).Should(ConsistOf( + PTS("./precompiled-dir", "windows", true, path, TestSuiteStateCompiled), + )) + }) + }) + Context("when pointed at a fake precompiled test", func() { It("returns nothing", func() { suites := FindSuites([]string{"precompiled-dir/some-other-binary"}, cliConf, true)