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 binary paths when precompiling multiple suites. #1511

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
12 changes: 7 additions & 5 deletions ginkgo/build/build_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,20 @@ func buildSpecs(args []string, cliConfig types.CLIConfig, goFlagsConfig types.Go
if suite.State.Is(internal.TestSuiteStateFailedToCompile) {
fmt.Println(suite.CompilationError.Error())
} else {
if len(goFlagsConfig.O) == 0 {
goFlagsConfig.O = path.Join(suite.Path, suite.PackageName+".test")
} else {
var testBinPath string
if len(goFlagsConfig.O) != 0 {
stat, err := os.Stat(goFlagsConfig.O)
if err != nil {
panic(err)
}
if stat.IsDir() {
goFlagsConfig.O += "/" + suite.PackageName + ".test"
testBinPath = goFlagsConfig.O + "/" + suite.PackageName + ".test"
}
}
fmt.Printf("Compiled %s\n", goFlagsConfig.O)
if len(testBinPath) == 0 {
testBinPath = path.Join(suite.Path, suite.PackageName+".test")
}
fmt.Printf("Compiled %s\n", testBinPath)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package suite1_test

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

"testing"
)

func TestAfterRunHook(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Build reporting suite 1")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package suite1_test

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

var _ = Describe("Testing", func() {
It("it should succeed", func() {
Ω(true).Should(Equal(true))
})

PIt("a failing test", func() {
It("should fail", func() {
Ω(true).Should(Equal(false))
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package suite2_test

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

"testing"
)

func TestAfterRunHook(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Build reporting suite 1")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package suite2_test

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

var _ = Describe("Testing", func() {
It("it should succeed", func() {
Ω(true).Should(Equal(true))
})

PIt("a failing test", func() {
It("should fail", func() {
Ω(true).Should(Equal(false))
})
})
})
13 changes: 13 additions & 0 deletions integration/precompiled_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ var _ = Describe("ginkgo build", func() {
})
})

var _ = Describe("ginkgo build with multiple suites", Label("build"), func() {
It("should correctly report multiple test binaries", func() {
fm.MountFixture("build_reporting")
session := startGinkgo(fm.PathTo("build_reporting"), "build", "-r")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("Compiled suite1/suite1.test"))
Ω(output).Should(ContainSubstring("Compiled suite2/suite2.test"))
Ω(fm.PathTo("build_reporting", "suite1", "suite1.test")).Should(BeAnExistingFile())
Ω(fm.PathTo("build_reporting", "suite2", "suite2.test")).Should(BeAnExistingFile())
})
})

var _ = Describe("ginkgo build with custom output", Label("build"), func() {
const customPath = "mycustomdir"
var fullPath string
Expand Down