Skip to content

Commit 4df06c6

Browse files
rjacobs31onsi
authored andcommitted
Fix binary paths when precompiling multiple suites.
1 parent cbcf39a commit 4df06c6

File tree

6 files changed

+82
-5
lines changed

6 files changed

+82
-5
lines changed

ginkgo/build/build_command.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,20 @@ func buildSpecs(args []string, cliConfig types.CLIConfig, goFlagsConfig types.Go
5555
if suite.State.Is(internal.TestSuiteStateFailedToCompile) {
5656
fmt.Println(suite.CompilationError.Error())
5757
} else {
58-
if len(goFlagsConfig.O) == 0 {
59-
goFlagsConfig.O = path.Join(suite.Path, suite.PackageName+".test")
60-
} else {
58+
var testBinPath string
59+
if len(goFlagsConfig.O) != 0 {
6160
stat, err := os.Stat(goFlagsConfig.O)
6261
if err != nil {
6362
panic(err)
6463
}
6564
if stat.IsDir() {
66-
goFlagsConfig.O += "/" + suite.PackageName + ".test"
65+
testBinPath = goFlagsConfig.O + "/" + suite.PackageName + ".test"
6766
}
6867
}
69-
fmt.Printf("Compiled %s\n", goFlagsConfig.O)
68+
if len(testBinPath) == 0 {
69+
testBinPath = path.Join(suite.Path, suite.PackageName+".test")
70+
}
71+
fmt.Printf("Compiled %s\n", testBinPath)
7072
}
7173
}
7274

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package suite1_test
2+
3+
import (
4+
. "github.com/onsi/ginkgo/v2"
5+
. "github.com/onsi/gomega"
6+
7+
"testing"
8+
)
9+
10+
func TestAfterRunHook(t *testing.T) {
11+
RegisterFailHandler(Fail)
12+
RunSpecs(t, "Build reporting suite 1")
13+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package suite1_test
2+
3+
import (
4+
. "github.com/onsi/ginkgo/v2"
5+
. "github.com/onsi/gomega"
6+
)
7+
8+
var _ = Describe("Testing", func() {
9+
It("it should succeed", func() {
10+
Ω(true).Should(Equal(true))
11+
})
12+
13+
PIt("a failing test", func() {
14+
It("should fail", func() {
15+
Ω(true).Should(Equal(false))
16+
})
17+
})
18+
})
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package suite2_test
2+
3+
import (
4+
. "github.com/onsi/ginkgo/v2"
5+
. "github.com/onsi/gomega"
6+
7+
"testing"
8+
)
9+
10+
func TestAfterRunHook(t *testing.T) {
11+
RegisterFailHandler(Fail)
12+
RunSpecs(t, "Build reporting suite 1")
13+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package suite2_test
2+
3+
import (
4+
. "github.com/onsi/ginkgo/v2"
5+
. "github.com/onsi/gomega"
6+
)
7+
8+
var _ = Describe("Testing", func() {
9+
It("it should succeed", func() {
10+
Ω(true).Should(Equal(true))
11+
})
12+
13+
PIt("a failing test", func() {
14+
It("should fail", func() {
15+
Ω(true).Should(Equal(false))
16+
})
17+
})
18+
})

integration/precompiled_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ var _ = Describe("ginkgo build", func() {
4848
})
4949
})
5050

51+
var _ = Describe("ginkgo build with multiple suites", Label("build"), func() {
52+
It("should correctly report multiple test binaries", func() {
53+
fm.MountFixture("build_reporting")
54+
session := startGinkgo(fm.PathTo("build_reporting"), "build", "-r")
55+
Eventually(session).Should(gexec.Exit(0))
56+
output := string(session.Out.Contents())
57+
Ω(output).Should(ContainSubstring("Compiled suite1/suite1.test"))
58+
Ω(output).Should(ContainSubstring("Compiled suite2/suite2.test"))
59+
Ω(fm.PathTo("build_reporting", "suite1", "suite1.test")).Should(BeAnExistingFile())
60+
Ω(fm.PathTo("build_reporting", "suite2", "suite2.test")).Should(BeAnExistingFile())
61+
})
62+
})
63+
5164
var _ = Describe("ginkgo build with custom output", Label("build"), func() {
5265
const customPath = "mycustomdir"
5366
var fullPath string

0 commit comments

Comments
 (0)