Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrated to github.com/cucumber/gherkin-go - v9.2.0 #240

Merged
merged 14 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ commands:
description: "Run go vet"
steps:
- run: go vet github.com/cucumber/godog
- run: go vet github.com/cucumber/godog/gherkin
- run: go vet github.com/cucumber/godog/colors
fmt:
description: "Run go fmt"
Expand Down
8 changes: 4 additions & 4 deletions _examples/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ need to store state within steps (a response), we should introduce a structure w
package main

import (
"github.com/cucumber/gherkin-go/v9"
"github.com/cucumber/godog"
"github.com/cucumber/godog/gherkin"
)

type apiFeature struct {
Expand All @@ -71,7 +71,7 @@ func (a *apiFeature) theResponseCodeShouldBe(code int) error {
return godog.ErrPending
}

func (a *apiFeature) theResponseShouldMatchJSON(body *gherkin.DocString) error {
func (a *apiFeature) theResponseShouldMatchJSON(body *messages.PickleStepArgument_PickleDocString) error {
return godog.ErrPending
}

Expand All @@ -98,8 +98,8 @@ import (
"net/http"
"net/http/httptest"

"github.com/cucumber/gherkin-go/v9"
"github.com/cucumber/godog"
"github.com/cucumber/godog/gherkin"
)

type apiFeature struct {
Expand Down Expand Up @@ -142,7 +142,7 @@ func (a *apiFeature) theResponseCodeShouldBe(code int) error {
return nil
}

func (a *apiFeature) theResponseShouldMatchJSON(body *gherkin.DocString) (err error) {
func (a *apiFeature) theResponseShouldMatchJSON(body *messages.PickleStepArgument_PickleDocString) error {
var expected, actual []byte
var data interface{}
if err = json.Unmarshal([]byte(body.Content), &data); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions _examples/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (
"reflect"

"github.com/cucumber/godog"
"github.com/cucumber/godog/gherkin"
"github.com/cucumber/messages-go/v9"
)

type apiFeature struct {
resp *httptest.ResponseRecorder
}

func (a *apiFeature) resetResponse(interface{}) {
func (a *apiFeature) resetResponse(*messages.Pickle) {
a.resp = httptest.NewRecorder()
}

Expand Down Expand Up @@ -51,7 +51,7 @@ func (a *apiFeature) theResponseCodeShouldBe(code int) error {
return nil
}

func (a *apiFeature) theResponseShouldMatchJSON(body *gherkin.DocString) (err error) {
func (a *apiFeature) theResponseShouldMatchJSON(body *messages.PickleStepArgument_PickleDocString) (err error) {
var expected, actual interface{}

// re-encode expected response
Expand Down
6 changes: 3 additions & 3 deletions _examples/db/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

txdb "github.com/DATA-DOG/go-txdb"
"github.com/cucumber/godog"
"github.com/cucumber/godog/gherkin"
"github.com/cucumber/messages-go/v9"
)

func init() {
Expand Down Expand Up @@ -71,7 +71,7 @@ func (a *apiFeature) theResponseCodeShouldBe(code int) error {
return nil
}

func (a *apiFeature) theResponseShouldMatchJSON(body *gherkin.DocString) (err error) {
func (a *apiFeature) theResponseShouldMatchJSON(body *messages.PickleStepArgument_PickleDocString) (err error) {
var expected, actual interface{}

// re-encode expected response
Expand All @@ -91,7 +91,7 @@ func (a *apiFeature) theResponseShouldMatchJSON(body *gherkin.DocString) (err er
return nil
}

func (a *apiFeature) thereAreUsers(users *gherkin.DataTable) error {
func (a *apiFeature) thereAreUsers(users *messages.PickleStepArgument_PickleTable) error {
var fields []string
var marks []string
head := users.Rows[0].Cells
Expand Down
3 changes: 2 additions & 1 deletion _examples/godogs/godogs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/cucumber/godog"
"github.com/cucumber/godog/colors"
messages "github.com/cucumber/messages-go/v9"
)

var opt = godog.Options{Output: colors.Colored(os.Stdout)}
Expand Down Expand Up @@ -56,7 +57,7 @@ func FeatureContext(s *godog.Suite) {
s.Step(`^I eat (\d+)$`, iEat)
s.Step(`^there should be (\d+) remaining$`, thereShouldBeRemaining)

s.BeforeScenario(func(interface{}) {
s.BeforeScenario(func(*messages.Pickle) {
Godogs = 0 // clean the state before every scenario
})
}
60 changes: 60 additions & 0 deletions builder_go112_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// +build go1.12
// +build !go1.13

package godog

import (
"bytes"
"os"
"path/filepath"
"testing"
)

func TestGodogBuildWithVendoredGodogAndMod(t *testing.T) {
gopath := filepath.Join(os.TempDir(), "_gpc")
dir := filepath.Join(gopath, "src", "godogs")
err := buildTestPackage(dir, map[string]string{
"godogs.feature": builderFeatureFile,
"godogs.go": builderMainCodeFile,
"godogs_test.go": builderTestFile,
"go.mod": builderModFile,
})
if err != nil {
os.RemoveAll(gopath)
t.Fatal(err)
}
defer os.RemoveAll(gopath)

pkg := filepath.Join(dir, "vendor", "github.com", "cucumber")
if err := os.MkdirAll(pkg, 0755); err != nil {
t.Fatal(err)
}

prevDir, err := os.Getwd()
if err != nil {
t.Fatal(err)
}

// symlink godog package
if err := os.Symlink(prevDir, filepath.Join(pkg, "godog")); err != nil {
t.Fatal(err)
}

if err := os.Chdir(dir); err != nil {
t.Fatal(err)
}
defer os.Chdir(prevDir)

cmd := buildTestCommand(t, "godogs.feature")

var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
cmd.Env = append(envVarsWithoutGopath(), "GOPATH="+gopath)

if err := cmd.Run(); err != nil {
t.Log(stdout.String())
t.Log(stderr.String())
t.Fatal(err)
}
}
54 changes: 54 additions & 0 deletions builder_go113_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// +build go1.13

package godog

import (
"bytes"
"os"
"os/exec"
"path/filepath"
"testing"
)

func TestGodogBuildWithVendoredGodogAndMod(t *testing.T) {
gopath := filepath.Join(os.TempDir(), "_gpc")
dir := filepath.Join(gopath, "src", "godogs")
err := buildTestPackage(dir, map[string]string{
"godogs.feature": builderFeatureFile,
"godogs.go": builderMainCodeFile,
"godogs_test.go": builderTestFile,
"go.mod": builderModFile,
})
if err != nil {
os.RemoveAll(gopath)
t.Fatal(err)
}
defer os.RemoveAll(gopath)

prevDir, err := os.Getwd()
if err != nil {
t.Fatal(err)
}

if err = exec.Command("go", "mod", "vendor").Run(); err != nil {
t.Fatal(err)
}

if err := os.Chdir(dir); err != nil {
t.Fatal(err)
}
defer os.Chdir(prevDir)

cmd := buildTestCommand(t, "godogs.feature")

var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
cmd.Env = append(envVarsWithoutGopath(), "GOPATH="+gopath)

if err := cmd.Run(); err != nil {
t.Log(stdout.String())
t.Log(stderr.String())
t.Fatal(err)
}
}
49 changes: 0 additions & 49 deletions builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,55 +310,6 @@ func TestGodogBuildWithinGopath(t *testing.T) {
}
}

func TestGodogBuildWithVendoredGodogAndMod(t *testing.T) {
gopath := filepath.Join(os.TempDir(), "_gpc")
dir := filepath.Join(gopath, "src", "godogs")
err := buildTestPackage(dir, map[string]string{
"godogs.feature": builderFeatureFile,
"godogs.go": builderMainCodeFile,
"godogs_test.go": builderTestFile,
"go.mod": builderModFile,
})
if err != nil {
os.RemoveAll(gopath)
t.Fatal(err)
}
defer os.RemoveAll(gopath)

pkg := filepath.Join(dir, "vendor", "github.com", "cucumber")
if err := os.MkdirAll(pkg, 0755); err != nil {
t.Fatal(err)
}

prevDir, err := os.Getwd()
if err != nil {
t.Fatal(err)
}

// symlink godog package
if err := os.Symlink(prevDir, filepath.Join(pkg, "godog")); err != nil {
t.Fatal(err)
}

if err := os.Chdir(dir); err != nil {
t.Fatal(err)
}
defer os.Chdir(prevDir)

cmd := buildTestCommand(t, "godogs.feature")

var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
cmd.Env = append(envVarsWithoutGopath(), "GOPATH="+gopath)

if err := cmd.Run(); err != nil {
t.Log(stdout.String())
t.Log(stderr.String())
t.Fatal(err)
}
}

func TestGodogBuildWithVendoredGodogWithoutModule(t *testing.T) {
gopath := filepath.Join(os.TempDir(), "_gp")
dir := filepath.Join(gopath, "src", "godogs")
Expand Down
2 changes: 1 addition & 1 deletion color_tag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (cw *tagColorWriter) Write(p []byte) (int, error) {
}

if cw.state == outsideCsiCode {
nw, err = cw.w.Write(p[first:len(p)])
nw, err = cw.w.Write(p[first:])
r += nw
}

Expand Down
2 changes: 1 addition & 1 deletion colors/ansi_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ func (cw *ansiColorWriter) Write(p []byte) (int, error) {
}

if cw.mode != discardNonColorEscSeq || cw.state == outsideCsiCode {
nw, err = cw.w.Write(p[first:len(p)])
nw, err = cw.w.Write(p[first:])
r += nw
}

Expand Down
14 changes: 7 additions & 7 deletions features/formatter/cucumber.feature
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ Feature: cucumber json formatter
"name": "passing step",
"line": 7,
"match": {
"location": "suite_context.go:64"
"location": "suite_context.go:0"
},
"result": {
"status": "passed",
Expand All @@ -269,7 +269,7 @@ Feature: cucumber json formatter
"name": "a failing step",
"line": 8,
"match": {
"location": "suite_context.go:47"
"location": "suite_context.go:0"
},
"result": {
"status": "failed",
Expand Down Expand Up @@ -325,7 +325,7 @@ Feature: cucumber json formatter
"name": "passing step",
"line": 11,
"match": {
"location": "suite_context.go:64"
"location": "suite_context.go:0"
},
"result": {
"status": "passed",
Expand All @@ -347,7 +347,7 @@ Feature: cucumber json formatter
"name": "failing step",
"line": 12,
"match": {
"location": "suite_context.go:47"
"location": "suite_context.go:0"
},
"result": {
"status": "failed",
Expand Down Expand Up @@ -448,7 +448,7 @@ Feature: cucumber json formatter
"line": 8
},
"match": {
"location": "suite_context.go:64"
"location": "suite_context.go:0"
},
"result": {
"status": "passed",
Expand Down Expand Up @@ -501,7 +501,7 @@ Feature: cucumber json formatter
"name": "passing step",
"line": 7,
"match": {
"location": "suite_context.go:64"
"location": "suite_context.go:0"
},
"result": {
"status": "passed",
Expand Down Expand Up @@ -535,7 +535,7 @@ Feature: cucumber json formatter
"name": "passing step",
"line": 10,
"match": {
"location": "suite_context.go:64"
"location": "suite_context.go:0"
},
"result": {
"status": "skipped"
Expand Down
2 changes: 1 addition & 1 deletion features/load.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Feature: load features
| feature | number |
| features/load.feature:3 | 0 |
| features/load.feature:6 | 1 |
| features/load.feature | 4 |
| features/load.feature | 6 |

Scenario: load a number of feature files
Given a feature path "features/load.feature"
Expand Down
2 changes: 1 addition & 1 deletion features/snippets.feature
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Feature: undefined step snippets
When I run feature suite
Then the undefined step snippets should be:
"""
func iSendRequestToWith(arg1, arg2 string, arg3 *gherkin.DataTable) error {
func iSendRequestToWith(arg1, arg2 string, arg3 *messages.PickleStepArgument_PickleTable) error {
return godog.ErrPending
}

Expand Down
Loading