Skip to content

Commit 1be2427

Browse files
bcrochetonsi
authored andcommittedSep 26, 2022
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>
1 parent 57c373c commit 1be2427

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed
 
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package example_test
2+
3+
import (
4+
. "github.com/onsi/ginkgo/v2/dsl/core"
5+
)
6+
7+
var _ = Describe("DslCoreFixture", func() {
8+
Describe("dslcore", func() {
9+
It("dslcore", func() {
10+
By("step 1")
11+
By("step 2")
12+
})
13+
})
14+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Name,Text,Start,End,Spec,Focused,Pending
2+
Describe,DslCoreFixture,82,216,false,false,false
3+
Describe,dslcore,119,213,false,false,false
4+
It,dslcore,150,209,true,false,false
5+
By,step 1,176,188,false,false,false
6+
By,step 2,192,204,false,false,false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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":[]}]}]}]}]

‎ginkgo/outline/import.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func packageNameForImport(f *ast.File, path string) *string {
4747
// or nil otherwise.
4848
func importSpec(f *ast.File, path string) *ast.ImportSpec {
4949
for _, s := range f.Imports {
50-
if importPath(s) == path {
50+
if strings.HasPrefix(importPath(s), path) {
5151
return s
5252
}
5353
}

‎ginkgo/outline/outline_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ var _ = DescribeTable("Validate outline from file with",
5959
Entry("mixed focused containers and specs", "mixed_test.go", "mixed_test.go.json", "mixed_test.go.csv"),
6060
Entry("specs used to verify position", "position_test.go", "position_test.go.json", "position_test.go.csv"),
6161
Entry("suite setup", "suite_test.go", "suite_test.go.json", "suite_test.go.csv"),
62+
Entry("core dsl import", "dsl_core_test.go", "dsl_core_test.go.json", "dsl_core_test.go.csv"),
6263
)
6364

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

0 commit comments

Comments
 (0)
Please sign in to comment.