Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix testing suites outside of the current directory tree with Go 1.8 and test against Go 1.8 in CI #337

Closed
wants to merge 4 commits into from
Closed
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ go:
- 1.5
- 1.6
- 1.7
- 1.8

install:
- go get -v -t ./...
Expand Down
2 changes: 1 addition & 1 deletion ginkgo/testrunner/test_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (t *TestRunner) Compile() error {
}

func (t *TestRunner) BuildArgs(path string) []string {
args := []string{"test", "-c", "-i", "-o", path, t.Suite.Path}
args := []string{"test", "-c", "-o", path, t.Suite.Path}

if *t.goOpts["covermode"].(*string) != "" {
args = append(args, "-cover", fmt.Sprintf("-covermode=%s", *t.goOpts["covermode"].(*string)))
Expand Down
5 changes: 2 additions & 3 deletions ginkgo/testrunner/test_runner_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package testrunner_test

import (
"testing"

. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/ginkgo/testrunner"
"github.com/onsi/ginkgo/ginkgo/testsuite"
. "github.com/onsi/gomega"
"testing"
)

func strAddr(s string) interface{} {
Expand All @@ -22,7 +23,6 @@ func intAddr(s int) interface{} {

var _ = Describe("TestRunner", func() {
It("should pass through go opts", func() {
//var opts map[string]interface{}
opts := map[string]interface{}{
"asmflags": strAddr("a"),
"pkgdir": strAddr("b"),
Expand All @@ -38,7 +38,6 @@ var _ = Describe("TestRunner", func() {
Ω(args).Should(Equal([]string{
"test",
"-c",
"-i",
"-o",
".",
"",
Expand Down
12 changes: 12 additions & 0 deletions ginkgo/testsuite/_fixture_suite/passing_suite_setup_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package fixture_suite_test

import (
. "github.com/onsi/ginkgo"

"testing"
)

func TestPassingSuiteSetup(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "FixtureSuite Suite")
}
8 changes: 8 additions & 0 deletions ginkgo/testsuite/_fixture_suite/passing_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package fixture_suite_test

import (
. "github.com/onsi/ginkgo"
)

var _ = Describe("FixtureSuite", func() {
})
4 changes: 3 additions & 1 deletion ginkgo/testsuite/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ func relPath(dir string) string {
dir, _ = filepath.Abs(dir)
cwd, _ := os.Getwd()
dir, _ = filepath.Rel(cwd, filepath.Clean(dir))
dir = "." + string(filepath.Separator) + dir
if !strings.HasPrefix(dir, "..") {
dir = "." + string(filepath.Separator) + dir
}
return dir
}

Expand Down
31 changes: 23 additions & 8 deletions ginkgo/testsuite/testsuite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ var _ = Describe("TestSuite", func() {
cwd, err := os.Getwd()
Ω(err).ShouldNot(HaveOccurred())
relTmpDir, err = filepath.Rel(cwd, tmpDir)
relTmpDir = "./" + relTmpDir
Ω(err).ShouldNot(HaveOccurred())

//go files in the root directory (no tests)
Expand Down Expand Up @@ -130,14 +129,30 @@ var _ = Describe("TestSuite", func() {
})

Context("when there are ginkgo tests in the specified directory", func() {
It("should return an appropriately configured suite", func() {
suites := SuitesInDir(filepath.Join(tmpDir, "colonelmustard"), false)
Ω(suites).Should(HaveLen(1))
Context("and the directory is a child of the current working directory", func() {
It("should return an appropriately configured suite", func() {
cwd, err := os.Getwd()
Ω(err).ShouldNot(HaveOccurred())
suites := SuitesInDir(filepath.Join(cwd, "_fixture_suite"), false)
Ω(suites).Should(HaveLen(1))

Ω(suites[0].Path).Should(Equal("./_fixture_suite"))
Ω(suites[0].PackageName).Should(Equal("_fixture_suite"))
Ω(suites[0].IsGinkgo).Should(BeTrue())
Ω(suites[0].Precompiled).Should(BeFalse())
})
})

Ω(suites[0].Path).Should(Equal(relTmpDir + "/colonelmustard"))
Ω(suites[0].PackageName).Should(Equal("colonelmustard"))
Ω(suites[0].IsGinkgo).Should(BeTrue())
Ω(suites[0].Precompiled).Should(BeFalse())
Context("and the directory is outside the current working directory", func() {
It("should return an appropriately configured suite", func() {
suites := SuitesInDir(filepath.Join(tmpDir, "colonelmustard"), false)
Ω(suites).Should(HaveLen(1))

Ω(suites[0].Path).Should(Equal(relTmpDir + "/colonelmustard"))
Ω(suites[0].PackageName).Should(Equal("colonelmustard"))
Ω(suites[0].IsGinkgo).Should(BeTrue())
Ω(suites[0].Precompiled).Should(BeFalse())
})
})
})

Expand Down
31 changes: 23 additions & 8 deletions ginkgo/testsuite/vendor_check_go15_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ var _ = Describe("TestSuite", func() {
cwd, err := os.Getwd()
Ω(err).ShouldNot(HaveOccurred())
relTmpDir, err = filepath.Rel(cwd, tmpDir)
relTmpDir = "./" + relTmpDir
Ω(err).ShouldNot(HaveOccurred())

//go files in the root directory (no tests)
Expand Down Expand Up @@ -130,14 +129,30 @@ var _ = Describe("TestSuite", func() {
})

Context("when there are ginkgo tests in the specified directory", func() {
It("should return an appropriately configured suite", func() {
suites := SuitesInDir(filepath.Join(tmpDir, "colonelmustard"), false)
Ω(suites).Should(HaveLen(1))
Context("and the directory is a child of the current working directory", func() {
It("should return an appropriately configured suite", func() {
cwd, err := os.Getwd()
Ω(err).ShouldNot(HaveOccurred())
suites := SuitesInDir(filepath.Join(cwd, "_fixture_suite"), false)
Ω(suites).Should(HaveLen(1))

Ω(suites[0].Path).Should(Equal("./_fixture_suite"))
Ω(suites[0].PackageName).Should(Equal("_fixture_suite"))
Ω(suites[0].IsGinkgo).Should(BeTrue())
Ω(suites[0].Precompiled).Should(BeFalse())
})
})

Ω(suites[0].Path).Should(Equal(relTmpDir + "/colonelmustard"))
Ω(suites[0].PackageName).Should(Equal("colonelmustard"))
Ω(suites[0].IsGinkgo).Should(BeTrue())
Ω(suites[0].Precompiled).Should(BeFalse())
Context("and the directory is outside the current working directory", func() {
It("should return an appropriately configured suite", func() {
suites := SuitesInDir(filepath.Join(tmpDir, "colonelmustard"), false)
Ω(suites).Should(HaveLen(1))

Ω(suites[0].Path).Should(Equal(relTmpDir + "/colonelmustard"))
Ω(suites[0].PackageName).Should(Equal("colonelmustard"))
Ω(suites[0].IsGinkgo).Should(BeTrue())
Ω(suites[0].Precompiled).Should(BeFalse())
})
})
})

Expand Down
1 change: 1 addition & 0 deletions integration/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ var _ = Describe("Flags Specs", func() {
output = regextest("-regexScansFilePath=false", "-focus=/passing/") // nothing gets focused (nothing runs)
Ω(output).Should(ContainSubstring("0 of 4 Specs"))
})

It("should honor compiler flags", func() {
session := startGinkgo(pathToTest, "-gcflags=-importmap 'math=math/cmplx'")
Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
Expand Down