Этот коммит содержится в:
hgouchet 2018-09-29 00:10:55 +02:00
родитель 5c352074bc
коммит 5bd9dce5d6
6 изменённых файлов: 23 добавлений и 63 удалений

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

@ -19,16 +19,15 @@ import (
"unicode" "unicode"
) )
var tooldir = findToolDir() var (
var compiler = filepath.Join(tooldir, "compile") tooldir = findToolDir()
var linker = filepath.Join(tooldir, "link") compiler = filepath.Join(tooldir, "compile")
var gopaths = filepath.SplitList(build.Default.GOPATH) linker = filepath.Join(tooldir, "link")
var goarch = build.Default.GOARCH gopaths = filepath.SplitList(build.Default.GOPATH)
var goroot = build.Default.GOROOT godogImportPath = "github.com/DATA-DOG/godog"
var goos = build.Default.GOOS
var godogImportPath = "github.com/DATA-DOG/godog" // godep
var runnerTemplate = template.Must(template.New("testmain").Parse(`package main runnerTemplate = template.Must(template.New("testmain").Parse(`package main
import ( import (
"github.com/DATA-DOG/godog" "github.com/DATA-DOG/godog"
@ -45,6 +44,7 @@ func main() {
}) })
os.Exit(status) os.Exit(status)
}`)) }`))
)
// Build creates a test package like go test command at given target path. // Build creates a test package like go test command at given target path.
// If there are no go files in tested directory, then // If there are no go files in tested directory, then
@ -299,17 +299,6 @@ func makeImportValid(r rune) rune {
return r 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 // buildTestMain if given package is valid
// it scans test files for contexts // it scans test files for contexts
// and produces a testmain source code. // and produces a testmain source code.

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

@ -27,7 +27,7 @@ func TestBuildTestRunnerWithoutGoFiles(t *testing.T) {
} }
defer func() { defer func() {
os.Chdir(pwd) // get back to current dir _ = os.Chdir(pwd) // get back to current dir
}() }()
if err := Build(bin); err != nil { if err := Build(bin); err != nil {

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

@ -3,12 +3,10 @@ package main
import ( import (
"fmt" "fmt"
"go/build" "go/build"
"io"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"regexp" "regexp"
"strconv"
"syscall" "syscall"
"github.com/DATA-DOG/godog" "github.com/DATA-DOG/godog"
@ -107,20 +105,3 @@ func main() {
} }
os.Exit(status) 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)
}

13
fmt.go
Просмотреть файл

@ -381,9 +381,11 @@ func (f *basefmt) Summary() {
} }
func (s *undefinedSnippet) Args() (ret string) { func (s *undefinedSnippet) Args() (ret string) {
var args []string var (
var pos, idx int args []string
var breakLoop bool pos int
breakLoop bool
)
for !breakLoop { for !breakLoop {
part := s.Expr[pos:] part := s.Expr[pos:]
ipos := strings.Index(part, "(\\d+)") ipos := strings.Index(part, "(\\d+)")
@ -392,25 +394,20 @@ func (s *undefinedSnippet) Args() (ret string) {
case spos == -1 && ipos == -1: case spos == -1 && ipos == -1:
breakLoop = true breakLoop = true
case spos == -1: case spos == -1:
idx++
pos += ipos + len("(\\d+)") pos += ipos + len("(\\d+)")
args = append(args, reflect.Int.String()) args = append(args, reflect.Int.String())
case ipos == -1: case ipos == -1:
idx++
pos += spos + len("\"([^\"]*)\"") pos += spos + len("\"([^\"]*)\"")
args = append(args, reflect.String.String()) args = append(args, reflect.String.String())
case ipos < spos: case ipos < spos:
idx++
pos += ipos + len("(\\d+)") pos += ipos + len("(\\d+)")
args = append(args, reflect.Int.String()) args = append(args, reflect.Int.String())
case spos < ipos: case spos < ipos:
idx++
pos += spos + len("\"([^\"]*)\"") pos += spos + len("\"([^\"]*)\"")
args = append(args, reflect.String.String()) args = append(args, reflect.String.String())
} }
} }
if s.argument != nil { if s.argument != nil {
idx++
switch s.argument.(type) { switch s.argument.(type) {
case *gherkin.DocString: case *gherkin.DocString:
args = append(args, "*gherkin.DocString") args = append(args, "*gherkin.DocString")

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

@ -109,15 +109,14 @@ type cukefmt struct {
// this is sadly not passed by gherkin nodes. // this is sadly not passed by gherkin nodes.
// it restricts this formatter to run only in synchronous single // it restricts this formatter to run only in synchronous single
// threaded execution. Unless running a copy of formatter for each feature // threaded execution. Unless running a copy of formatter for each feature
path string path string
stat stepType // last step status, before skipped stat stepType // last step status, before skipped
outlineSteps int // number of current outline scenario steps ID string // current test id.
ID string // current test id. results []cukeFeatureJSON // structure that represent cuke results
results []cukeFeatureJSON // structure that represent cuke results curStep *cukeStep // track the current step
curStep *cukeStep // track the current step curElement *cukeElement // track the current element
curElement *cukeElement // track the current element curFeature *cukeFeatureJSON // track the current feature
curFeature *cukeFeatureJSON // track the current feature curOutline cukeElement // Each example show up as an outline element but the outline is parsed only once
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 // so I need to keep track of the current outline
curRow int // current row of the example table as it is being processed. 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. curExampleTags []cukeTag // temporary storage for tags associate with the current example table.

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

@ -402,12 +402,6 @@ func (s *Suite) runSteps(steps []*gherkin.Step) (err error) {
return 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) { func (s *Suite) runOutline(outline *gherkin.ScenarioOutline, b *gherkin.Background) (failErr error) {
s.fmt.Node(outline) s.fmt.Node(outline)