From d4c6c236b19c11b7fa9fc1cabf55368fb79b8d37 Mon Sep 17 00:00:00 2001 From: Viacheslav Poturaev Date: Wed, 7 Jul 2021 18:12:11 +0200 Subject: [PATCH 1/9] Apply gofmt to fix CircleCI jobs --- _examples/custom-formatter/custom.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) {} From f34f37dfd21c413ac5fc174cc2f94f344ea12299 Mon Sep 17 00:00:00 2001 From: Viacheslav Poturaev Date: Wed, 7 Jul 2021 19:47:46 +0200 Subject: [PATCH 2/9] Upgrade MultiFormatter to use messages-go/v16 --- internal/formatters/fmt_multi.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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) } From ee7ab9c52b3b3ed48d88d923dc654a05a91917e8 Mon Sep 17 00:00:00 2001 From: Viacheslav Poturaev Date: Wed, 7 Jul 2021 19:48:47 +0200 Subject: [PATCH 3/9] Fix example build by pinning untagged version of godog --- _examples/custom-formatter/go.mod | 6 +++++- _examples/custom-formatter/go.sum | 13 ++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) 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= From c6e9cd0e195371182db3ab1de9765a8b9779f623 Mon Sep 17 00:00:00 2001 From: Viacheslav Poturaev Date: Wed, 7 Jul 2021 20:12:56 +0200 Subject: [PATCH 4/9] Revert return logic to restore previous behavior and pass the original test --- internal/models/feature.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ... From 8af91e50f6b223e7c2aacf771d868b4a11fc7d45 Mon Sep 17 00:00:00 2001 From: Viacheslav Poturaev Date: Wed, 7 Jul 2021 20:22:32 +0200 Subject: [PATCH 5/9] Revert minimal Go version to 1.13 --- go.mod | 2 +- run_test.go | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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/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, From f42c85989f257ad0b2cd233bb6e33b658f93a859 Mon Sep 17 00:00:00 2001 From: Viacheslav Poturaev Date: Wed, 7 Jul 2021 20:32:50 +0200 Subject: [PATCH 6/9] Fix home directory for cimg/go:1.16.5 CI image --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From bd397253a4800e05ca9add513c8bca008248c98f Mon Sep 17 00:00:00 2001 From: Viacheslav Poturaev Date: Wed, 7 Jul 2021 20:45:51 +0200 Subject: [PATCH 7/9] Run "go mod tidy" during build to comply with https://blog.golang.org/go116-module-changes#TOC_3. --- internal/builder/builder.go | 4 ++++ 1 file changed, 4 insertions(+) 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)) From 15ab3cd84f834ecefc1ff57a4c022683023e685b Mon Sep 17 00:00:00 2001 From: Viacheslav Poturaev Date: Wed, 7 Jul 2021 21:01:26 +0200 Subject: [PATCH 8/9] Remove parallel testing to avoid "go: updating go.mod: existing contents have changed since last read" --- internal/builder/builder_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/builder/builder_test.go b/internal/builder/builder_test.go index ce2a73d..b5f7eb0 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) From 885805bfd3eda4a23077dea105135e7a98adf21b Mon Sep 17 00:00:00 2001 From: Viacheslav Poturaev Date: Wed, 7 Jul 2021 21:06:13 +0200 Subject: [PATCH 9/9] Remove parallel testing to avoid "go: updating go.mod: existing contents have changed since last read" --- internal/builder/builder_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/builder/builder_test.go b/internal/builder/builder_test.go index b5f7eb0..8a2bfff 100644 --- a/internal/builder/builder_test.go +++ b/internal/builder/builder_test.go @@ -300,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)