Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make the outline command able to use the DSL import
The outline command throws an error if the only the core DSL is
imported. This allows any of the DSL to be imported and still
produce a valid outline.

Signed-off-by: Brad P. Crochet <brad@redhat.com>
  • Loading branch information
bcrochet authored and onsi committed Sep 26, 2022
1 parent 57c373c commit 1be2427
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
14 changes: 14 additions & 0 deletions ginkgo/outline/_testdata/dsl_core_test.go
@@ -0,0 +1,14 @@
package example_test

import (
. "github.com/onsi/ginkgo/v2/dsl/core"
)

var _ = Describe("DslCoreFixture", func() {
Describe("dslcore", func() {
It("dslcore", func() {
By("step 1")
By("step 2")
})
})
})
6 changes: 6 additions & 0 deletions ginkgo/outline/_testdata/dsl_core_test.go.csv
@@ -0,0 +1,6 @@
Name,Text,Start,End,Spec,Focused,Pending
Describe,DslCoreFixture,82,216,false,false,false
Describe,dslcore,119,213,false,false,false
It,dslcore,150,209,true,false,false
By,step 1,176,188,false,false,false
By,step 2,192,204,false,false,false
1 change: 1 addition & 0 deletions ginkgo/outline/_testdata/dsl_core_test.go.json
@@ -0,0 +1 @@
[{"name":"Describe","text":"DslCoreFixture","start":82,"end":216,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"Describe","text":"dslcore","start":119,"end":213,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"dslcore","start":150,"end":209,"spec":true,"focused":false,"pending":false,"nodes":[{"name":"By","text":"step 1","start":176,"end":188,"spec":false,"focused":false,"pending":false,"nodes":[]},{"name":"By","text":"step 2","start":192,"end":204,"spec":false,"focused":false,"pending":false,"nodes":[]}]}]}]}]
2 changes: 1 addition & 1 deletion ginkgo/outline/import.go
Expand Up @@ -47,7 +47,7 @@ func packageNameForImport(f *ast.File, path string) *string {
// or nil otherwise.
func importSpec(f *ast.File, path string) *ast.ImportSpec {
for _, s := range f.Imports {
if importPath(s) == path {
if strings.HasPrefix(importPath(s), path) {
return s
}
}
Expand Down
1 change: 1 addition & 0 deletions ginkgo/outline/outline_test.go
Expand Up @@ -59,6 +59,7 @@ var _ = DescribeTable("Validate outline from file with",
Entry("mixed focused containers and specs", "mixed_test.go", "mixed_test.go.json", "mixed_test.go.csv"),
Entry("specs used to verify position", "position_test.go", "position_test.go.json", "position_test.go.csv"),
Entry("suite setup", "suite_test.go", "suite_test.go.json", "suite_test.go.csv"),
Entry("core dsl import", "dsl_core_test.go", "dsl_core_test.go.json", "dsl_core_test.go.csv"),
)

var _ = Describe("Validate position", func() {
Expand Down

0 comments on commit 1be2427

Please sign in to comment.