Skip to content

Commit

Permalink
Fix binary paths when precompiling multiple suites.
Browse files Browse the repository at this point in the history
  • Loading branch information
rjacobs31 committed Jan 21, 2025
1 parent 60cc4e2 commit 1ba25d7
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 5 deletions.
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 = "/" + 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

0 comments on commit 1ba25d7

Please sign in to comment.