Skip to content

Commit

Permalink
ensure integration tests pass in an environment sans GOPATH
Browse files Browse the repository at this point in the history
  • Loading branch information
onsi committed Jun 12, 2020
1 parent fc0e44e commit 606fba2
Show file tree
Hide file tree
Showing 16 changed files with 85 additions and 63 deletions.
4 changes: 2 additions & 2 deletions ginkgo/main.go
Expand Up @@ -288,9 +288,9 @@ func findSuites(args []string, recurseForAll bool, skipPackage string, allowPrec
}

func goFmt(path string) {
err := exec.Command("go", "fmt", path).Run()
out, err := exec.Command("go", "fmt", path).CombinedOutput()
if err != nil {
complainAndQuit("Could not fmt: " + err.Error())
complainAndQuit("Could not fmt: " + err.Error() + "\n" + string(out))
}
}

Expand Down
1 change: 1 addition & 0 deletions go.mod
Expand Up @@ -4,6 +4,7 @@ require (
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/nxadm/tail v1.4.4
github.com/onsi/gomega v1.10.1
github.com/sclevine/agouti v3.0.0+incompatible // indirect
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299
golang.org/x/text v0.3.2 // indirect
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Expand Up @@ -25,6 +25,8 @@ github.com/onsi/gomega v1.7.1 h1:K0jcRCwNQM3vFGh1ppMtDh/+7ApJrjldlX8fA0jDTLQ=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/sclevine/agouti v3.0.0+incompatible h1:8IBJS6PWz3uTlMP3YBIR5f+KAldcGuOeFkFbUWfBgK4=
github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down
2 changes: 1 addition & 1 deletion integration/_fixtures/watch_fixtures/A/A.go
@@ -1,6 +1,6 @@
package A

import "github.com/onsi/B"
import "$ROOT_PATH$/B"

func DoIt() string {
return B.DoIt()
Expand Down
2 changes: 1 addition & 1 deletion integration/_fixtures/watch_fixtures/A/A_test.go
@@ -1,7 +1,7 @@
package A_test

import (
. "github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/A"
. "$ROOT_PATH$/A"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down
2 changes: 1 addition & 1 deletion integration/_fixtures/watch_fixtures/B/B.go
@@ -1,6 +1,6 @@
package B

import "github.com/onsi/C"
import "$ROOT_PATH$/C"

func DoIt() string {
return C.DoIt()
Expand Down
2 changes: 1 addition & 1 deletion integration/_fixtures/watch_fixtures/B/B_test.go
@@ -1,7 +1,7 @@
package B_test

import (
. "github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/B"
. "$ROOT_PATH$/B"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down
2 changes: 1 addition & 1 deletion integration/_fixtures/watch_fixtures/C/C_test.go
@@ -1,7 +1,7 @@
package C_test

import (
. "github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C"
. "$ROOT_PATH$/C"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down
2 changes: 1 addition & 1 deletion integration/_fixtures/watch_fixtures/D/D.go
@@ -1,6 +1,6 @@
package D

import "github.com/onsi/C"
import "$ROOT_PATH$/C"

func DoIt() string {
return C.DoIt()
Expand Down
2 changes: 1 addition & 1 deletion integration/_fixtures/watch_fixtures/D/D_test.go
@@ -1,7 +1,7 @@
package D_test

import (
. "github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C"
. "$ROOT_PATH$/D"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down
1 change: 1 addition & 0 deletions integration/coverage_test.go
Expand Up @@ -18,6 +18,7 @@ var _ = Describe("Coverage Specs", func() {
AfterEach(func() {
removeSuccessfully("./_fixtures/coverage_fixture/coverage_fixture.coverprofile")
})

It("works", func() {
session := startGinkgo("./_fixtures/coverage_fixture", "-cover")
Eventually(session).Should(gexec.Exit(0))
Expand Down
6 changes: 4 additions & 2 deletions integration/integration_suite_test.go
@@ -1,6 +1,7 @@
package integration_test

import (
"fmt"
"io"
"io/ioutil"
"os"
Expand Down Expand Up @@ -34,8 +35,8 @@ var _ = SynchronizedBeforeSuite(func() []byte {
})

var _ = BeforeEach(func() {
var err error
tmpDir, err = ioutil.TempDir("", "ginkgo-run")
tmpDir = fmt.Sprintf("./ginko-run-%d", GinkgoParallelNode())
err := os.Mkdir(tmpDir, 0700)
Ω(err).ShouldNot(HaveOccurred())
})

Expand All @@ -45,6 +46,7 @@ var _ = AfterEach(func() {
})

var _ = SynchronizedAfterSuite(func() {}, func() {
os.RemoveAll(tmpDir)
gexec.CleanupBuildArtifacts()
})

Expand Down
2 changes: 1 addition & 1 deletion integration/run_test.go
Expand Up @@ -50,7 +50,7 @@ var _ = Describe("Running Specs", func() {
})

It("should run the ginkgo style tests", func() {
session := startGinkgo(tmpDir, "--noColor", pathToTest)
session := startGinkgo(tmpDir, "--noColor", "ginkgo")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())

Expand Down
4 changes: 2 additions & 2 deletions integration/subcommand_test.go
Expand Up @@ -98,7 +98,7 @@ var _ = Describe("Subcommand", func() {
func Test{{.FormattedName}}(t *testing.T) {
// This is a {{.Package}} test
}`), 0666)
session := startGinkgo(pkgPath, "bootstrap", "--template", templateFile)
session := startGinkgo(pkgPath, "bootstrap", "--template", ".bootstrap")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()

Expand Down Expand Up @@ -311,7 +311,7 @@ var _ = Describe("Subcommand", func() {
Describe("ginkgo bootstrap/generate", func() {
var pkgPath string
BeforeEach(func() {
pkgPath = tmpPath("some crazy-thing")
pkgPath = tmpPath("some-crazy-thing")
os.Mkdir(pkgPath, 0777)
})

Expand Down
8 changes: 4 additions & 4 deletions integration/verbose_and_succinct_test.go
Expand Up @@ -45,7 +45,7 @@ var _ = Describe("Verbose And Succinct Mode", func() {

Context("with no flags set", func() {
It("should default to succinct mode", func() {
session := startGinkgo(pathToTest, "--noColor", pathToTest, otherPathToTest)
session := startGinkgo(tmpDir, "--noColor", "ginkgo", "more_ginkgo")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()

Expand All @@ -56,7 +56,7 @@ var _ = Describe("Verbose And Succinct Mode", func() {

Context("with --succinct=false", func() {
It("should not be in succinct mode", func() {
session := startGinkgo(pathToTest, "--noColor", "--succinct=false", pathToTest, otherPathToTest)
session := startGinkgo(tmpDir, "--noColor", "--succinct=false", "ginkgo", "more_ginkgo")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()

Expand All @@ -67,7 +67,7 @@ var _ = Describe("Verbose And Succinct Mode", func() {

Context("with -v", func() {
It("should not be in succinct mode, but should be verbose", func() {
session := startGinkgo(pathToTest, "--noColor", "-v", pathToTest, otherPathToTest)
session := startGinkgo(tmpDir, "--noColor", "-v", "ginkgo", "more_ginkgo")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()

Expand All @@ -78,7 +78,7 @@ var _ = Describe("Verbose And Succinct Mode", func() {
})

It("should emit output from Bys", func() {
session := startGinkgo(pathToTest, "--noColor", "-v", pathToTest)
session := startGinkgo(tmpDir, "--noColor", "-v", "ginkgo")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()

Expand Down

0 comments on commit 606fba2

Please sign in to comment.