Repository: cucumber/godog
Pull request #404 (2021-07-07 16:17:22)

Fix tests and CircleCI jobs
<!--- Provide a general summary of your changes in the Title above -->

# Description

Current `main` fails CI jobs since recent merges.

# Motivation & context

This PR 
* addresses https://github.com/cucumber/godog/pull/402#issuecomment-874291502,
* applies `gofmt` formatting where missing,
* reverts minimal Go version back to 1.13 to align with CI images,
* fixes `go1.16` home directory configuration in CI,
* fixes obscure merge conflict where `MultiFormatter` was depending on obsolete (`v10` instead of `v16`) version of `messages-go`,
* fixes builder test with explicit `go mod tidy` to comply with [No automatic changes to go.mod and go.sum](https://blog.golang.org/go116-module-changes#TOC_3),
* removes parallelism in builder tests to avoid racy module updates.

## Type of change

<!--- Delete any options that are not relevant -->

- Refactoring/debt (improvement to code design or tooling without changing behaviour)

## Note to other contributors

No notes.

## Update required of cucumber.io/docs

Not required.

# Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I have read the [**CONTRIBUTING**](../CONTRIBUTING.md) document.
- [ ] I have added tests to cover my changes.
- [x] All new and existing tests passed.



Patch:
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 1890715..d6fb369 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -77,7 +77,7 @@ jobs:
     steps:
       - all
   go1_16:
-    working_directory: /go/src/github.com/cucumber/godog
+    working_directory: /home/circleci/go/src/github.com/cucumber/godog
     executor: exec_go_1_16
     steps:
       - all
diff --git a/_examples/custom-formatter/custom.go b/_examples/custom-formatter/custom.go
index 5c014b3..9e364c3 100644
--- a/_examples/custom-formatter/custom.go
+++ b/_examples/custom-formatter/custom.go
@@ -21,7 +21,7 @@ type customFmt struct {
 }
 
 func (f *customFmt) TestRunStarted()                                                   {}
-func (f *customFmt) Feature(*messages.GherkinDocument, string, []byte) {}
+func (f *customFmt) Feature(*messages.GherkinDocument, string, []byte)                 {}
 func (f *customFmt) Pickle(*godog.Scenario)                                            {}
 func (f *customFmt) Defined(*godog.Scenario, *godog.Step, *godog.StepDefinition)       {}
 func (f *customFmt) Passed(*godog.Scenario, *godog.Step, *godog.StepDefinition)        {}
diff --git a/_examples/custom-formatter/go.mod b/_examples/custom-formatter/go.mod
index 4dd6643..b46595f 100644
--- a/_examples/custom-formatter/go.mod
+++ b/_examples/custom-formatter/go.mod
@@ -3,6 +3,10 @@ module custom-formatter
 go 1.14
 
 require (
-	github.com/cucumber/godog v0.11.0
+	github.com/cucumber/gherkin-go/v11 v11.0.0 // indirect
+	github.com/cucumber/godog v0.10.1-0.20210705192606-df8c6e49b40b
+	github.com/cucumber/messages-go/v10 v10.0.3 // indirect
 	github.com/cucumber/messages-go/v16 v16.0.1
+	github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
+	github.com/hashicorp/go-memdb v1.3.2 // indirect
 )
diff --git a/_examples/custom-formatter/go.sum b/_examples/custom-formatter/go.sum
index 209eb52..57ee6fb 100644
--- a/_examples/custom-formatter/go.sum
+++ b/_examples/custom-formatter/go.sum
@@ -35,11 +35,18 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsr
 github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
 github.com/cucumber/gherkin-go/v11 v11.0.0 h1:cwVwN1Qn2VRSfHZNLEh5x00tPBmZcjATBWDpxsR5Xug=
 github.com/cucumber/gherkin-go/v11 v11.0.0/go.mod h1:CX33k2XU2qog4e+TFjOValoq6mIUq0DmVccZs238R9w=
+github.com/cucumber/gherkin-go/v19 v19.0.3 h1:mMSKu1077ffLbTJULUfM5HPokgeBcIGboyeNUof1MdE=
+github.com/cucumber/gherkin-go/v19 v19.0.3/go.mod h1:jY/NP6jUtRSArQQJ5h1FXOUgk5fZK24qtE7vKi776Vw=
+github.com/cucumber/godog v0.10.1-0.20210705192606-df8c6e49b40b h1:TthfOM7c3wz2M5kUvktCU27WXufvUSV/YtcxQk2yaq8=
+github.com/cucumber/godog v0.10.1-0.20210705192606-df8c6e49b40b/go.mod h1:ql2U1OH5nlLZ2UDD/3fDJ1+0vkib0XGgEn8NYXCwDZQ=
 github.com/cucumber/godog v0.11.0 h1:xgaWyJuAD6A+aW4TfVGNDBhuMyKW0jjl0cvY3KNxEak=
 github.com/cucumber/godog v0.11.0/go.mod h1:GyxCIrsg1sgEgpL2GD/rMr3fIoNHpgkjm9nANw/89XY=
 github.com/cucumber/messages-go/v10 v10.0.1/go.mod h1:kA5T38CBlBbYLU12TIrJ4fk4wSkVVOgyh7Enyy8WnSg=
-github.com/cucumber/messages-go/v10 v10.0.3 h1:m/9SD/K/A15WP7i1aemIv7cwvUw+viS51Ui5HBw1cdE=
 github.com/cucumber/messages-go/v10 v10.0.3/go.mod h1:9jMZ2Y8ZxjLY6TG2+x344nt5rXstVVDYSdS5ySfI1WY=
+github.com/cucumber/messages-go/v16 v10.0.1/go.mod h1:kA5T38CBlBbYLU12TIrJ4fk4wSkVVOgyh7Enyy8WnSg=
+github.com/cucumber/messages-go/v16 v10.0.3 h1:m/9SD/K/A15WP7i1aemIv7cwvUw+viS51Ui5HBw1cdE=
+github.com/cucumber/messages-go/v16 v10.0.3/go.mod h1:9jMZ2Y8ZxjLY6TG2+x344nt5rXstVVDYSdS5ySfI1WY=
+github.com/cucumber/messages-go/v16 v16.0.0/go.mod h1:EJcyR5Mm5ZuDsKJnT2N9KRnBK30BGjtYotDKpwQ0v6g=
 github.com/cucumber/messages-go/v16 v16.0.1 h1:fvkpwsLgnIm0qugftrw2YwNlio+ABe2Iu94Ap8GMYIY=
 github.com/cucumber/messages-go/v16 v16.0.1/go.mod h1:EJcyR5Mm5ZuDsKJnT2N9KRnBK30BGjtYotDKpwQ0v6g=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -93,8 +100,12 @@ github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtng
 github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
 github.com/hashicorp/go-immutable-radix v1.3.0 h1:8exGP7ego3OmkfksihtSouGMZ+hQrhxx+FVELeXpVPE=
 github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
+github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc=
+github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
 github.com/hashicorp/go-memdb v1.3.0 h1:xdXq34gBOMEloa9rlGStLxmfX/dyIK8htOv36dQUwHU=
 github.com/hashicorp/go-memdb v1.3.0/go.mod h1:Mluclgwib3R93Hk5fxEfiRhB+6Dar64wWh71LpNSe3g=
+github.com/hashicorp/go-memdb v1.3.2 h1:RBKHOsnSszpU6vxq80LzC2BaQjuuvoyaQbkLTf7V7g8=
+github.com/hashicorp/go-memdb v1.3.2/go.mod h1:Mluclgwib3R93Hk5fxEfiRhB+6Dar64wWh71LpNSe3g=
 github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
 github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
 github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
diff --git a/go.mod b/go.mod
index 10dcceb..646ab05 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
 module github.com/cucumber/godog
 
-go 1.16
+go 1.13
 
 require (
 	github.com/cucumber/gherkin-go/v19 v19.0.3
diff --git a/internal/builder/builder.go b/internal/builder/builder.go
index 626e7bb..88ebd98 100644
--- a/internal/builder/builder.go
+++ b/internal/builder/builder.go
@@ -127,6 +127,10 @@ func Build(bin string) error {
 	// we also print back the temp WORK directory
 	// go has built. We will reuse it for our suite workdir.
 	temp := fmt.Sprintf(filepath.Join("%s", "temp-%d.test"), os.TempDir(), time.Now().UnixNano())
+	modTidyOutput, err := exec.Command("go", "mod", "tidy").CombinedOutput()
+	if err != nil {
+		return fmt.Errorf("failed to tidy modules in tested package: %s, reason: %v, output: %s", abs, err, string(modTidyOutput))
+	}
 	testOutput, err := exec.Command("go", "test", "-c", "-work", "-o", temp).CombinedOutput()
 	if err != nil {
 		return fmt.Errorf("failed to compile tested package: %s, reason: %v, output: %s", abs, err, string(testOutput))
diff --git a/internal/formatters/fmt_multi.go b/internal/formatters/fmt_multi.go
index a54c80a..aa206ff 100644
--- a/internal/formatters/fmt_multi.go
+++ b/internal/formatters/fmt_multi.go
@@ -5,7 +5,7 @@ import (
 
 	"github.com/cucumber/godog/formatters"
 	"github.com/cucumber/godog/internal/storage"
-	"github.com/cucumber/messages-go/v10"
+	"github.com/cucumber/messages-go/v16"
 )
 
 // MultiFormatter passes test progress to multiple formatters.
@@ -57,42 +57,42 @@ func (r repeater) Pickle(pickle *messages.Pickle) {
 }
 
 // Defined triggers Defined for all added formatters.
-func (r repeater) Defined(pickle *messages.Pickle, step *messages.Pickle_PickleStep, definition *formatters.StepDefinition) {
+func (r repeater) Defined(pickle *messages.Pickle, step *messages.PickleStep, definition *formatters.StepDefinition) {
 	for _, f := range r {
 		f.Defined(pickle, step, definition)
 	}
 }
 
 // Failed triggers Failed for all added formatters.
-func (r repeater) Failed(pickle *messages.Pickle, step *messages.Pickle_PickleStep, definition *formatters.StepDefinition, err error) {
+func (r repeater) Failed(pickle *messages.Pickle, step *messages.PickleStep, definition *formatters.StepDefinition, err error) {
 	for _, f := range r {
 		f.Failed(pickle, step, definition, err)
 	}
 }
 
 // Passed triggers Passed for all added formatters.
-func (r repeater) Passed(pickle *messages.Pickle, step *messages.Pickle_PickleStep, definition *formatters.StepDefinition) {
+func (r repeater) Passed(pickle *messages.Pickle, step *messages.PickleStep, definition *formatters.StepDefinition) {
 	for _, f := range r {
 		f.Passed(pickle, step, definition)
 	}
 }
 
 // Skipped triggers Skipped for all added formatters.
-func (r repeater) Skipped(pickle *messages.Pickle, step *messages.Pickle_PickleStep, definition *formatters.StepDefinition) {
+func (r repeater) Skipped(pickle *messages.Pickle, step *messages.PickleStep, definition *formatters.StepDefinition) {
 	for _, f := range r {
 		f.Skipped(pickle, step, definition)
 	}
 }
 
 // Undefined triggers Undefined for all added formatters.
-func (r repeater) Undefined(pickle *messages.Pickle, step *messages.Pickle_PickleStep, definition *formatters.StepDefinition) {
+func (r repeater) Undefined(pickle *messages.Pickle, step *messages.PickleStep, definition *formatters.StepDefinition) {
 	for _, f := range r {
 		f.Undefined(pickle, step, definition)
 	}
 }
 
 // Pending triggers Pending for all added formatters.
-func (r repeater) Pending(pickle *messages.Pickle, step *messages.Pickle_PickleStep, definition *formatters.StepDefinition) {
+func (r repeater) Pending(pickle *messages.Pickle, step *messages.PickleStep, definition *formatters.StepDefinition) {
 	for _, f := range r {
 		f.Pending(pickle, step, definition)
 	}
diff --git a/internal/models/feature.go b/internal/models/feature.go
index 1bf12b0..d38a224 100644
--- a/internal/models/feature.go
+++ b/internal/models/feature.go
@@ -38,7 +38,7 @@ func (f Feature) FindBackground(astScenarioID string) *messages.Background {
 		}
 	}
 
-	return bg
+	return nil
 }
 
 // FindExample ...


Test patch:
diff --git a/internal/builder/builder_test.go b/internal/builder/builder_test.go
index ce2a73d..8a2bfff 100644
--- a/internal/builder/builder_test.go
+++ b/internal/builder/builder_test.go
@@ -27,8 +27,6 @@ func Test_GodogBuild(t *testing.T) {
 	t.Run("WithVendoredGodogAndMod", testWithVendoredGodogAndMod)
 
 	t.Run("WithModule", func(t *testing.T) {
-		t.Parallel()
-
 		t.Run("OutsideGopathAndHavingOnlyFeature", testOutsideGopathAndHavingOnlyFeature)
 		t.Run("OutsideGopath", testOutsideGopath)
 		t.Run("OutsideGopathWithXTest", testOutsideGopathWithXTest)
@@ -302,8 +300,6 @@ type builderTestCase struct {
 }
 
 func (bt builderTestCase) run(t *testing.T) {
-	t.Parallel()
-
 	err := buildTestPackage(bt.dir, bt.files)
 	defer os.RemoveAll(bt.dir)
 	require.Nil(t, err)
diff --git a/run_test.go b/run_test.go
index 284af77..b94018b 100644
--- a/run_test.go
+++ b/run_test.go
@@ -350,7 +350,13 @@ func Test_FormatOutputRun(t *testing.T) {
 		noRandomFlag, []string{featurePath},
 	)
 
-	file := filepath.Join(t.TempDir(), "result.xml")
+	dir := filepath.Join(os.TempDir(), t.Name())
+	err := os.MkdirAll(dir, 0755)
+	require.NoError(t, err)
+
+	defer os.RemoveAll(dir)
+
+	file := filepath.Join(dir, "result.xml")
 
 	actualStatus, actualOutput := testRun(t,
 		fmtOutputScenarioInitializer,