Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ginkgo/testrunner/test_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strconv"
"strings"
"syscall"
Expand Down Expand Up @@ -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...)
Expand Down
15 changes: 11 additions & 4 deletions ginkgo/testsuite/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"path/filepath"
"regexp"
"runtime"
"strings"
)

Expand All @@ -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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move assign value in else block to packageName declaration?

packageName = strings.TrimSuffix(filepath.Base(path), filepath.Ext(path))
}

return TestSuite{
Path: dir,
Expand Down