Skip to content

Commit 8e74b34

Browse files
committed
sanity: support embedding tests multiple time in Ginkgo, II
This reverts commit ddf8b3f. It was meant to enable the call sequence DescribeSanity, RegisterTestsInGinkgo, DescribeSanity, RegisterTestsInGinkgo, but that call sequence is invalid: DescribeSanity must be called during the init phase, then RegisterTestsInGinkgo may be called multiple times with different configs. That usage got broken by the commit above because the second RegisterTestsInGinkgo then didn't add any of the tests defined by the sanity package. Users who want to add their own sanity tests can do it like this: Describe( ... func() { config := &sanity.TestConfig{...} Describe(..., func() { sc := NewTestContext(config) BeforeEach(func() { sc.Setup() }) AfterEach(func() { sc.Teardown() }) Describe(..., func() { ... }) }) sanity.GinkgoTest(config) }) NewTestContext must be made public for this to work. Otherwise TestContext has be initialized manually, which isn't as nice.
1 parent ddf8b3f commit 8e74b34

File tree

2 files changed

+0
-8
lines changed

2 files changed

+0
-8
lines changed

pkg/sanity/sanity.go

-4
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,6 @@ func Test(t GinkgoTestingT, config TestConfig) {
231231
// GinkgoTest for use when the tests run. Therefore its content can
232232
// still be modified in a BeforeEach. The sanity package itself treats
233233
// it as read-only.
234-
//
235-
// Only tests defined with DescribeSanity after the last invocation with
236-
// GinkgoTest (if there has be one) will be added, i.e. each test only
237-
// gets added at most once.
238234
func GinkgoTest(config *TestConfig) *TestContext {
239235
sc := newTestContext(config)
240236
registerTestsInGinkgo(sc)

pkg/sanity/tests.go

-4
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,4 @@ func registerTestsInGinkgo(sc *TestContext) {
5353
})
5454
})
5555
}
56-
// Don't register tests more than once! More tests might
57-
// be added later in a different context, followed by
58-
// another registerTestsInGinkgo call.
59-
tests = nil
6056
}

0 commit comments

Comments
 (0)