Skip to content

Commit

Permalink
Support precompiled binaries in windows with .exe and .test.exe exten…
Browse files Browse the repository at this point in the history
…sions

Fixes #529
  • Loading branch information
onsi committed Oct 12, 2021
1 parent 44f2181 commit 605649b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ginkgo/internal/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 20 additions & 0 deletions ginkgo/internal/testsuite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 605649b

Please sign in to comment.