fix context import when package is not godog

Этот коммит содержится в:
gedi 2015-06-12 20:15:39 +03:00
родитель f292e412c6
коммит d111956758
3 изменённых файлов: 19 добавлений и 18 удалений

Просмотреть файл

@ -85,17 +85,22 @@ func (b *builder) deleteMainFunc(f *ast.File) {
func (b *builder) registerSteps(f *ast.File) { func (b *builder) registerSteps(f *ast.File) {
for _, d := range f.Decls { for _, d := range f.Decls {
fun, ok := d.(*ast.FuncDecl) switch fun := d.(type) {
if !ok { case *ast.FuncDecl:
continue for _, param := range fun.Type.Params.List {
} switch expr := param.Type.(type) {
for _, param := range fun.Type.Params.List { case *ast.SelectorExpr:
ident, ok := param.Type.(*ast.Ident) switch x := expr.X.(type) {
if !ok { case *ast.Ident:
continue if x.Name == "godog" && expr.Sel.Name == "Suite" {
} b.Contexts = append(b.Contexts, fun.Name.Name)
if ident.Name == "godog.Suite" || f.Name.Name == "godog" && ident.Name == "Suite" { }
b.Contexts = append(b.Contexts, fun.Name.Name) }
case *ast.Ident:
if expr.Name == "Suite" {
b.Contexts = append(b.Contexts, fun.Name.Name)
}
}
} }
} }
} }

Просмотреть файл

@ -1,7 +1,6 @@
package godog package godog
import ( import (
"flag"
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
@ -17,12 +16,6 @@ type config struct {
formatterName string formatterName string
} }
func init() {
// @TODO: colorize flag help output
flag.StringVar(&cfg.featuresPath, "features", "features", "Path to feature files")
flag.StringVar(&cfg.formatterName, "formatter", "pretty", "Formatter name")
}
func (c config) validate() error { func (c config) validate() error {
inf, err := os.Stat(c.featuresPath) inf, err := os.Stat(c.featuresPath)
if err != nil { if err != nil {

Просмотреть файл

@ -49,6 +49,9 @@ type suite struct {
// interface. The instance is passed around to all // interface. The instance is passed around to all
// context initialization functions from *_test.go files // context initialization functions from *_test.go files
func New() *suite { func New() *suite {
// @TODO: colorize flag help output
flag.StringVar(&cfg.featuresPath, "features", "features", "Path to feature files")
flag.StringVar(&cfg.formatterName, "formatter", "pretty", "Formatter name")
if !flag.Parsed() { if !flag.Parsed() {
flag.Parse() flag.Parse()
} }