diff --git a/builder_go110.go b/builder_go110.go index c4ae376..29bbbab 100644 --- a/builder_go110.go +++ b/builder_go110.go @@ -19,16 +19,15 @@ import ( "unicode" ) -var tooldir = findToolDir() -var compiler = filepath.Join(tooldir, "compile") -var linker = filepath.Join(tooldir, "link") -var gopaths = filepath.SplitList(build.Default.GOPATH) -var goarch = build.Default.GOARCH -var goroot = build.Default.GOROOT -var goos = build.Default.GOOS +var ( + tooldir = findToolDir() + compiler = filepath.Join(tooldir, "compile") + linker = filepath.Join(tooldir, "link") + gopaths = filepath.SplitList(build.Default.GOPATH) + godogImportPath = "github.com/DATA-DOG/godog" -var godogImportPath = "github.com/DATA-DOG/godog" -var runnerTemplate = template.Must(template.New("testmain").Parse(`package main + // godep + runnerTemplate = template.Must(template.New("testmain").Parse(`package main import ( "github.com/DATA-DOG/godog" @@ -45,6 +44,7 @@ func main() { }) os.Exit(status) }`)) +) // Build creates a test package like go test command at given target path. // If there are no go files in tested directory, then @@ -299,17 +299,6 @@ func makeImportValid(r rune) rune { return r } -func uniqStringList(strs []string) (unique []string) { - uniq := make(map[string]void, len(strs)) - for _, s := range strs { - if _, ok := uniq[s]; !ok { - uniq[s] = void{} - unique = append(unique, s) - } - } - return -} - // buildTestMain if given package is valid // it scans test files for contexts // and produces a testmain source code. diff --git a/builder_test.go b/builder_test.go index 4a1c5ac..820dd66 100644 --- a/builder_test.go +++ b/builder_test.go @@ -27,7 +27,7 @@ func TestBuildTestRunnerWithoutGoFiles(t *testing.T) { } defer func() { - os.Chdir(pwd) // get back to current dir + _ = os.Chdir(pwd) // get back to current dir }() if err := Build(bin); err != nil { diff --git a/cmd/godog/main.go b/cmd/godog/main.go index f409d07..5e1c97f 100644 --- a/cmd/godog/main.go +++ b/cmd/godog/main.go @@ -3,12 +3,10 @@ package main import ( "fmt" "go/build" - "io" "os" "os/exec" "path/filepath" "regexp" - "strconv" "syscall" "github.com/DATA-DOG/godog" @@ -107,20 +105,3 @@ func main() { } os.Exit(status) } - -func statusOutputFilter(w io.Writer) io.Writer { - return writerFunc(func(b []byte) (int, error) { - if m := statusMatch.FindStringSubmatch(string(b)); len(m) > 1 { - parsedStatus, _ = strconv.Atoi(m[1]) - // skip status stderr output - return len(b), nil - } - return w.Write(b) - }) -} - -type writerFunc func([]byte) (int, error) - -func (w writerFunc) Write(b []byte) (int, error) { - return w(b) -} diff --git a/fmt.go b/fmt.go index fdaf0ac..57d1297 100644 --- a/fmt.go +++ b/fmt.go @@ -381,9 +381,11 @@ func (f *basefmt) Summary() { } func (s *undefinedSnippet) Args() (ret string) { - var args []string - var pos, idx int - var breakLoop bool + var ( + args []string + pos int + breakLoop bool + ) for !breakLoop { part := s.Expr[pos:] ipos := strings.Index(part, "(\\d+)") @@ -392,25 +394,20 @@ func (s *undefinedSnippet) Args() (ret string) { case spos == -1 && ipos == -1: breakLoop = true case spos == -1: - idx++ pos += ipos + len("(\\d+)") args = append(args, reflect.Int.String()) case ipos == -1: - idx++ pos += spos + len("\"([^\"]*)\"") args = append(args, reflect.String.String()) case ipos < spos: - idx++ pos += ipos + len("(\\d+)") args = append(args, reflect.Int.String()) case spos < ipos: - idx++ pos += spos + len("\"([^\"]*)\"") args = append(args, reflect.String.String()) } } if s.argument != nil { - idx++ switch s.argument.(type) { case *gherkin.DocString: args = append(args, "*gherkin.DocString") diff --git a/fmt_cucumber.go b/fmt_cucumber.go index 19897ef..cbfe30d 100644 --- a/fmt_cucumber.go +++ b/fmt_cucumber.go @@ -109,15 +109,14 @@ type cukefmt struct { // this is sadly not passed by gherkin nodes. // it restricts this formatter to run only in synchronous single // threaded execution. Unless running a copy of formatter for each feature - path string - stat stepType // last step status, before skipped - outlineSteps int // number of current outline scenario steps - ID string // current test id. - results []cukeFeatureJSON // structure that represent cuke results - curStep *cukeStep // track the current step - curElement *cukeElement // track the current element - curFeature *cukeFeatureJSON // track the current feature - curOutline cukeElement // Each example show up as an outline element but the outline is parsed only once + path string + stat stepType // last step status, before skipped + ID string // current test id. + results []cukeFeatureJSON // structure that represent cuke results + curStep *cukeStep // track the current step + curElement *cukeElement // track the current element + curFeature *cukeFeatureJSON // track the current feature + curOutline cukeElement // Each example show up as an outline element but the outline is parsed only once // so I need to keep track of the current outline curRow int // current row of the example table as it is being processed. curExampleTags []cukeTag // temporary storage for tags associate with the current example table. diff --git a/suite.go b/suite.go index 643e172..7cf8619 100644 --- a/suite.go +++ b/suite.go @@ -402,12 +402,6 @@ func (s *Suite) runSteps(steps []*gherkin.Step) (err error) { return } -func (s *Suite) skipSteps(steps []*gherkin.Step) { - for _, step := range steps { - s.fmt.Skipped(step, s.matchStep(step)) - } -} - func (s *Suite) runOutline(outline *gherkin.ScenarioOutline, b *gherkin.Background) (failErr error) { s.fmt.Node(outline)