From b398ce80662a813934db45d74c932624611045d9 Mon Sep 17 00:00:00 2001 From: Gavin Taylor Date: Tue, 3 Mar 2020 18:12:19 +0000 Subject: [PATCH 1/7] Normalise module paths for use on Windows too --- builder_go110.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/builder_go110.go b/builder_go110.go index cf8f0cb..9702a29 100644 --- a/builder_go110.go +++ b/builder_go110.go @@ -238,6 +238,9 @@ func maybeVendoredGodog() *build.Package { return nil } +func normaliseLocalImportPath(dir string) string { + return path.Join("_", strings.Map(makeImportValid, filepath.ToSlash(dir))) +} func importPackage(dir string) *build.Package { pkg, _ := build.ImportDir(dir, 0) @@ -245,7 +248,7 @@ func importPackage(dir string) *build.Package { // taken from go source code // see: https://github.com/golang/go/blob/go1.7rc5/src/cmd/go/pkg.go#L279 if pkg != nil && pkg.ImportPath == "." { - pkg.ImportPath = path.Join("_", strings.Map(makeImportValid, filepath.ToSlash(dir))) + pkg.ImportPath = normaliseLocalImportPath(dir) } return pkg @@ -376,7 +379,7 @@ func parseImport(rawPath, rootPath string) string { return rawPath } // Concatenates the module path with the current sub-folders if needed - return mod.Path + filepath.ToSlash(strings.TrimPrefix(strings.TrimPrefix(rawPath, "_"), mod.Dir)) + return mod.Path + filepath.ToSlash(strings.TrimPrefix(rawPath, normaliseLocalImportPath(mod.Dir))) } // processPackageTestFiles runs through ast of each test From cc861097ae40fabb4f0e559429a0e9a2dd4f673e Mon Sep 17 00:00:00 2001 From: Jayson Smith Date: Wed, 4 Mar 2020 21:53:10 -0700 Subject: [PATCH 2/7] Add suite_test.go back --- go.mod | 6 +++++- go.sum | 4 ++++ suite_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 suite_test.go diff --git a/go.mod b/go.mod index 7fcdb3a..2924270 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,8 @@ module github.com/cucumber/godog go 1.13 -require github.com/stretchr/testify v1.4.0 +require ( + github.com/DATA-DOG/go-txdb v0.1.3 + github.com/go-sql-driver/mysql v1.5.0 + github.com/stretchr/testify v1.4.0 +) diff --git a/go.sum b/go.sum index 8fdee58..77d1d3f 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,9 @@ +github.com/DATA-DOG/go-txdb v0.1.3 h1:R4v6OuOcy2O147e2zHxU0B4NDtF+INb5R9q/CV7AEMg= +github.com/DATA-DOG/go-txdb v0.1.3/go.mod h1:DhAhxMXZpUJVGnT+p9IbzJoRKvlArO2pkHjnGX7o0n0= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/suite_test.go b/suite_test.go new file mode 100644 index 0000000..aabffe4 --- /dev/null +++ b/suite_test.go @@ -0,0 +1,46 @@ +package godog + +import ( + "os" + "strings" + "testing" + "time" +) + +func TestMain(m *testing.M) { + format := "progress" // non verbose mode + concurrency := 4 + + var specific bool + for _, arg := range os.Args[1:] { + if arg == "-test.v=true" { // go test transforms -v option - verbose mode + format = "pretty" + concurrency = 1 + break + } + if strings.Index(arg, "-test.run") == 0 { + specific = true + } + } + var status int + if !specific { + status = RunWithOptions("godog", func(s *Suite) { + GodogContext(s) + }, Options{ + Format: format, // pretty format for verbose mode, otherwise - progress + Paths: []string{"features"}, + Concurrency: concurrency, // concurrency for verbose mode is 1 + Randomize: time.Now().UnixNano(), // randomize scenario execution order + }) + } + + if st := m.Run(); st > status { + status = st + } + os.Exit(status) +} + +// needed in order to use godog cli +func GodogContext(s *Suite) { + SuiteContext(s) +} From e57711c730c4d84865b97b390a875a2357154aa2 Mon Sep 17 00:00:00 2001 From: Jayson Smith Date: Wed, 4 Mar 2020 21:53:55 -0700 Subject: [PATCH 3/7] Run godog features in Circle with strict --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7cf2960..fa800ff 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,7 +39,7 @@ commands: description: "Run godog" steps: - run: go install ./cmd/godog - - run: godog -f progress + - run: godog -f progress --strict go_test: description: "Run go test" steps: From 31974c50288c0142f68631358d0da3956025170c Mon Sep 17 00:00:00 2001 From: Jayson Smith Date: Wed, 4 Mar 2020 21:59:41 -0700 Subject: [PATCH 4/7] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cd6985..beec873 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,13 +14,17 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt ### Changed +- Run godog features in CircleCI in strict mode ([jaysonesmith]) + ### Deprecated ### Removed ### Fixed + - Fixed the time attributes in the JUnit formatter. ([232](https://github.com/cucumber/godog/pull/232) [lonnblad]) - Re enable custom formatters. ([238](https://github.com/cucumber/godog/pull/238) [ericmcbride]) +- Added back suite_test.go ([jaysonesmith]) ## [0.8.1] From d05c3fbe58c1280f485f23495a20c95b938cec33 Mon Sep 17 00:00:00 2001 From: Jayson Smith Date: Wed, 4 Mar 2020 22:14:02 -0700 Subject: [PATCH 5/7] Update README.md Removed maintainer alert, issue is closed --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 9a831fd..72f7dc8 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,6 @@ # Godog -[🚨🚨🚨 Godog is looking for new maintainers 🚨🚨🚨](https://github.com/cucumber/godog/issues/207) -

Godog logo

**The API is likely to change a few times before we reach 1.0.0** From b35fc94fa55a0e02cb2416f9c450b91b8a936e69 Mon Sep 17 00:00:00 2001 From: Jayson Smith Date: Wed, 4 Mar 2020 22:16:20 -0700 Subject: [PATCH 6/7] Remove TestMain call --- suite_test.go | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/suite_test.go b/suite_test.go index aabffe4..9d2f71d 100644 --- a/suite_test.go +++ b/suite_test.go @@ -1,45 +1,5 @@ package godog -import ( - "os" - "strings" - "testing" - "time" -) - -func TestMain(m *testing.M) { - format := "progress" // non verbose mode - concurrency := 4 - - var specific bool - for _, arg := range os.Args[1:] { - if arg == "-test.v=true" { // go test transforms -v option - verbose mode - format = "pretty" - concurrency = 1 - break - } - if strings.Index(arg, "-test.run") == 0 { - specific = true - } - } - var status int - if !specific { - status = RunWithOptions("godog", func(s *Suite) { - GodogContext(s) - }, Options{ - Format: format, // pretty format for verbose mode, otherwise - progress - Paths: []string{"features"}, - Concurrency: concurrency, // concurrency for verbose mode is 1 - Randomize: time.Now().UnixNano(), // randomize scenario execution order - }) - } - - if st := m.Run(); st > status { - status = st - } - os.Exit(status) -} - // needed in order to use godog cli func GodogContext(s *Suite) { SuiteContext(s) From ee20061a4692fbf67e1d74c56a765538a1c71315 Mon Sep 17 00:00:00 2001 From: Jayson Smith Date: Wed, 4 Mar 2020 22:20:48 -0700 Subject: [PATCH 7/7] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index beec873..f7a1ccb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt ### Changed - Run godog features in CircleCI in strict mode ([jaysonesmith]) +- Removed TestMain call in `suite_test.go` for CI. ([jaysonesmith]) ### Deprecated