-
-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
outline: Add support for nodot and alias import of the ginkgo package
- Loading branch information
1 parent
c386859
commit bdc78da
Showing
9 changed files
with
210 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package example_test | ||
|
||
import ( | ||
fooginkgo "github.com/onsi/ginkgo" | ||
) | ||
|
||
var _ = fooginkgo.Describe("NodotFixture", func() { | ||
fooginkgo.Describe("normal", func() { | ||
fooginkgo.It("normal", func() { | ||
|
||
}) | ||
}) | ||
|
||
fooginkgo.Context("normal", func() { | ||
fooginkgo.It("normal", func() { | ||
|
||
}) | ||
}) | ||
|
||
fooginkgo.When("normal", func() { | ||
fooginkgo.It("normal", func() { | ||
|
||
}) | ||
}) | ||
|
||
fooginkgo.It("normal", func() { | ||
|
||
}) | ||
|
||
fooginkgo.Specify("normal", func() { | ||
|
||
}) | ||
|
||
fooginkgo.Measure("normal", func(b Benchmarker) { | ||
|
||
}, 2) | ||
|
||
fooginkgo.DescribeTable("normal", | ||
func() {}, | ||
fooginkgo.Entry("normal"), | ||
) | ||
|
||
fooginkgo.DescribeTable("normal", | ||
func() {}, | ||
fooginkgo.Entry("normal"), | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Name,Text,Start,End,Spec,Focused,Pending | ||
Describe,NodotFixture,79,676,false,false,false | ||
Describe,normal,124,205,false,false,false | ||
It,normal,164,201,true,false,false | ||
Context,normal,208,288,false,false,false | ||
It,normal,247,284,true,false,false | ||
When,normal,291,368,false,false,false | ||
It,normal,327,364,true,false,false | ||
It,normal,371,407,true,false,false | ||
Specify,normal,410,451,true,false,false | ||
Measure,normal,454,511,true,false,false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"name":"Describe","text":"NodotFixture","start":79,"end":676,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"Describe","text":"normal","start":124,"end":205,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"normal","start":164,"end":201,"spec":true,"focused":false,"pending":false}]},{"name":"Context","text":"normal","start":208,"end":288,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"normal","start":247,"end":284,"spec":true,"focused":false,"pending":false}]},{"name":"When","text":"normal","start":291,"end":368,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"normal","start":327,"end":364,"spec":true,"focused":false,"pending":false}]},{"name":"It","text":"normal","start":371,"end":407,"spec":true,"focused":false,"pending":false},{"name":"Specify","text":"normal","start":410,"end":451,"spec":true,"focused":false,"pending":false},{"name":"Measure","text":"normal","start":454,"end":511,"spec":true,"focused":false,"pending":false}]}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package example_test | ||
|
||
import ( | ||
"github.com/onsi/ginkgo" | ||
) | ||
|
||
var _ = ginkgo.Describe("NodotFixture", func() { | ||
ginkgo.Describe("normal", func() { | ||
ginkgo.It("normal", func() { | ||
|
||
}) | ||
}) | ||
|
||
ginkgo.Context("normal", func() { | ||
ginkgo.It("normal", func() { | ||
|
||
}) | ||
}) | ||
|
||
ginkgo.When("normal", func() { | ||
ginkgo.It("normal", func() { | ||
|
||
}) | ||
}) | ||
|
||
ginkgo.It("normal", func() { | ||
|
||
}) | ||
|
||
ginkgo.Specify("normal", func() { | ||
|
||
}) | ||
|
||
ginkgo.Measure("normal", func(b Benchmarker) { | ||
|
||
}, 2) | ||
|
||
ginkgo.DescribeTable("normal", | ||
func() {}, | ||
ginkgo.Entry("normal"), | ||
) | ||
|
||
ginkgo.DescribeTable("normal", | ||
func() {}, | ||
ginkgo.Entry("normal"), | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Name,Text,Start,End,Spec,Focused,Pending | ||
Describe,NodotFixture,69,624,false,false,false | ||
Describe,normal,111,186,false,false,false | ||
It,normal,148,182,true,false,false | ||
Context,normal,189,263,false,false,false | ||
It,normal,225,259,true,false,false | ||
When,normal,266,337,false,false,false | ||
It,normal,299,333,true,false,false | ||
It,normal,340,373,true,false,false | ||
Specify,normal,376,414,true,false,false | ||
Measure,normal,417,471,true,false,false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"name":"Describe","text":"NodotFixture","start":69,"end":624,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"Describe","text":"normal","start":111,"end":186,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"normal","start":148,"end":182,"spec":true,"focused":false,"pending":false}]},{"name":"Context","text":"normal","start":189,"end":263,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"normal","start":225,"end":259,"spec":true,"focused":false,"pending":false}]},{"name":"When","text":"normal","start":266,"end":337,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"normal","start":299,"end":333,"spec":true,"focused":false,"pending":false}]},{"name":"It","text":"normal","start":340,"end":373,"spec":true,"focused":false,"pending":false},{"name":"Specify","text":"normal","start":376,"end":414,"spec":true,"focused":false,"pending":false},{"name":"Measure","text":"normal","start":417,"end":471,"spec":true,"focused":false,"pending":false}]}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2013 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// Most of the required functions were available in the | ||
// "golang.org/x/tools/go/ast/astutil" package, but not exported. | ||
// They were copied from https://github.com/golang/tools/blob/2b0845dc783e36ae26d683f4915a5840ef01ab0f/go/ast/astutil/imports.go | ||
|
||
package outline | ||
|
||
import ( | ||
"go/ast" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
// importNameForPackage returns the import name for the package. If the package | ||
// is not imported, it returns false. Examples: | ||
// How package is imported -> Import Name | ||
// "import example.com/pkg/foo" -> "foo" | ||
// "import fooalias example.com/pkg/foo" -> "fooalias" | ||
// "import . example.com/pkg/foo" -> "." | ||
func importNameForPackage(f *ast.File, path string) (string, bool) { | ||
spec := importSpec(f, path) | ||
if spec == nil { | ||
return "", false | ||
} | ||
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:] | ||
} | ||
} | ||
return name, true | ||
} | ||
|
||
// importSpec returns the import spec if f imports path, | ||
// or nil otherwise. | ||
func importSpec(f *ast.File, path string) *ast.ImportSpec { | ||
for _, s := range f.Imports { | ||
if importPath(s) == path { | ||
return s | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
// importPath returns the unquoted import path of s, | ||
// or "" if the path is not properly quoted. | ||
func importPath(s *ast.ImportSpec) string { | ||
t, err := strconv.Unquote(s.Path.Value) | ||
if err != nil { | ||
return "" | ||
} | ||
return t | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters