Skip to content

Commit

Permalink
fix outline when using nodot inginkgo v2
Browse files Browse the repository at this point in the history
  • Loading branch information
onsi committed Jan 17, 2024
1 parent 96e915c commit dca77c8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
15 changes: 15 additions & 0 deletions ginkgo/outline/_testdata/nodot_test.go.csv
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
Name,Text,Start,End,Spec,Focused,Pending,Labels
Describe,NodotFixture,71,614,false,false,false,""
Describe,normal,113,233,false,false,false,""
It,normal,150,229,true,false,false,""
By,normal,182,201,false,false,false,""
By,normal,205,224,false,false,false,""
Context,normal,236,310,false,false,false,""
It,normal,272,306,true,false,false,""
When,normal,313,384,false,false,false,""
It,normal,346,380,true,false,false,""
It,normal,387,420,true,false,false,""
Specify,normal,423,461,true,false,false,""
DescribeTable,normal,464,536,false,false,false,""
Entry,normal,510,532,true,false,false,""
DescribeTable,normal,539,611,false,false,false,""
Entry,normal,585,607,true,false,false,""
2 changes: 1 addition & 1 deletion ginkgo/outline/_testdata/nodot_test.go.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[]
[{"name":"Describe","text":"NodotFixture","start":71,"end":614,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"Describe","text":"normal","start":113,"end":233,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"It","text":"normal","start":150,"end":229,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"By","text":"normal","start":182,"end":201,"spec":false,"focused":false,"pending":false,"labels":null,"nodes":[]},{"name":"By","text":"normal","start":205,"end":224,"spec":false,"focused":false,"pending":false,"labels":null,"nodes":[]}]}]},{"name":"Context","text":"normal","start":236,"end":310,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"It","text":"normal","start":272,"end":306,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]},{"name":"When","text":"normal","start":313,"end":384,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"It","text":"normal","start":346,"end":380,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]},{"name":"It","text":"normal","start":387,"end":420,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]},{"name":"Specify","text":"normal","start":423,"end":461,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]},{"name":"DescribeTable","text":"normal","start":464,"end":536,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"Entry","text":"normal","start":510,"end":532,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]},{"name":"DescribeTable","text":"normal","start":539,"end":611,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"Entry","text":"normal","start":585,"end":607,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]}]}]
3 changes: 2 additions & 1 deletion ginkgo/outline/ginkgo.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package outline

import (
"github.com/onsi/ginkgo/v2/types"
"go/ast"
"go/token"
"strconv"

"github.com/onsi/ginkgo/v2/types"
)

const (
Expand Down
9 changes: 1 addition & 8 deletions ginkgo/outline/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,7 @@ func packageNameForImport(f *ast.File, path string) *string {
}
name := spec.Name.String()
if name == "<nil>" {
// If the package name is not explicitly specified,
// make an educated guess. This is not guaranteed to be correct.
lastSlash := strings.LastIndex(path, "/")
if lastSlash == -1 {
name = path
} else {
name = path[lastSlash+1:]
}
name = "ginkgo"
}
if name == "." {
name = ""
Expand Down

0 comments on commit dca77c8

Please sign in to comment.