diff -Nru golang-ginkgo-1.12.0/CHANGELOG.md golang-ginkgo-1.14.2/CHANGELOG.md --- golang-ginkgo-1.12.0/CHANGELOG.md 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/CHANGELOG.md 2020-10-12 17:59:23.000000000 +0000 @@ -1,3 +1,64 @@ +## 1.14.2 + +### Fixes +- correct handling windows backslash in import path (#721) [97f3d51] +- Add additional methods to GinkgoT() to improve compatibility with the testing.TB interface [b5fe44d] + +## 1.14.1 + +### Fixes +- Discard exported method declaration when running ginkgo bootstrap (#558) [f4b0240] + +## 1.14.0 + +### Features +- Defer running top-level container nodes until RunSpecs is called [d44dedf] +- [Document Ginkgo lifecycle](http://onsi.github.io/ginkgo/#understanding-ginkgos-lifecycle) +- Add `extensions/globals` package (#692) [3295c8f] - this can be helpful in contexts where you are test-driving your test-generation code (see [#692](https://github.com/onsi/ginkgo/pull/692)) +- Print Skip reason in JUnit reporter if one was provided [820dfab] + +## 1.13.0 + +### Features +- Add a version of table.Entry that allows dumping the entry parameters. (#689) [21eaef2] + +### Fixes +- Ensure integration tests pass in an environment sans GOPATH [606fba2] +- Add books package (#568) [fc0e44e] +- doc(readme): installation via "tools package" (#677) [83bb20e] +- Solve the undefined: unix.Dup2 compile error on mips64le (#680) [0624f75] +- Import package without dot (#687) [6321024] +- Fix integration tests to stop require GOPATH (#686) [a912ec5] + +## 1.12.3 + +### Fixes +- Print correct code location of failing table test (#666) [c6d7afb] + +## 1.12.2 + +### Fixes +- Update dependencies [ea4a036] + +## 1.12.1 + +### Fixes +- Make unfocus ("blur") much faster (#674) [8b18061] +- Fix typo (#673) [7fdcbe8] +- Test against 1.14 and remove 1.12 [d5c2ad6] +- Test if a coverprofile content is empty before checking its latest character (#670) [14d9fa2] +- replace tail package with maintained one. this fixes go get errors (#667) [4ba33d4] +- improve ginkgo performance - makes progress on #644 [a14f98e] +- fix convert integration tests [1f8ba69] +- fix typo succesful -> successful (#663) [1ea49cf] +- Fix invalid link (#658) [b886136] +- convert utility : Include comments from source (#657) [1077c6d] +- Explain what BDD means [d79e7fb] +- skip race detector test on unsupported platform (#642) [f8ab89d] +- Use Dup2 from golang.org/x/sys/unix instead of syscallDup (#638) [5d53c55] +- Fix missing newline in combined coverage file (#641) [6a07ea2] +- check if a spec is run before returning SpecSummary (#645) [8850000] + ## 1.12.0 ### Features @@ -208,7 +269,7 @@ - `ginkgo -tags=TAG_LIST` passes a list of tags down to the `go build` command. - `ginkgo --failFast` aborts the test suite after the first failure. - `ginkgo generate file_1 file_2` can take multiple file arguments. -- Ginkgo now summarizes any spec failures that occured at the end of the test run. +- Ginkgo now summarizes any spec failures that occurred at the end of the test run. - `ginkgo --randomizeSuites` will run tests *suites* in random order using the generated/passed-in seed. Improvements: diff -Nru golang-ginkgo-1.12.0/config/config.go golang-ginkgo-1.14.2/config/config.go --- golang-ginkgo-1.12.0/config/config.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/config/config.go 2020-10-12 17:59:23.000000000 +0000 @@ -1,7 +1,7 @@ /* Ginkgo accepts a number of configuration options. -These are documented [here](http://onsi.github.io/ginkgo/#the_ginkgo_cli) +These are documented [here](http://onsi.github.io/ginkgo/#the-ginkgo-cli) You can also learn more via @@ -20,7 +20,7 @@ "fmt" ) -const VERSION = "1.12.0" +const VERSION = "1.14.2" type GinkgoConfigType struct { RandomSeed int64 diff -Nru golang-ginkgo-1.12.0/debian/changelog golang-ginkgo-1.14.2/debian/changelog --- golang-ginkgo-1.12.0/debian/changelog 2020-11-11 22:09:58.000000000 +0000 +++ golang-ginkgo-1.14.2/debian/changelog 2020-11-22 12:00:04.000000000 +0000 @@ -1,14 +1,24 @@ -golang-ginkgo (1.12.0-7build2) hirsute; urgency=medium +golang-ginkgo (1.14.2-1) unstable; urgency=medium - * No-change rebuild using new golang + * Team upload. - -- Steve Langasek Wed, 11 Nov 2020 22:09:58 +0000 + [ Debian Janitor ] + * Set upstream metadata fields: Bug-Database, Bug-Submit, Repository, + Repository-Browse. + + [ Roger Shimizu ] + * New upstream release 1.14.2 + * debian/patches: + - Refresh patches. + - Add patch 0006 to import golang-github-influxdata-tail-dev + instead of golang-github-hpcloud-tail-dev + * debian/control: + - Replace B-D golang-github-hpcloud-tail-dev with + golang-github-influxdata-tail-dev. + * debian/watch: + - Update watch to match filename in archive. -golang-ginkgo (1.12.0-7build1) groovy; urgency=medium - - * No-change rebuild using new golang - - -- Steve Langasek Tue, 22 Sep 2020 08:50:34 +0000 + -- Roger Shimizu Sun, 22 Nov 2020 21:00:04 +0900 golang-ginkgo (1.12.0-7) unstable; urgency=medium diff -Nru golang-ginkgo-1.12.0/debian/control golang-ginkgo-1.14.2/debian/control --- golang-ginkgo-1.12.0/debian/control 2020-09-22 08:50:34.000000000 +0000 +++ golang-ginkgo-1.14.2/debian/control 2020-11-22 12:00:04.000000000 +0000 @@ -1,13 +1,12 @@ Source: golang-ginkgo Section: devel Priority: optional -Maintainer: Ubuntu Developers -XSBC-Original-Maintainer: Debian Go Packaging Team +Maintainer: Debian Go Packaging Team Uploaders: Martín Ferrari , Build-Depends: debhelper-compat (= 12), dh-golang (>= 1.17~), golang-any, - golang-github-hpcloud-tail-dev, + golang-github-influxdata-tail-dev, golang-golang-x-sys-dev, golang-gomega-dev, Standards-Version: 4.5.0 @@ -32,7 +31,7 @@ Package: golang-github-onsi-ginkgo-dev Architecture: all -Depends: golang-github-hpcloud-tail-dev, +Depends: golang-github-influxdata-tail-dev, golang-golang-x-sys-dev, golang-gomega-dev, ${misc:Depends}, diff -Nru golang-ginkgo-1.12.0/debian/patches/0001-skip-go-module-test.patch golang-ginkgo-1.14.2/debian/patches/0001-skip-go-module-test.patch --- golang-ginkgo-1.12.0/debian/patches/0001-skip-go-module-test.patch 2020-02-13 15:43:55.000000000 +0000 +++ golang-ginkgo-1.14.2/debian/patches/0001-skip-go-module-test.patch 2020-11-22 12:00:04.000000000 +0000 @@ -7,7 +7,7 @@ 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integration/subcommand_test.go b/integration/subcommand_test.go -index 9c1cecc..48350da 100644 +index f46777b..9e6a4e4 100644 --- a/integration/subcommand_test.go +++ b/integration/subcommand_test.go @@ -377,10 +377,11 @@ var _ = Describe("Subcommand", func() { diff -Nru golang-ginkgo-1.12.0/debian/patches/0002-increase-default-test-timeout-to-30m.patch golang-ginkgo-1.14.2/debian/patches/0002-increase-default-test-timeout-to-30m.patch --- golang-ginkgo-1.12.0/debian/patches/0002-increase-default-test-timeout-to-30m.patch 2020-02-13 15:43:55.000000000 +0000 +++ golang-ginkgo-1.14.2/debian/patches/0002-increase-default-test-timeout-to-30m.patch 2020-11-22 12:00:04.000000000 +0000 @@ -7,10 +7,10 @@ 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/integration_suite_test.go b/integration/integration_suite_test.go -index 32ec741..3ae43dc 100644 +index e4d8b44..31d666b 100644 --- a/integration/integration_suite_test.go +++ b/integration/integration_suite_test.go -@@ -19,7 +19,7 @@ var tmpDir string +@@ -21,7 +21,7 @@ var tmpDir string var pathToGinkgo string func TestIntegration(t *testing.T) { diff -Nru golang-ginkgo-1.12.0/debian/patches/0003-only-run-race-detector-on-supported-arch.patch golang-ginkgo-1.14.2/debian/patches/0003-only-run-race-detector-on-supported-arch.patch --- golang-ginkgo-1.12.0/debian/patches/0003-only-run-race-detector-on-supported-arch.patch 2020-02-13 15:43:55.000000000 +0000 +++ golang-ginkgo-1.14.2/debian/patches/0003-only-run-race-detector-on-supported-arch.patch 2020-11-22 12:00:04.000000000 +0000 @@ -3,13 +3,12 @@ Subject: only run race detector on supported arch Forwarded: https://github.com/onsi/ginkgo/pull/642 - --- - integration/flags_test.go | 4 ++++ - 1 file changed, 4 insertions(+) + integration/flags_test.go | 1 + + 1 file changed, 1 insertion(+) diff --git a/integration/flags_test.go b/integration/flags_test.go -index d84eb46..1795f00 100644 +index ad1e090..ae7ae5a 100644 --- a/integration/flags_test.go +++ b/integration/flags_test.go @@ -4,6 +4,7 @@ import ( @@ -20,13 +19,3 @@ "strings" . "github.com/onsi/ginkgo" -@@ -106,6 +107,9 @@ var _ = Describe("Flags Specs", func() { - }) - - It("should run the race detector when told to", func() { -+ if runtime.GOARCH != "amd64" && runtime.GOARCH != "ppc64le" && runtime.GOARCH != "arm64" { -+ Skip("Skip race detector on " + runtime.GOARCH) -+ } - session := startGinkgo(pathToTest, "--noColor", "--race") - Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE)) - output := string(session.Out.Contents()) diff -Nru golang-ginkgo-1.12.0/debian/patches/0004-skip-tests-not-working-on-gccgo.patch golang-ginkgo-1.14.2/debian/patches/0004-skip-tests-not-working-on-gccgo.patch --- golang-ginkgo-1.12.0/debian/patches/0004-skip-tests-not-working-on-gccgo.patch 2020-02-13 15:43:55.000000000 +0000 +++ golang-ginkgo-1.14.2/debian/patches/0004-skip-tests-not-working-on-gccgo.patch 2020-11-22 12:00:04.000000000 +0000 @@ -9,7 +9,7 @@ 3 files changed, 14 insertions(+) diff --git a/integration/coverage_test.go b/integration/coverage_test.go -index 3b4528c..868f663 100644 +index 962538c..3ae9efb 100644 --- a/integration/coverage_test.go +++ b/integration/coverage_test.go @@ -1,3 +1,5 @@ @@ -19,7 +19,7 @@ import ( diff --git a/integration/flags_test.go b/integration/flags_test.go -index 1795f00..aa2f778 100644 +index ae7ae5a..7540da0 100644 --- a/integration/flags_test.go +++ b/integration/flags_test.go @@ -50,6 +50,9 @@ var _ = Describe("Flags Specs", func() { diff -Nru golang-ginkgo-1.12.0/debian/patches/0005-skip-failed-test-on-mips64le-and-riscv64.patch golang-ginkgo-1.14.2/debian/patches/0005-skip-failed-test-on-mips64le-and-riscv64.patch --- golang-ginkgo-1.12.0/debian/patches/0005-skip-failed-test-on-mips64le-and-riscv64.patch 2020-02-13 15:43:55.000000000 +0000 +++ golang-ginkgo-1.14.2/debian/patches/0005-skip-failed-test-on-mips64le-and-riscv64.patch 2020-11-22 12:00:04.000000000 +0000 @@ -3,13 +3,12 @@ Subject: skip failed test on mips64le and riscv64 Bug: https://github.com/onsi/ginkgo/issues/643 - --- integration/run_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/integration/run_test.go b/integration/run_test.go -index 6c270b6..3a08d5e 100644 +index c300e1c..25c0e67 100644 --- a/integration/run_test.go +++ b/integration/run_test.go @@ -301,6 +301,9 @@ var _ = Describe("Running Specs", func() { diff -Nru golang-ginkgo-1.12.0/debian/patches/0006-Import-github.com-influxdata-tail-instead-of-github.patch golang-ginkgo-1.14.2/debian/patches/0006-Import-github.com-influxdata-tail-instead-of-github.patch --- golang-ginkgo-1.12.0/debian/patches/0006-Import-github.com-influxdata-tail-instead-of-github.patch 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/debian/patches/0006-Import-github.com-influxdata-tail-instead-of-github.patch 2020-11-22 12:00:04.000000000 +0000 @@ -0,0 +1,22 @@ +From: Roger Shimizu +Date: Sun, 22 Nov 2020 18:46:29 +0900 +Subject: Import github.com/influxdata/tail instead of github.com/nxadm/tail + +Fix ftbfs issue +--- + internal/remote/output_interceptor_unix.go | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/internal/remote/output_interceptor_unix.go b/internal/remote/output_interceptor_unix.go +index 80614d0..c80b5a9 100644 +--- a/internal/remote/output_interceptor_unix.go ++++ b/internal/remote/output_interceptor_unix.go +@@ -7,7 +7,7 @@ import ( + "io/ioutil" + "os" + +- "github.com/nxadm/tail" ++ "github.com/influxdata/tail" + ) + + func NewOutputInterceptor() OutputInterceptor { diff -Nru golang-ginkgo-1.12.0/debian/patches/series golang-ginkgo-1.14.2/debian/patches/series --- golang-ginkgo-1.12.0/debian/patches/series 2020-02-13 15:43:55.000000000 +0000 +++ golang-ginkgo-1.14.2/debian/patches/series 2020-11-22 12:00:04.000000000 +0000 @@ -3,3 +3,4 @@ 0003-only-run-race-detector-on-supported-arch.patch 0004-skip-tests-not-working-on-gccgo.patch 0005-skip-failed-test-on-mips64le-and-riscv64.patch +0006-Import-github.com-influxdata-tail-instead-of-github.patch diff -Nru golang-ginkgo-1.12.0/debian/upstream/metadata golang-ginkgo-1.14.2/debian/upstream/metadata --- golang-ginkgo-1.12.0/debian/upstream/metadata 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/debian/upstream/metadata 2020-11-22 12:00:04.000000000 +0000 @@ -0,0 +1,5 @@ +--- +Bug-Database: https://github.com/onsi/ginkgo/issues +Bug-Submit: https://github.com/onsi/ginkgo/issues/new +Repository: https://github.com/onsi/ginkgo.git +Repository-Browse: https://github.com/onsi/ginkgo diff -Nru golang-ginkgo-1.12.0/debian/watch golang-ginkgo-1.14.2/debian/watch --- golang-ginkgo-1.12.0/debian/watch 2020-02-13 15:43:55.000000000 +0000 +++ golang-ginkgo-1.14.2/debian/watch 2020-11-22 12:00:04.000000000 +0000 @@ -1,4 +1,4 @@ version=4 -opts="filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/golang-ginkgo-\$1\.tar\.gz/, \ +opts="filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/golang-ginkgo_\$1\.orig.tar\.gz/, \ uversionmangle=s/(\d)[_\.\-\+]?(RC|rc|pre|dev|beta|alpha)[.]?(\d*)$/\$1~\$2\$3/" \ https://github.com/onsi/ginkgo/tags .*/v?(\d\S*)\.tar\.gz debian diff -Nru golang-ginkgo-1.12.0/example/books/books.go golang-ginkgo-1.14.2/example/books/books.go --- golang-ginkgo-1.12.0/example/books/books.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/example/books/books.go 2020-10-12 17:59:23.000000000 +0000 @@ -0,0 +1,16 @@ +package books + +type Book struct { + Title string + Author string + Pages int +} + +func (b *Book) CategoryByLength() string { + + if b.Pages >= 300 { + return "NOVEL" + } + + return "SHORT STORY" +} diff -Nru golang-ginkgo-1.12.0/example/books/books_suite_test.go golang-ginkgo-1.14.2/example/books/books_suite_test.go --- golang-ginkgo-1.12.0/example/books/books_suite_test.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/example/books/books_suite_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -0,0 +1,13 @@ +package books_test + +import ( + "testing" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +func TestBooks(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Books Suite") +} diff -Nru golang-ginkgo-1.12.0/example/books/book_test.go golang-ginkgo-1.14.2/example/books/book_test.go --- golang-ginkgo-1.12.0/example/books/book_test.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/example/books/book_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -0,0 +1,42 @@ +package books_test + +import ( + . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/example/books" + . "github.com/onsi/gomega" +) + +var _ = Describe("Book", func() { + var ( + longBook Book + shortBook Book + ) + + BeforeEach(func() { + longBook = Book{ + Title: "Les Miserables", + Author: "Victor Hugo", + Pages: 1488, + } + + shortBook = Book{ + Title: "Fox In Socks", + Author: "Dr. Seuss", + Pages: 24, + } + }) + + Describe("Categorizing book length", func() { + Context("With more than 300 pages", func() { + It("should be a novel", func() { + Expect(longBook.CategoryByLength()).To(Equal("NOVEL")) + }) + }) + + Context("With fewer than 300 pages", func() { + It("should be a short story", func() { + Expect(shortBook.CategoryByLength()).To(Equal("SHORT STORY")) + }) + }) + }) +}) diff -Nru golang-ginkgo-1.12.0/extensions/globals/globals.go golang-ginkgo-1.14.2/extensions/globals/globals.go --- golang-ginkgo-1.12.0/extensions/globals/globals.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/extensions/globals/globals.go 2020-10-12 17:59:23.000000000 +0000 @@ -0,0 +1,26 @@ +// Package `globals` provides an interface to alter the global state of ginkgo suite. +// +// ginkgo currently registers a few singleton global vars that hold all the +// test blocks and failure management. These vars are global per package, which means +// that only one Suite definition can coexist in one package. +// +// However, there can be some use cases where applications using ginkgo may want to +// have a bit more control about this. For instance, a package may be using ginkgo +// to dynamically generate different tests and groups depending on some configuration. +// In this particular case, if the application wants to test how these different groups +// are generated, they will need access to change these global variables, so they +// can re-generate this global state, and ensure that different configuration generate +// indeed different tests. +// +// Note that this package is not intended to be used as part of normal ginkgo setups, and +// usually, you will never need to worry about the global state of ginkgo +package globals + +import "github.com/onsi/ginkgo/internal/global" + +// Reset calls `global.InitializeGlobals()` which will basically create a new instance +// of Suite, and therefore, will effectively reset the global variables to the init state. +// This will effectively remove all groups, tests and blocks that were added to the Suite. +func Reset() { + global.InitializeGlobals() +} diff -Nru golang-ginkgo-1.12.0/extensions/globals/globals_test.go golang-ginkgo-1.14.2/extensions/globals/globals_test.go --- golang-ginkgo-1.12.0/extensions/globals/globals_test.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/extensions/globals/globals_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -0,0 +1,26 @@ +package globals_test + +import ( + "testing" + + "github.com/onsi/ginkgo/extensions/globals" + "github.com/onsi/ginkgo/internal/global" +) + +func TestGlobals(t *testing.T) { + global.InitializeGlobals() + oldSuite := global.Suite + if oldSuite == nil { + t.Error("global.Suite was nil") + } + + globals.Reset() + newSuite := global.Suite + if newSuite == nil { + t.Error("new global.Suite was nil") + } + + if oldSuite == newSuite { + t.Error("got the same suite but expected it to be different!") + } +} diff -Nru golang-ginkgo-1.12.0/extensions/table/table_entry.go golang-ginkgo-1.14.2/extensions/table/table_entry.go --- golang-ginkgo-1.12.0/extensions/table/table_entry.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/extensions/table/table_entry.go 2020-10-12 17:59:23.000000000 +0000 @@ -1,49 +1,76 @@ package table import ( + "fmt" "reflect" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/internal/codelocation" + "github.com/onsi/ginkgo/internal/global" + "github.com/onsi/ginkgo/types" ) /* TableEntry represents an entry in a table test. You generally use the `Entry` constructor. */ type TableEntry struct { - Description string - Parameters []interface{} - Pending bool - Focused bool + Description interface{} + Parameters []interface{} + Pending bool + Focused bool + codeLocation types.CodeLocation } func (t TableEntry) generateIt(itBody reflect.Value) { - if t.Pending { - ginkgo.PIt(t.Description) - return + var description string + descriptionValue := reflect.ValueOf(t.Description) + switch descriptionValue.Kind() { + case reflect.String: + description = descriptionValue.String() + case reflect.Func: + values := castParameters(descriptionValue, t.Parameters) + res := descriptionValue.Call(values) + if len(res) != 1 { + panic(fmt.Sprintf("The describe function should return only a value, returned %d", len(res))) + } + if res[0].Kind() != reflect.String { + panic(fmt.Sprintf("The describe function should return a string, returned %#v", res[0])) + } + description = res[0].String() + default: + panic(fmt.Sprintf("Description can either be a string or a function, got %#v", descriptionValue)) } - values := make([]reflect.Value, len(t.Parameters)) - iBodyType := itBody.Type() - for i, param := range t.Parameters { - if param == nil { - inType := iBodyType.In(i) - values[i] = reflect.Zero(inType) - } else { - values[i] = reflect.ValueOf(param) - } + if t.Pending { + global.Suite.PushItNode(description, func() {}, types.FlagTypePending, t.codeLocation, 0) + return } + values := castParameters(itBody, t.Parameters) body := func() { itBody.Call(values) } if t.Focused { - ginkgo.FIt(t.Description, body) + global.Suite.PushItNode(description, body, types.FlagTypeFocused, t.codeLocation, global.DefaultTimeout) } else { - ginkgo.It(t.Description, body) + global.Suite.PushItNode(description, body, types.FlagTypeNone, t.codeLocation, global.DefaultTimeout) } } +func castParameters(function reflect.Value, parameters []interface{}) []reflect.Value { + res := make([]reflect.Value, len(parameters)) + funcType := function.Type() + for i, param := range parameters { + if param == nil { + inType := funcType.In(i) + res[i] = reflect.Zero(inType) + } else { + res[i] = reflect.ValueOf(param) + } + } + return res +} + /* Entry constructs a TableEntry. @@ -52,27 +79,51 @@ Each Entry ends up generating an individual Ginkgo It. */ -func Entry(description string, parameters ...interface{}) TableEntry { - return TableEntry{description, parameters, false, false} +func Entry(description interface{}, parameters ...interface{}) TableEntry { + return TableEntry{ + Description: description, + Parameters: parameters, + Pending: false, + Focused: false, + codeLocation: codelocation.New(1), + } } /* You can focus a particular entry with FEntry. This is equivalent to FIt. */ -func FEntry(description string, parameters ...interface{}) TableEntry { - return TableEntry{description, parameters, false, true} +func FEntry(description interface{}, parameters ...interface{}) TableEntry { + return TableEntry{ + Description: description, + Parameters: parameters, + Pending: false, + Focused: true, + codeLocation: codelocation.New(1), + } } /* You can mark a particular entry as pending with PEntry. This is equivalent to PIt. */ -func PEntry(description string, parameters ...interface{}) TableEntry { - return TableEntry{description, parameters, true, false} +func PEntry(description interface{}, parameters ...interface{}) TableEntry { + return TableEntry{ + Description: description, + Parameters: parameters, + Pending: true, + Focused: false, + codeLocation: codelocation.New(1), + } } /* You can mark a particular entry as pending with XEntry. This is equivalent to XIt. */ -func XEntry(description string, parameters ...interface{}) TableEntry { - return TableEntry{description, parameters, true, false} +func XEntry(description interface{}, parameters ...interface{}) TableEntry { + return TableEntry{ + Description: description, + Parameters: parameters, + Pending: true, + Focused: false, + codeLocation: codelocation.New(1), + } } diff -Nru golang-ginkgo-1.12.0/extensions/table/table.go golang-ginkgo-1.14.2/extensions/table/table.go --- golang-ginkgo-1.12.0/extensions/table/table.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/extensions/table/table.go 2020-10-12 17:59:23.000000000 +0000 @@ -12,7 +12,9 @@ "fmt" "reflect" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/internal/codelocation" + "github.com/onsi/ginkgo/internal/global" + "github.com/onsi/ginkgo/types" ) /* @@ -40,9 +42,28 @@ It's important to understand that the `Describe`s and `It`s are generated at evaluation time (i.e. when Ginkgo constructs the tree of tests and before the tests run). Individual Entries can be focused (with FEntry) or marked pending (with PEntry or XEntry). In addition, the entire table can be focused or marked pending with FDescribeTable and PDescribeTable/XDescribeTable. + +A description function can be passed to Entry in place of the description. The function is then fed with the entry parameters to generate the description of the It corresponding to that particular Entry. + +For example: + + describe := func(desc string) func(int, int, bool) string { + return func(x, y int, expected bool) string { + return fmt.Sprintf("%s x=%d y=%d expected:%t", desc, x, y, expected) + } + } + + DescribeTable("a simple table", + func(x int, y int, expected bool) { + Ω(x > y).Should(Equal(expected)) + }, + Entry(describe("x > y"), 1, 0, true), + Entry(describe("x == y"), 0, 0, false), + Entry(describe("x < y"), 0, 1, false), + ) */ func DescribeTable(description string, itBody interface{}, entries ...TableEntry) bool { - describeTable(description, itBody, entries, false, false) + describeTable(description, itBody, entries, types.FlagTypeNone) return true } @@ -50,7 +71,7 @@ You can focus a table with `FDescribeTable`. This is equivalent to `FDescribe`. */ func FDescribeTable(description string, itBody interface{}, entries ...TableEntry) bool { - describeTable(description, itBody, entries, false, true) + describeTable(description, itBody, entries, types.FlagTypeFocused) return true } @@ -58,7 +79,7 @@ You can mark a table as pending with `PDescribeTable`. This is equivalent to `PDescribe`. */ func PDescribeTable(description string, itBody interface{}, entries ...TableEntry) bool { - describeTable(description, itBody, entries, true, false) + describeTable(description, itBody, entries, types.FlagTypePending) return true } @@ -66,33 +87,24 @@ You can mark a table as pending with `XDescribeTable`. This is equivalent to `XDescribe`. */ func XDescribeTable(description string, itBody interface{}, entries ...TableEntry) bool { - describeTable(description, itBody, entries, true, false) + describeTable(description, itBody, entries, types.FlagTypePending) return true } -func describeTable(description string, itBody interface{}, entries []TableEntry, pending bool, focused bool) { +func describeTable(description string, itBody interface{}, entries []TableEntry, flag types.FlagType) { itBodyValue := reflect.ValueOf(itBody) if itBodyValue.Kind() != reflect.Func { panic(fmt.Sprintf("DescribeTable expects a function, got %#v", itBody)) } - if pending { - ginkgo.PDescribe(description, func() { + global.Suite.PushContainerNode( + description, + func() { for _, entry := range entries { entry.generateIt(itBodyValue) } - }) - } else if focused { - ginkgo.FDescribe(description, func() { - for _, entry := range entries { - entry.generateIt(itBodyValue) - } - }) - } else { - ginkgo.Describe(description, func() { - for _, entry := range entries { - entry.generateIt(itBodyValue) - } - }) - } + }, + flag, + codelocation.New(2), + ) } diff -Nru golang-ginkgo-1.12.0/extensions/table/table_test.go golang-ginkgo-1.14.2/extensions/table/table_test.go --- golang-ginkgo-1.12.0/extensions/table/table_test.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/extensions/table/table_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -1,6 +1,7 @@ package table_test import ( + "fmt" "strings" . "github.com/onsi/ginkgo/extensions/table" @@ -62,3 +63,53 @@ Entry("nil", nil), ) }) + +var _ = Describe("TableWithParametricDescription", func() { + describe := func(desc string) func(int, int, bool) string { + return func(x, y int, expected bool) string { + return fmt.Sprintf("%s x=%d y=%d expected:%t", desc, x, y, expected) + } + } + + DescribeTable("a simple table", + func(x int, y int, expected bool) { + Ω(x > y).Should(Equal(expected)) + }, + Entry(describe("x > y"), 1, 0, true), + Entry(describe("x == y"), 0, 0, false), + Entry(describe("x < y"), 0, 1, false), + ) + + type ComplicatedThings struct { + Superstructure string + Substructure string + Count int + } + + describeComplicated := func(desc string) func(ComplicatedThings) string { + return func(things ComplicatedThings) string { + return fmt.Sprintf("%s things=%v", desc, things) + } + } + + DescribeTable("a more complicated table", + func(c ComplicatedThings) { + Ω(strings.Count(c.Superstructure, c.Substructure)).Should(BeNumerically("==", c.Count)) + }, + Entry(describeComplicated("with no matching substructures"), ComplicatedThings{ + Superstructure: "the sixth sheikh's sixth sheep's sick", + Substructure: "emir", + Count: 0, + }), + Entry(describeComplicated("with one matching substructure"), ComplicatedThings{ + Superstructure: "the sixth sheikh's sixth sheep's sick", + Substructure: "sheep", + Count: 1, + }), + Entry(describeComplicated("with many matching substructures"), ComplicatedThings{ + Superstructure: "the sixth sheikh's sixth sheep's sick", + Substructure: "si", + Count: 3, + }), + ) +}) diff -Nru golang-ginkgo-1.12.0/ginkgo/build_command.go golang-ginkgo-1.14.2/ginkgo/build_command.go --- golang-ginkgo-1.12.0/ginkgo/build_command.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/ginkgo/build_command.go 2020-10-12 17:59:23.000000000 +0000 @@ -57,8 +57,6 @@ } else { fmt.Printf(" compiled %s.test\n", suite.PackageName) } - - runner.CleanUp() } if passed { diff -Nru golang-ginkgo-1.12.0/ginkgo/convert/package_rewriter.go golang-ginkgo-1.14.2/ginkgo/convert/package_rewriter.go --- golang-ginkgo-1.12.0/ginkgo/convert/package_rewriter.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/ginkgo/convert/package_rewriter.go 2020-10-12 17:59:23.000000000 +0000 @@ -33,7 +33,8 @@ */ func findTestsInPackage(pkg *build.Package) (testfiles []string) { for _, file := range append(pkg.TestGoFiles, pkg.XTestGoFiles...) { - testfiles = append(testfiles, filepath.Join(pkg.Dir, file)) + testfile, _ := filepath.Abs(filepath.Join(pkg.Dir, file)) + testfiles = append(testfiles, testfile) } dirFiles, err := ioutil.ReadDir(pkg.Dir) @@ -103,10 +104,11 @@ * Shells out to `go fmt` to format the package */ func goFmtPackage(pkg *build.Package) { - output, err := exec.Command("go", "fmt", pkg.ImportPath).Output() + path, _ := filepath.Abs(pkg.ImportPath) + output, err := exec.Command("go", "fmt", path).CombinedOutput() if err != nil { - fmt.Printf("Warning: Error running 'go fmt %s'.\nstdout: %s\n%s\n", pkg.ImportPath, output, err.Error()) + fmt.Printf("Warning: Error running 'go fmt %s'.\nstdout: %s\n%s\n", path, output, err.Error()) } } diff -Nru golang-ginkgo-1.12.0/ginkgo/convert/testfile_rewriter.go golang-ginkgo-1.14.2/ginkgo/convert/testfile_rewriter.go --- golang-ginkgo-1.12.0/ginkgo/convert/testfile_rewriter.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/ginkgo/convert/testfile_rewriter.go 2020-10-12 17:59:23.000000000 +0000 @@ -22,7 +22,7 @@ */ func rewriteTestsInFile(pathToFile string) { fileSet := token.NewFileSet() - rootNode, err := parser.ParseFile(fileSet, pathToFile, nil, 0) + rootNode, err := parser.ParseFile(fileSet, pathToFile, nil, parser.ParseComments) if err != nil { panic(fmt.Sprintf("Error parsing test file '%s':\n%s\n", pathToFile, err.Error())) } @@ -56,11 +56,12 @@ } fileInfo, err := os.Stat(pathToFile) + if err != nil { panic(fmt.Sprintf("Error stat'ing file: %s\n", pathToFile)) } - ioutil.WriteFile(pathToFile, buffer.Bytes(), fileInfo.Mode()) + err = ioutil.WriteFile(pathToFile, buffer.Bytes(), fileInfo.Mode()) } /* diff -Nru golang-ginkgo-1.12.0/ginkgo/generate_command.go golang-ginkgo-1.14.2/ginkgo/generate_command.go --- golang-ginkgo-1.12.0/ginkgo/generate_command.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/ginkgo/generate_command.go 2020-10-12 17:59:23.000000000 +0000 @@ -39,7 +39,7 @@ {{if .IncludeImports}}. "github.com/onsi/ginkgo"{{end}} {{if .IncludeImports}}. "github.com/onsi/gomega"{{end}} - {{if .DotImportPackage}}. "{{.PackageImportPath}}"{{end}} + {{if .ImportPackage}}"{{.PackageImportPath}}"{{end}} ) var _ = Describe("{{.Subject}}", func() { @@ -55,7 +55,7 @@ "github.com/sclevine/agouti" . "github.com/sclevine/agouti/matchers" - {{if .DotImportPackage}}. "{{.PackageImportPath}}"{{end}} + {{if .ImportPackage}}"{{.PackageImportPath}}"{{end}} ) var _ = Describe("{{.Subject}}", func() { @@ -78,7 +78,7 @@ Subject string PackageImportPath string IncludeImports bool - DotImportPackage bool + ImportPackage bool } func generateSpec(args []string, agouti, noDot, internal bool) { @@ -119,7 +119,7 @@ Subject: formattedName, PackageImportPath: getPackageImportPath(), IncludeImports: !noDot, - DotImportPackage: !internal, + ImportPackage: !internal, } targetFile := fmt.Sprintf("%s_test.go", specFilePrefix) @@ -233,18 +233,20 @@ panic(err.Error()) } + sep := string(filepath.Separator) + // Try go.mod file first modRoot := findModuleRoot(workingDir) if modRoot != "" { modName := moduleName(modRoot) if modName != "" { cd := strings.Replace(workingDir, modRoot, "", -1) + cd = strings.ReplaceAll(cd, sep, "/") return modName + cd } } // Fallback to GOPATH structure - sep := string(filepath.Separator) paths := strings.Split(workingDir, sep+"src"+sep) if len(paths) == 1 { fmt.Printf("\nCouldn't identify package import path.\n\n\tginkgo generate\n\nMust be run within a package directory under $GOPATH/src/...\nYou're going to have to change UNKNOWN_PACKAGE_PATH in the generated file...\n\n") diff -Nru golang-ginkgo-1.12.0/ginkgo/main.go golang-ginkgo-1.14.2/ginkgo/main.go --- golang-ginkgo-1.12.0/ginkgo/main.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/ginkgo/main.go 2020-10-12 17:59:23.000000000 +0000 @@ -288,9 +288,9 @@ } func goFmt(path string) { - err := exec.Command("go", "fmt", path).Run() + out, err := exec.Command("go", "fmt", path).CombinedOutput() if err != nil { - complainAndQuit("Could not fmt: " + err.Error()) + complainAndQuit("Could not fmt: " + err.Error() + "\n" + string(out)) } } diff -Nru golang-ginkgo-1.12.0/ginkgo/nodot/nodot.go golang-ginkgo-1.14.2/ginkgo/nodot/nodot.go --- golang-ginkgo-1.12.0/ginkgo/nodot/nodot.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/ginkgo/nodot/nodot.go 2020-10-12 17:59:23.000000000 +0000 @@ -186,7 +186,9 @@ declarations = append(declarations, s.Names[0].Name) } case *ast.FuncDecl: - declarations = append(declarations, x.Name.Name) + if x.Recv == nil { + declarations = append(declarations, x.Name.Name) + } } } diff -Nru golang-ginkgo-1.12.0/ginkgo/run_command.go golang-ginkgo-1.14.2/ginkgo/run_command.go --- golang-ginkgo-1.12.0/ginkgo/run_command.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/ginkgo/run_command.go 2020-10-12 17:59:23.000000000 +0000 @@ -179,19 +179,24 @@ for index, runner := range runners { contents, err := ioutil.ReadFile(runner.CoverageFile) + if err != nil { + fmt.Printf("Unable to read coverage file %s to combine, %v\n", runner.CoverageFile, err) + return nil // non-fatal error + } + // remove the cover mode line from every file // except the first one if index > 0 { contents = modeRegex.ReplaceAll(contents, []byte{}) } - if err != nil { - fmt.Printf("Unable to read coverage file %s to combine, %v\n", runner.CoverageFile, err) - return nil // non-fatal error - } - _, err = combined.Write(contents) + // Add a newline to the end of every file if missing. + if err == nil && len(contents) > 0 && contents[len(contents)-1] != '\n' { + _, err = combined.Write([]byte("\n")) + } + if err != nil { fmt.Printf("Unable to append to coverprofile, %v\n", err) return nil // non-fatal error diff -Nru golang-ginkgo-1.12.0/ginkgo/testrunner/test_runner.go golang-ginkgo-1.14.2/ginkgo/testrunner/test_runner.go --- golang-ginkgo-1.12.0/ginkgo/testrunner/test_runner.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/ginkgo/testrunner/test_runner.go 2020-10-12 17:59:23.000000000 +0000 @@ -49,11 +49,7 @@ } if !suite.Precompiled { - dir, err := ioutil.TempDir("", "ginkgo") - if err != nil { - panic(fmt.Sprintf("couldn't create temporary directory... might be time to rm -rf:\n%s", err.Error())) - } - runner.compilationTargetPath = filepath.Join(dir, suite.PackageName+".test") + runner.compilationTargetPath, _ = filepath.Abs(filepath.Join(suite.Path, suite.PackageName+".test")) } return runner @@ -248,7 +244,7 @@ if t.Suite.Precompiled { return } - os.RemoveAll(filepath.Dir(t.compilationTargetPath)) + os.Remove(t.compilationTargetPath) } func (t *TestRunner) runSerialGinkgoSuite() RunResult { diff -Nru golang-ginkgo-1.12.0/ginkgo/unfocus_command.go golang-ginkgo-1.14.2/ginkgo/unfocus_command.go --- golang-ginkgo-1.12.0/ginkgo/unfocus_command.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/ginkgo/unfocus_command.go 2020-10-12 17:59:23.000000000 +0000 @@ -1,11 +1,18 @@ package main import ( + "bytes" "flag" "fmt" + "go/ast" + "go/parser" + "go/token" + "io" "io/ioutil" - "os/exec" + "os" + "path/filepath" "strings" + "sync" ) func BuildUnfocusCommand() *Command { @@ -22,40 +29,152 @@ } func unfocusSpecs([]string, []string) { - unfocus("Describe") - unfocus("Context") - unfocus("It") - unfocus("Measure") - unfocus("DescribeTable") - unfocus("Entry") - unfocus("Specify") - unfocus("When") + fmt.Println("Scanning for focus...") + + goFiles := make(chan string) + go func() { + unfocusDir(goFiles, ".") + close(goFiles) + }() + + const workers = 10 + wg := sync.WaitGroup{} + wg.Add(workers) + + for i := 0; i < workers; i++ { + go func() { + for path := range goFiles { + unfocusFile(path) + } + wg.Done() + }() + } + + wg.Wait() } -func unfocus(component string) { - fmt.Printf("Removing F%s...\n", component) - files, err := ioutil.ReadDir(".") +func unfocusDir(goFiles chan string, path string) { + files, err := ioutil.ReadDir(path) if err != nil { fmt.Println(err.Error()) return } + for _, f := range files { - // Exclude "vendor" directory - if f.IsDir() && f.Name() == "vendor" { - continue + switch { + case f.IsDir() && shouldProcessDir(f.Name()): + unfocusDir(goFiles, filepath.Join(path, f.Name())) + case !f.IsDir() && shouldProcessFile(f.Name()): + goFiles <- filepath.Join(path, f.Name()) } - // Exclude non-go files in the current directory - if !f.IsDir() && !strings.HasSuffix(f.Name(), ".go") { - continue + } +} + +func shouldProcessDir(basename string) bool { + return basename != "vendor" && !strings.HasPrefix(basename, ".") +} + +func shouldProcessFile(basename string) bool { + return strings.HasSuffix(basename, ".go") +} + +func unfocusFile(path string) { + data, err := ioutil.ReadFile(path) + if err != nil { + fmt.Printf("error reading file '%s': %s\n", path, err.Error()) + return + } + + ast, err := parser.ParseFile(token.NewFileSet(), path, bytes.NewReader(data), 0) + if err != nil { + fmt.Printf("error parsing file '%s': %s\n", path, err.Error()) + return + } + + eliminations := scanForFocus(ast) + if len(eliminations) == 0 { + return + } + + fmt.Printf("...updating %s\n", path) + backup, err := writeBackup(path, data) + if err != nil { + fmt.Printf("error creating backup file: %s\n", err.Error()) + return + } + + if err := updateFile(path, data, eliminations); err != nil { + fmt.Printf("error writing file '%s': %s\n", path, err.Error()) + return + } + + os.Remove(backup) +} + +func writeBackup(path string, data []byte) (string, error) { + t, err := ioutil.TempFile(filepath.Dir(path), filepath.Base(path)) + + if err != nil { + return "", fmt.Errorf("error creating temporary file: %w", err) + } + defer t.Close() + + if _, err := io.Copy(t, bytes.NewReader(data)); err != nil { + return "", fmt.Errorf("error writing to temporary file: %w", err) + } + + return t.Name(), nil +} + +func updateFile(path string, data []byte, eliminations []int64) error { + to, err := os.Create(path) + if err != nil { + return fmt.Errorf("error opening file for writing '%s': %w\n", path, err) + } + defer to.Close() + + from := bytes.NewReader(data) + var cursor int64 + for _, byteToEliminate := range eliminations { + if _, err := io.CopyN(to, from, byteToEliminate-cursor); err != nil { + return fmt.Errorf("error copying data: %w", err) } - // Recursively run `gofmt` otherwise - cmd := exec.Command("gofmt", fmt.Sprintf("-r=F%s -> %s", component, component), "-w", f.Name()) - out, err := cmd.CombinedOutput() - if err != nil { - fmt.Println(err.Error()) + + cursor = byteToEliminate + 1 + + if _, err := from.Seek(1, io.SeekCurrent); err != nil { + return fmt.Errorf("error seeking to position in buffer: %w", err) } - if string(out) != "" { - fmt.Println(string(out)) + } + + if _, err := io.Copy(to, from); err != nil { + return fmt.Errorf("error copying end data: %w", err) + } + + return nil +} + +func scanForFocus(file *ast.File) (eliminations []int64) { + ast.Inspect(file, func(n ast.Node) bool { + if c, ok := n.(*ast.CallExpr); ok { + if i, ok := c.Fun.(*ast.Ident); ok { + if isFocus(i.Name) { + eliminations = append(eliminations, int64(i.Pos()-file.Pos())) + } + } } + + return true + }) + + return eliminations +} + +func isFocus(name string) bool { + switch name { + case "FDescribe", "FContext", "FIt", "FMeasure", "FDescribeTable", "FEntry", "FSpecify", "FWhen": + return true + default: + return false } } diff -Nru golang-ginkgo-1.12.0/ginkgo/watch/dependencies.go golang-ginkgo-1.14.2/ginkgo/watch/dependencies.go --- golang-ginkgo-1.12.0/ginkgo/watch/dependencies.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/ginkgo/watch/dependencies.go 2020-10-12 17:59:23.000000000 +0000 @@ -6,6 +6,7 @@ ) var ginkgoAndGomegaFilter = regexp.MustCompile(`github\.com/onsi/ginkgo|github\.com/onsi/gomega`) +var ginkgoIntegrationTestFilter = regexp.MustCompile(`github\.com/onsi/ginkgo/integration`) //allow us to integration test this thing type Dependencies struct { deps map[string]int @@ -77,7 +78,7 @@ if err != nil { continue } - if !pkg.Goroot && !ginkgoAndGomegaFilter.Match([]byte(pkg.Dir)) { + if !pkg.Goroot && (!ginkgoAndGomegaFilter.Match([]byte(pkg.Dir)) || ginkgoIntegrationTestFilter.Match([]byte(pkg.Dir))) { d.addDepIfNotPresent(pkg.Dir, depth) } } diff -Nru golang-ginkgo-1.12.0/ginkgo_dsl.go golang-ginkgo-1.14.2/ginkgo_dsl.go --- golang-ginkgo-1.12.0/ginkgo_dsl.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/ginkgo_dsl.go 2020-10-12 17:59:23.000000000 +0000 @@ -22,9 +22,8 @@ "github.com/onsi/ginkgo/config" "github.com/onsi/ginkgo/internal/codelocation" - "github.com/onsi/ginkgo/internal/failer" + "github.com/onsi/ginkgo/internal/global" "github.com/onsi/ginkgo/internal/remote" - "github.com/onsi/ginkgo/internal/suite" "github.com/onsi/ginkgo/internal/testingtproxy" "github.com/onsi/ginkgo/internal/writer" "github.com/onsi/ginkgo/reporters" @@ -46,16 +45,10 @@ at the top of the goroutine that caused this panic. ` -const defaultTimeout = 1 - -var globalSuite *suite.Suite -var globalFailer *failer.Failer func init() { config.Flags(flag.CommandLine, "ginkgo", true) GinkgoWriter = writer.New(os.Stdout) - globalFailer = failer.New() - globalSuite = suite.New(globalFailer) } //GinkgoWriter implements an io.Writer @@ -100,26 +93,36 @@ if len(optionalOffset) > 0 { offset = optionalOffset[0] } - return testingtproxy.New(GinkgoWriter, Fail, offset) + failedFunc := func() bool { + return CurrentGinkgoTestDescription().Failed + } + nameFunc := func() string { + return CurrentGinkgoTestDescription().FullTestText + } + return testingtproxy.New(GinkgoWriter, Fail, Skip, failedFunc, nameFunc, offset) } //The interface returned by GinkgoT(). This covers most of the methods //in the testing package's T. type GinkgoTInterface interface { - Fail() + Cleanup(func()) Error(args ...interface{}) Errorf(format string, args ...interface{}) + Fail() FailNow() + Failed() bool Fatal(args ...interface{}) Fatalf(format string, args ...interface{}) + Helper() Log(args ...interface{}) Logf(format string, args ...interface{}) - Failed() bool + Name() string Parallel() Skip(args ...interface{}) - Skipf(format string, args ...interface{}) SkipNow() + Skipf(format string, args ...interface{}) Skipped() bool + TempDir() string } //Custom Ginkgo test reporters must implement the Reporter interface. @@ -156,7 +159,7 @@ //CurrentGinkgoTestDescripton returns information about the current running test. func CurrentGinkgoTestDescription() GinkgoTestDescription { - summary, ok := globalSuite.CurrentRunningSpecSummary() + summary, ok := global.Suite.CurrentRunningSpecSummary() if !ok { return GinkgoTestDescription{} } @@ -223,7 +226,7 @@ for i, reporter := range specReporters { reporters[i] = reporter } - passed, hasFocusedTests := globalSuite.Run(t, description, reporters, writer, config.GinkgoConfig) + passed, hasFocusedTests := global.Suite.Run(t, description, reporters, writer, config.GinkgoConfig) if passed && hasFocusedTests && strings.TrimSpace(os.Getenv("GINKGO_EDITOR_INTEGRATION")) == "" { fmt.Println("PASS | FOCUSED") os.Exit(types.GINKGO_FOCUS_EXIT_CODE) @@ -252,7 +255,7 @@ skip = callerSkip[0] } - globalFailer.Skip(message, codelocation.New(skip+1)) + global.Failer.Skip(message, codelocation.New(skip+1)) panic(GINKGO_PANIC) } @@ -263,7 +266,7 @@ skip = callerSkip[0] } - globalFailer.Fail(message, codelocation.New(skip+1)) + global.Failer.Fail(message, codelocation.New(skip+1)) panic(GINKGO_PANIC) } @@ -280,7 +283,7 @@ func GinkgoRecover() { e := recover() if e != nil { - globalFailer.Panic(codelocation.New(1), e) + global.Failer.Panic(codelocation.New(1), e) } } @@ -291,25 +294,25 @@ //equivalent. The difference is purely semantic -- you typically Describe the behavior of an object //or method and, within that Describe, outline a number of Contexts and Whens. func Describe(text string, body func()) bool { - globalSuite.PushContainerNode(text, body, types.FlagTypeNone, codelocation.New(1)) + global.Suite.PushContainerNode(text, body, types.FlagTypeNone, codelocation.New(1)) return true } //You can focus the tests within a describe block using FDescribe func FDescribe(text string, body func()) bool { - globalSuite.PushContainerNode(text, body, types.FlagTypeFocused, codelocation.New(1)) + global.Suite.PushContainerNode(text, body, types.FlagTypeFocused, codelocation.New(1)) return true } //You can mark the tests within a describe block as pending using PDescribe func PDescribe(text string, body func()) bool { - globalSuite.PushContainerNode(text, body, types.FlagTypePending, codelocation.New(1)) + global.Suite.PushContainerNode(text, body, types.FlagTypePending, codelocation.New(1)) return true } //You can mark the tests within a describe block as pending using XDescribe func XDescribe(text string, body func()) bool { - globalSuite.PushContainerNode(text, body, types.FlagTypePending, codelocation.New(1)) + global.Suite.PushContainerNode(text, body, types.FlagTypePending, codelocation.New(1)) return true } @@ -320,25 +323,25 @@ //equivalent. The difference is purely semantic -- you typical Describe the behavior of an object //or method and, within that Describe, outline a number of Contexts and Whens. func Context(text string, body func()) bool { - globalSuite.PushContainerNode(text, body, types.FlagTypeNone, codelocation.New(1)) + global.Suite.PushContainerNode(text, body, types.FlagTypeNone, codelocation.New(1)) return true } //You can focus the tests within a describe block using FContext func FContext(text string, body func()) bool { - globalSuite.PushContainerNode(text, body, types.FlagTypeFocused, codelocation.New(1)) + global.Suite.PushContainerNode(text, body, types.FlagTypeFocused, codelocation.New(1)) return true } //You can mark the tests within a describe block as pending using PContext func PContext(text string, body func()) bool { - globalSuite.PushContainerNode(text, body, types.FlagTypePending, codelocation.New(1)) + global.Suite.PushContainerNode(text, body, types.FlagTypePending, codelocation.New(1)) return true } //You can mark the tests within a describe block as pending using XContext func XContext(text string, body func()) bool { - globalSuite.PushContainerNode(text, body, types.FlagTypePending, codelocation.New(1)) + global.Suite.PushContainerNode(text, body, types.FlagTypePending, codelocation.New(1)) return true } @@ -349,25 +352,25 @@ //equivalent. The difference is purely semantic -- you typical Describe the behavior of an object //or method and, within that Describe, outline a number of Contexts and Whens. func When(text string, body func()) bool { - globalSuite.PushContainerNode("when "+text, body, types.FlagTypeNone, codelocation.New(1)) + global.Suite.PushContainerNode("when "+text, body, types.FlagTypeNone, codelocation.New(1)) return true } //You can focus the tests within a describe block using FWhen func FWhen(text string, body func()) bool { - globalSuite.PushContainerNode("when "+text, body, types.FlagTypeFocused, codelocation.New(1)) + global.Suite.PushContainerNode("when "+text, body, types.FlagTypeFocused, codelocation.New(1)) return true } //You can mark the tests within a describe block as pending using PWhen func PWhen(text string, body func()) bool { - globalSuite.PushContainerNode("when "+text, body, types.FlagTypePending, codelocation.New(1)) + global.Suite.PushContainerNode("when "+text, body, types.FlagTypePending, codelocation.New(1)) return true } //You can mark the tests within a describe block as pending using XWhen func XWhen(text string, body func()) bool { - globalSuite.PushContainerNode("when "+text, body, types.FlagTypePending, codelocation.New(1)) + global.Suite.PushContainerNode("when "+text, body, types.FlagTypePending, codelocation.New(1)) return true } @@ -377,25 +380,25 @@ //Ginkgo will normally run It blocks synchronously. To perform asynchronous tests, pass a //function that accepts a Done channel. When you do this, you can also provide an optional timeout. func It(text string, body interface{}, timeout ...float64) bool { - globalSuite.PushItNode(text, body, types.FlagTypeNone, codelocation.New(1), parseTimeout(timeout...)) + global.Suite.PushItNode(text, body, types.FlagTypeNone, codelocation.New(1), parseTimeout(timeout...)) return true } //You can focus individual Its using FIt func FIt(text string, body interface{}, timeout ...float64) bool { - globalSuite.PushItNode(text, body, types.FlagTypeFocused, codelocation.New(1), parseTimeout(timeout...)) + global.Suite.PushItNode(text, body, types.FlagTypeFocused, codelocation.New(1), parseTimeout(timeout...)) return true } //You can mark Its as pending using PIt func PIt(text string, _ ...interface{}) bool { - globalSuite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0) + global.Suite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0) return true } //You can mark Its as pending using XIt func XIt(text string, _ ...interface{}) bool { - globalSuite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0) + global.Suite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0) return true } @@ -403,25 +406,25 @@ //which "It" does not fit into a natural sentence flow. All the same protocols apply for Specify blocks //which apply to It blocks. func Specify(text string, body interface{}, timeout ...float64) bool { - globalSuite.PushItNode(text, body, types.FlagTypeNone, codelocation.New(1), parseTimeout(timeout...)) + global.Suite.PushItNode(text, body, types.FlagTypeNone, codelocation.New(1), parseTimeout(timeout...)) return true } //You can focus individual Specifys using FSpecify func FSpecify(text string, body interface{}, timeout ...float64) bool { - globalSuite.PushItNode(text, body, types.FlagTypeFocused, codelocation.New(1), parseTimeout(timeout...)) + global.Suite.PushItNode(text, body, types.FlagTypeFocused, codelocation.New(1), parseTimeout(timeout...)) return true } //You can mark Specifys as pending using PSpecify func PSpecify(text string, is ...interface{}) bool { - globalSuite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0) + global.Suite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0) return true } //You can mark Specifys as pending using XSpecify func XSpecify(text string, is ...interface{}) bool { - globalSuite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0) + global.Suite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0) return true } @@ -452,25 +455,25 @@ //The body function must have the signature: // func(b Benchmarker) func Measure(text string, body interface{}, samples int) bool { - globalSuite.PushMeasureNode(text, body, types.FlagTypeNone, codelocation.New(1), samples) + global.Suite.PushMeasureNode(text, body, types.FlagTypeNone, codelocation.New(1), samples) return true } //You can focus individual Measures using FMeasure func FMeasure(text string, body interface{}, samples int) bool { - globalSuite.PushMeasureNode(text, body, types.FlagTypeFocused, codelocation.New(1), samples) + global.Suite.PushMeasureNode(text, body, types.FlagTypeFocused, codelocation.New(1), samples) return true } //You can mark Measurements as pending using PMeasure func PMeasure(text string, _ ...interface{}) bool { - globalSuite.PushMeasureNode(text, func(b Benchmarker) {}, types.FlagTypePending, codelocation.New(1), 0) + global.Suite.PushMeasureNode(text, func(b Benchmarker) {}, types.FlagTypePending, codelocation.New(1), 0) return true } //You can mark Measurements as pending using XMeasure func XMeasure(text string, _ ...interface{}) bool { - globalSuite.PushMeasureNode(text, func(b Benchmarker) {}, types.FlagTypePending, codelocation.New(1), 0) + global.Suite.PushMeasureNode(text, func(b Benchmarker) {}, types.FlagTypePending, codelocation.New(1), 0) return true } @@ -481,7 +484,7 @@ // //You may only register *one* BeforeSuite handler per test suite. You typically do so in your bootstrap file at the top level. func BeforeSuite(body interface{}, timeout ...float64) bool { - globalSuite.SetBeforeSuiteNode(body, codelocation.New(1), parseTimeout(timeout...)) + global.Suite.SetBeforeSuiteNode(body, codelocation.New(1), parseTimeout(timeout...)) return true } @@ -494,7 +497,7 @@ // //You may only register *one* AfterSuite handler per test suite. You typically do so in your bootstrap file at the top level. func AfterSuite(body interface{}, timeout ...float64) bool { - globalSuite.SetAfterSuiteNode(body, codelocation.New(1), parseTimeout(timeout...)) + global.Suite.SetAfterSuiteNode(body, codelocation.New(1), parseTimeout(timeout...)) return true } @@ -539,7 +542,7 @@ // Ω(err).ShouldNot(HaveOccurred()) // }) func SynchronizedBeforeSuite(node1Body interface{}, allNodesBody interface{}, timeout ...float64) bool { - globalSuite.SetSynchronizedBeforeSuiteNode( + global.Suite.SetSynchronizedBeforeSuiteNode( node1Body, allNodesBody, codelocation.New(1), @@ -566,7 +569,7 @@ // dbRunner.Stop() // }) func SynchronizedAfterSuite(allNodesBody interface{}, node1Body interface{}, timeout ...float64) bool { - globalSuite.SetSynchronizedAfterSuiteNode( + global.Suite.SetSynchronizedAfterSuiteNode( allNodesBody, node1Body, codelocation.New(1), @@ -581,7 +584,7 @@ //Like It blocks, BeforeEach blocks can be made asynchronous by providing a body function that accepts //a Done channel func BeforeEach(body interface{}, timeout ...float64) bool { - globalSuite.PushBeforeEachNode(body, codelocation.New(1), parseTimeout(timeout...)) + global.Suite.PushBeforeEachNode(body, codelocation.New(1), parseTimeout(timeout...)) return true } @@ -591,7 +594,7 @@ //Like It blocks, BeforeEach blocks can be made asynchronous by providing a body function that accepts //a Done channel func JustBeforeEach(body interface{}, timeout ...float64) bool { - globalSuite.PushJustBeforeEachNode(body, codelocation.New(1), parseTimeout(timeout...)) + global.Suite.PushJustBeforeEachNode(body, codelocation.New(1), parseTimeout(timeout...)) return true } @@ -601,7 +604,7 @@ //Like It blocks, JustAfterEach blocks can be made asynchronous by providing a body function that accepts //a Done channel func JustAfterEach(body interface{}, timeout ...float64) bool { - globalSuite.PushJustAfterEachNode(body, codelocation.New(1), parseTimeout(timeout...)) + global.Suite.PushJustAfterEachNode(body, codelocation.New(1), parseTimeout(timeout...)) return true } @@ -611,13 +614,13 @@ //Like It blocks, AfterEach blocks can be made asynchronous by providing a body function that accepts //a Done channel func AfterEach(body interface{}, timeout ...float64) bool { - globalSuite.PushAfterEachNode(body, codelocation.New(1), parseTimeout(timeout...)) + global.Suite.PushAfterEachNode(body, codelocation.New(1), parseTimeout(timeout...)) return true } func parseTimeout(timeout ...float64) time.Duration { if len(timeout) == 0 { - return time.Duration(defaultTimeout * int64(time.Second)) + return global.DefaultTimeout } else { return time.Duration(timeout[0] * float64(time.Second)) } diff -Nru golang-ginkgo-1.12.0/go.mod golang-ginkgo-1.14.2/go.mod --- golang-ginkgo-1.12.0/go.mod 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/go.mod 2020-10-12 17:59:23.000000000 +0000 @@ -1,9 +1,11 @@ module github.com/onsi/ginkgo require ( - github.com/hpcloud/tail v1.0.0 - github.com/onsi/gomega v1.7.1 - golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e + github.com/fsnotify/fsnotify v1.4.9 // indirect + github.com/nxadm/tail v1.4.4 + github.com/onsi/gomega v1.10.1 + golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 + golang.org/x/text v0.3.2 // indirect ) -go 1.12 +go 1.13 diff -Nru golang-ginkgo-1.12.0/go.sum golang-ginkgo-1.14.2/go.sum --- golang-ginkgo-1.12.0/go.sum 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/go.sum 2020-10-12 17:59:23.000000000 +0000 @@ -1,21 +1,60 @@ github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/gomega v1.7.1 h1:K0jcRCwNQM3vFGh1ppMtDh/+7ApJrjldlX8fA0jDTLQ= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7 h1:AeiKBIuRw3UomYXSbLy0Mc2dDLfdtbT/IVn4keq83P0= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e h1:N7DeIrjYszNmSW409R3frPPwglRwMkXSBzwVbkOjLLA= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 h1:DYfZAGf2WMFjMxbgTjaC+2HC7NkNAQs+6Q8b9WEB/F4= +golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= @@ -24,3 +63,5 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff -Nru golang-ginkgo-1.12.0/integration/coverage_test.go golang-ginkgo-1.14.2/integration/coverage_test.go --- golang-ginkgo-1.12.0/integration/coverage_test.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/integration/coverage_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -18,6 +18,7 @@ AfterEach(func() { removeSuccessfully("./_fixtures/coverage_fixture/coverage_fixture.coverprofile") }) + It("works", func() { session := startGinkgo("./_fixtures/coverage_fixture", "-cover") Eventually(session).Should(gexec.Exit(0)) diff -Nru golang-ginkgo-1.12.0/integration/fail_test.go golang-ginkgo-1.14.2/integration/fail_test.go --- golang-ginkgo-1.12.0/integration/fail_test.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/integration/fail_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -21,12 +21,12 @@ Ω(output).ShouldNot(ContainSubstring("NEVER SEE THIS")) - Ω(output).Should(ContainSubstring("a top level failure on line 9")) - Ω(output).Should(ContainSubstring("fail_fixture_test.go:9")) - Ω(output).Should(ContainSubstring("an async top level failure on line 14")) - Ω(output).Should(ContainSubstring("fail_fixture_test.go:14")) - Ω(output).Should(ContainSubstring("a top level goroutine failure on line 21")) - Ω(output).Should(ContainSubstring("fail_fixture_test.go:21")) + Ω(output).Should(ContainSubstring("a top level failure on line 10")) + Ω(output).Should(ContainSubstring("fail_fixture_test.go:10")) + Ω(output).Should(ContainSubstring("an async top level failure on line 15")) + Ω(output).Should(ContainSubstring("fail_fixture_test.go:15")) + Ω(output).Should(ContainSubstring("a top level goroutine failure on line 22")) + Ω(output).Should(ContainSubstring("fail_fixture_test.go:22")) Ω(output).Should(ContainSubstring("a sync failure")) Ω(output).Should(MatchRegexp(`Test Panicked\n\s+a sync panic`)) @@ -47,9 +47,16 @@ Ω(output).ShouldNot(ContainSubstring("ginkgo_dsl.go")) // depending on the go version this could be the first line of the Specify // block (>= go1.9) or the last line of the Specify block (< go1.9) - Ω(output).Should(Or(ContainSubstring("fail_fixture_test.go:101"), ContainSubstring("fail_fixture_test.go:103"))) - Ω(output).Should(ContainSubstring("fail_fixture_test.go:102")) + Ω(output).Should(Or(ContainSubstring("fail_fixture_test.go:102"), ContainSubstring("fail_fixture_test.go:104"))) + Ω(output).Should(ContainSubstring("fail_fixture_test.go:103")) - Ω(output).Should(ContainSubstring("0 Passed | 17 Failed")) + Ω(output).ShouldNot(ContainSubstring("table.go")) + Ω(output).Should(MatchRegexp(`a top level DescribeTable\n.*fail_fixture_test\.go:106`), + "the output of a failing DescribeTable should include its file path and line number") + Ω(output).ShouldNot(ContainSubstring("table_entry.go")) + Ω(output).Should(MatchRegexp(`a TableEntry constructed by Entry \[It\]\n.*fail_fixture_test\.go:110`), + "the output of a failing Entry should include its file path and line number") + + Ω(output).Should(ContainSubstring("0 Passed | 19 Failed")) }) }) diff -Nru golang-ginkgo-1.12.0/integration/_fixtures/fail_fixture/fail_fixture_test.go golang-ginkgo-1.14.2/integration/_fixtures/fail_fixture/fail_fixture_test.go --- golang-ginkgo-1.12.0/integration/_fixtures/fail_fixture/fail_fixture_test.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/integration/_fixtures/fail_fixture/fail_fixture_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -2,23 +2,24 @@ import ( . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/extensions/table" . "github.com/onsi/gomega" ) var _ = It("handles top level failures", func() { - Ω("a top level failure on line 9").Should(Equal("nope")) + Ω("a top level failure on line 10").Should(Equal("nope")) println("NEVER SEE THIS") }) var _ = It("handles async top level failures", func(done Done) { - Fail("an async top level failure on line 14") + Fail("an async top level failure on line 15") println("NEVER SEE THIS") }, 0.1) var _ = It("FAIL in a goroutine", func(done Done) { go func() { defer GinkgoRecover() - Fail("a top level goroutine failure on line 21") + Fail("a top level goroutine failure on line 22") println("NEVER SEE THIS") }() }, 0.1) @@ -101,3 +102,16 @@ var _ = Specify("a top level specify", func() { Fail("fail the test") }) + +var _ = DescribeTable("a top level DescribeTable", + func(x, y int) { + Expect(x).To(Equal(y)) + }, + Entry("a TableEntry constructed by Entry", 2, 3), + TableEntry{ + Description: "a directly constructed TableEntry", + Parameters: []interface{}{2, 3}, + Pending: false, + Focused: false, + }, +) diff -Nru golang-ginkgo-1.12.0/integration/_fixtures/focused_fixture/internal/focused_fixture_suite_test.go golang-ginkgo-1.14.2/integration/_fixtures/focused_fixture/internal/focused_fixture_suite_test.go --- golang-ginkgo-1.12.0/integration/_fixtures/focused_fixture/internal/focused_fixture_suite_test.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/integration/_fixtures/focused_fixture/internal/focused_fixture_suite_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -0,0 +1,13 @@ +package focused_fixture_test + +import ( + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "testing" +) + +func TestFocused_fixture(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Focused_fixture Suite") +} diff -Nru golang-ginkgo-1.12.0/integration/_fixtures/focused_fixture/internal/focused_fixture_test.go golang-ginkgo-1.14.2/integration/_fixtures/focused_fixture/internal/focused_fixture_test.go --- golang-ginkgo-1.12.0/integration/_fixtures/focused_fixture/internal/focused_fixture_test.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/integration/_fixtures/focused_fixture/internal/focused_fixture_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -0,0 +1,73 @@ +package focused_fixture_test + +import ( + . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/extensions/table" +) + +var _ = Describe("FocusedFixture", func() { + FDescribe("focused", func() { + It("focused", func() { + + }) + }) + + FContext("focused", func() { + It("focused", func() { + + }) + }) + + FWhen("focused", func() { + It("focused", func() { + + }) + }) + + FIt("focused", func() { + + }) + + FSpecify("focused", func() { + + }) + + FMeasure("focused", func(b Benchmarker) { + + }, 2) + + FDescribeTable("focused", + func() {}, + Entry("focused"), + ) + + DescribeTable("focused", + func() {}, + FEntry("focused"), + ) + + Describe("not focused", func() { + It("not focused", func() { + + }) + }) + + Context("not focused", func() { + It("not focused", func() { + + }) + }) + + It("not focused", func() { + + }) + + Measure("not focused", func(b Benchmarker) { + + }, 2) + + DescribeTable("not focused", + func() {}, + Entry("not focused"), + ) +}) diff -Nru golang-ginkgo-1.12.0/integration/_fixtures/watch_fixtures/A/A.go golang-ginkgo-1.14.2/integration/_fixtures/watch_fixtures/A/A.go --- golang-ginkgo-1.12.0/integration/_fixtures/watch_fixtures/A/A.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/integration/_fixtures/watch_fixtures/A/A.go 2020-10-12 17:59:23.000000000 +0000 @@ -1,6 +1,6 @@ package A -import "github.com/onsi/B" +import "$ROOT_PATH$/B" func DoIt() string { return B.DoIt() diff -Nru golang-ginkgo-1.12.0/integration/_fixtures/watch_fixtures/A/A_test.go golang-ginkgo-1.14.2/integration/_fixtures/watch_fixtures/A/A_test.go --- golang-ginkgo-1.12.0/integration/_fixtures/watch_fixtures/A/A_test.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/integration/_fixtures/watch_fixtures/A/A_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -1,7 +1,7 @@ package A_test import ( - . "github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/A" + . "$ROOT_PATH$/A" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff -Nru golang-ginkgo-1.12.0/integration/_fixtures/watch_fixtures/B/B.go golang-ginkgo-1.14.2/integration/_fixtures/watch_fixtures/B/B.go --- golang-ginkgo-1.12.0/integration/_fixtures/watch_fixtures/B/B.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/integration/_fixtures/watch_fixtures/B/B.go 2020-10-12 17:59:23.000000000 +0000 @@ -1,6 +1,6 @@ package B -import "github.com/onsi/C" +import "$ROOT_PATH$/C" func DoIt() string { return C.DoIt() diff -Nru golang-ginkgo-1.12.0/integration/_fixtures/watch_fixtures/B/B_test.go golang-ginkgo-1.14.2/integration/_fixtures/watch_fixtures/B/B_test.go --- golang-ginkgo-1.12.0/integration/_fixtures/watch_fixtures/B/B_test.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/integration/_fixtures/watch_fixtures/B/B_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -1,7 +1,7 @@ package B_test import ( - . "github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/B" + . "$ROOT_PATH$/B" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff -Nru golang-ginkgo-1.12.0/integration/_fixtures/watch_fixtures/C/C_test.go golang-ginkgo-1.14.2/integration/_fixtures/watch_fixtures/C/C_test.go --- golang-ginkgo-1.12.0/integration/_fixtures/watch_fixtures/C/C_test.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/integration/_fixtures/watch_fixtures/C/C_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -1,7 +1,7 @@ package C_test import ( - . "github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C" + . "$ROOT_PATH$/C" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff -Nru golang-ginkgo-1.12.0/integration/_fixtures/watch_fixtures/D/D.go golang-ginkgo-1.14.2/integration/_fixtures/watch_fixtures/D/D.go --- golang-ginkgo-1.12.0/integration/_fixtures/watch_fixtures/D/D.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/integration/_fixtures/watch_fixtures/D/D.go 2020-10-12 17:59:23.000000000 +0000 @@ -1,6 +1,6 @@ package D -import "github.com/onsi/C" +import "$ROOT_PATH$/C" func DoIt() string { return C.DoIt() diff -Nru golang-ginkgo-1.12.0/integration/_fixtures/watch_fixtures/D/D_test.go golang-ginkgo-1.14.2/integration/_fixtures/watch_fixtures/D/D_test.go --- golang-ginkgo-1.12.0/integration/_fixtures/watch_fixtures/D/D_test.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/integration/_fixtures/watch_fixtures/D/D_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -1,7 +1,7 @@ package D_test import ( - . "github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C" + . "$ROOT_PATH$/D" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff -Nru golang-ginkgo-1.12.0/integration/flags_test.go golang-ginkgo-1.14.2/integration/flags_test.go --- golang-ginkgo-1.12.0/integration/flags_test.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/integration/flags_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -106,6 +106,9 @@ }) It("should run the race detector when told to", func() { + if !raceDetectorSupported() { + Skip("race detection is not supported") + } session := startGinkgo(pathToTest, "--noColor", "--race") Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE)) output := string(session.Out.Contents()) @@ -164,7 +167,7 @@ output := string(session.Out.Contents()) Ω(output).Should(ContainSubstring("1 Failed")) - Ω(output).Should(ContainSubstring("16 Skipped")) + Ω(output).Should(ContainSubstring("18 Skipped")) }) Context("with a flaky test", func() { @@ -187,7 +190,7 @@ output := string(session.Out.Contents()) Ω(output).Should(ContainSubstring("synchronous failures")) - Ω(output).Should(ContainSubstring("17 Specs")) + Ω(output).Should(ContainSubstring("19 Specs")) Ω(output).Should(ContainSubstring("0 Passed")) Ω(output).Should(ContainSubstring("0 Failed")) }) diff -Nru golang-ginkgo-1.12.0/integration/integration_suite_test.go golang-ginkgo-1.14.2/integration/integration_suite_test.go --- golang-ginkgo-1.12.0/integration/integration_suite_test.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/integration/integration_suite_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -1,11 +1,13 @@ package integration_test import ( + "fmt" "io" "io/ioutil" "os" "os/exec" "path/filepath" + "runtime" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -25,7 +27,7 @@ } var _ = SynchronizedBeforeSuite(func() []byte { - pathToGinkgo, err := gexec.Build("github.com/onsi/ginkgo/ginkgo") + pathToGinkgo, err := gexec.Build("../ginkgo") Ω(err).ShouldNot(HaveOccurred()) return []byte(pathToGinkgo) }, func(computedPathToGinkgo []byte) { @@ -33,8 +35,8 @@ }) var _ = BeforeEach(func() { - var err error - tmpDir, err = ioutil.TempDir("", "ginkgo-run") + tmpDir = fmt.Sprintf("./ginko-run-%d", GinkgoParallelNode()) + err := os.Mkdir(tmpDir, 0700) Ω(err).ShouldNot(HaveOccurred()) }) @@ -44,6 +46,7 @@ }) var _ = SynchronizedAfterSuite(func() {}, func() { + os.RemoveAll(tmpDir) gexec.CleanupBuildArtifacts() }) @@ -127,3 +130,15 @@ err := os.RemoveAll(path) Expect(err).NotTo(HaveOccurred()) } + +func raceDetectorSupported() bool { + // https://github.com/golang/go/blob/1a370950/src/cmd/internal/sys/supported.go#L12 + switch runtime.GOOS { + case "linux": + return runtime.GOARCH == "amd64" || runtime.GOARCH == "ppc64le" || runtime.GOARCH == "arm64" + case "darwin", "freebsd", "netbsd", "windows": + return runtime.GOARCH == "amd64" + default: + return false + } +} diff -Nru golang-ginkgo-1.12.0/integration/run_test.go golang-ginkgo-1.14.2/integration/run_test.go --- golang-ginkgo-1.12.0/integration/run_test.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/integration/run_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -50,7 +50,7 @@ }) It("should run the ginkgo style tests", func() { - session := startGinkgo(tmpDir, "--noColor", pathToTest) + session := startGinkgo(tmpDir, "--noColor", "ginkgo") Eventually(session).Should(gexec.Exit(0)) output := string(session.Out.Contents()) diff -Nru golang-ginkgo-1.12.0/integration/subcommand_test.go golang-ginkgo-1.14.2/integration/subcommand_test.go --- golang-ginkgo-1.12.0/integration/subcommand_test.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/integration/subcommand_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -98,7 +98,7 @@ func Test{{.FormattedName}}(t *testing.T) { // This is a {{.Package}} test }`), 0666) - session := startGinkgo(pkgPath, "bootstrap", "--template", templateFile) + session := startGinkgo(pkgPath, "bootstrap", "--template", ".bootstrap") Eventually(session).Should(gexec.Exit(0)) output := session.Out.Contents() @@ -311,7 +311,7 @@ Describe("ginkgo bootstrap/generate", func() { var pkgPath string BeforeEach(func() { - pkgPath = tmpPath("some crazy-thing") + pkgPath = tmpPath("some-crazy-thing") os.Mkdir(pkgPath, 0777) }) @@ -404,25 +404,25 @@ It("should unfocus tests", func() { pathToTest := tmpPath("focused") fixture := fixturePath("focused_fixture") - copyIn(fixture, pathToTest, false) + copyIn(fixture, pathToTest, true) - session := startGinkgo(pathToTest, "--noColor") + session := startGinkgo(pathToTest, "--noColor", "-r") Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE)) output := session.Out.Contents() - Ω(string(output)).Should(ContainSubstring("8 Passed")) - Ω(string(output)).Should(ContainSubstring("5 Skipped")) + Ω(string(output)).Should(ContainSubstring("Detected Programmatic Focus")) session = startGinkgo(pathToTest, "blur") Eventually(session).Should(gexec.Exit(0)) output = session.Out.Contents() Ω(string(output)).ShouldNot(ContainSubstring("expected 'package'")) - session = startGinkgo(pathToTest, "--noColor") + session = startGinkgo(pathToTest, "--noColor", "-r") Eventually(session).Should(gexec.Exit(0)) output = session.Out.Contents() - Ω(string(output)).Should(ContainSubstring("13 Passed")) - Ω(string(output)).Should(ContainSubstring("0 Skipped")) + Ω(string(output)).Should(ContainSubstring("Ginkgo ran 2 suites")) + Ω(string(output)).Should(ContainSubstring("Test Suite Passed")) + Ω(string(output)).ShouldNot(ContainSubstring("Detected Programmatic Focus")) Expect(sameFile(filepath.Join(pathToTest, "README.md"), filepath.Join(fixture, "README.md"))).To(BeTrue()) }) diff -Nru golang-ginkgo-1.12.0/integration/verbose_and_succinct_test.go golang-ginkgo-1.14.2/integration/verbose_and_succinct_test.go --- golang-ginkgo-1.12.0/integration/verbose_and_succinct_test.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/integration/verbose_and_succinct_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -45,7 +45,7 @@ Context("with no flags set", func() { It("should default to succinct mode", func() { - session := startGinkgo(pathToTest, "--noColor", pathToTest, otherPathToTest) + session := startGinkgo(tmpDir, "--noColor", "ginkgo", "more_ginkgo") Eventually(session).Should(gexec.Exit(0)) output := session.Out.Contents() @@ -56,7 +56,7 @@ Context("with --succinct=false", func() { It("should not be in succinct mode", func() { - session := startGinkgo(pathToTest, "--noColor", "--succinct=false", pathToTest, otherPathToTest) + session := startGinkgo(tmpDir, "--noColor", "--succinct=false", "ginkgo", "more_ginkgo") Eventually(session).Should(gexec.Exit(0)) output := session.Out.Contents() @@ -67,7 +67,7 @@ Context("with -v", func() { It("should not be in succinct mode, but should be verbose", func() { - session := startGinkgo(pathToTest, "--noColor", "-v", pathToTest, otherPathToTest) + session := startGinkgo(tmpDir, "--noColor", "-v", "ginkgo", "more_ginkgo") Eventually(session).Should(gexec.Exit(0)) output := session.Out.Contents() @@ -78,7 +78,7 @@ }) It("should emit output from Bys", func() { - session := startGinkgo(pathToTest, "--noColor", "-v", pathToTest) + session := startGinkgo(tmpDir, "--noColor", "-v", "ginkgo") Eventually(session).Should(gexec.Exit(0)) output := session.Out.Contents() diff -Nru golang-ginkgo-1.12.0/integration/watch_test.go golang-ginkgo-1.14.2/integration/watch_test.go --- golang-ginkgo-1.12.0/integration/watch_test.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/integration/watch_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -4,6 +4,7 @@ "io/ioutil" "os" "path/filepath" + "strings" "time" . "github.com/onsi/ginkgo" @@ -19,11 +20,31 @@ var pathC string var session *gexec.Session + fixUpImportPath := func(path string) { + files, err := ioutil.ReadDir(path) + Expect(err).NotTo(HaveOccurred()) + + for _, f := range files { + filePath := filepath.Join(path, f.Name()) + + r, err := os.Open(filePath) + Ω(err).ShouldNot(HaveOccurred()) + + src, err := ioutil.ReadAll(r) + Ω(err).ShouldNot(HaveOccurred()) + out := strings.ReplaceAll(string(src), "$ROOT_PATH$", "github.com/onsi/ginkgo/integration/"+rootPath) + r.Close() + + err = ioutil.WriteFile(filePath, []byte(out), 0666) + Ω(err).ShouldNot(HaveOccurred()) + } + } + BeforeEach(func() { rootPath = tmpPath("root") - pathA = filepath.Join(rootPath, "src", "github.com", "onsi", "A") - pathB = filepath.Join(rootPath, "src", "github.com", "onsi", "B") - pathC = filepath.Join(rootPath, "src", "github.com", "onsi", "C") + pathA = filepath.Join(rootPath, "A") + pathB = filepath.Join(rootPath, "B") + pathC = filepath.Join(rootPath, "C") err := os.MkdirAll(pathA, 0700) Ω(err).ShouldNot(HaveOccurred()) @@ -35,18 +56,13 @@ Ω(err).ShouldNot(HaveOccurred()) copyIn(fixturePath(filepath.Join("watch_fixtures", "A")), pathA, false) + fixUpImportPath(pathA) copyIn(fixturePath(filepath.Join("watch_fixtures", "B")), pathB, false) + fixUpImportPath(pathB) copyIn(fixturePath(filepath.Join("watch_fixtures", "C")), pathC, false) + fixUpImportPath(pathC) }) - startGinkgoWithGopath := func(args ...string) *gexec.Session { - cmd := ginkgoCommand(rootPath, args...) - os.Setenv("GOPATH", rootPath+":"+os.Getenv("GOPATH")) - session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter) - Ω(err).ShouldNot(HaveOccurred()) - return session - } - modifyFile := func(path string) { time.Sleep(time.Second) content, err := ioutil.ReadFile(path) @@ -57,15 +73,15 @@ } modifyCode := func(pkgToModify string) { - modifyFile(filepath.Join(rootPath, "src", "github.com", "onsi", pkgToModify, pkgToModify+".go")) + modifyFile(filepath.Join(rootPath, pkgToModify, pkgToModify+".go")) } modifyJSON := func(pkgToModify string) { - modifyFile(filepath.Join(rootPath, "src", "github.com", "onsi", pkgToModify, pkgToModify+".json")) + modifyFile(filepath.Join(rootPath, pkgToModify, pkgToModify+".json")) } modifyTest := func(pkgToModify string) { - modifyFile(filepath.Join(rootPath, "src", "github.com", "onsi", pkgToModify, pkgToModify+"_test.go")) + modifyFile(filepath.Join(rootPath, pkgToModify, pkgToModify+"_test.go")) } AfterEach(func() { @@ -75,7 +91,7 @@ }) It("should be set up correctly", func() { - session = startGinkgoWithGopath("-r") + session = startGinkgo(rootPath, "-r") Eventually(session).Should(gexec.Exit(0)) Ω(session.Out.Contents()).Should(ContainSubstring("A Suite")) Ω(session.Out.Contents()).Should(ContainSubstring("B Suite")) @@ -85,7 +101,7 @@ Context("when watching just one test suite", func() { It("should immediately run, and should rerun when the test suite changes", func() { - session = startGinkgoWithGopath("watch", "-succinct", pathA) + session = startGinkgo(rootPath, "watch", "-succinct", "A") Eventually(session).Should(gbytes.Say("A Suite")) modifyCode("A") Eventually(session).Should(gbytes.Say("Detected changes in")) @@ -96,7 +112,7 @@ Context("when watching several test suites", func() { It("should not immediately run, but should rerun a test when its code changes", func() { - session = startGinkgoWithGopath("watch", "-succinct", "-r") + session = startGinkgo(rootPath, "watch", "-succinct", "-r") Eventually(session).Should(gbytes.Say("Identified 3 test suites")) Consistently(session).ShouldNot(gbytes.Say("A Suite|B Suite|C Suite")) modifyCode("A") @@ -110,11 +126,11 @@ Describe("watching dependencies", func() { Context("with a depth of 2", func() { It("should watch down to that depth", func() { - session = startGinkgoWithGopath("watch", "-succinct", "-r", "-depth=2") + session = startGinkgo(rootPath, "watch", "-succinct", "-r", "-depth=2") Eventually(session).Should(gbytes.Say("Identified 3 test suites")) - Eventually(session).Should(gbytes.Say(`A \[2 dependencies\]`)) - Eventually(session).Should(gbytes.Say(`B \[1 dependency\]`)) - Eventually(session).Should(gbytes.Say(`C \[0 dependencies\]`)) + Eventually(session).Should(gbytes.Say(`A \[`)) + Eventually(session).Should(gbytes.Say(`B \[`)) + Eventually(session).Should(gbytes.Say(`C \[`)) modifyCode("A") Eventually(session).Should(gbytes.Say("Detected changes in")) @@ -137,11 +153,11 @@ Context("with a depth of 1", func() { It("should watch down to that depth", func() { - session = startGinkgoWithGopath("watch", "-succinct", "-r", "-depth=1") + session = startGinkgo(rootPath, "watch", "-succinct", "-r", "-depth=1") Eventually(session).Should(gbytes.Say("Identified 3 test suites")) - Eventually(session).Should(gbytes.Say(`A \[1 dependency\]`)) - Eventually(session).Should(gbytes.Say(`B \[1 dependency\]`)) - Eventually(session).Should(gbytes.Say(`C \[0 dependencies\]`)) + Eventually(session).Should(gbytes.Say(`A \[`)) + Eventually(session).Should(gbytes.Say(`B \[`)) + Eventually(session).Should(gbytes.Say(`C \[`)) modifyCode("A") Eventually(session).Should(gbytes.Say("Detected changes in")) @@ -164,11 +180,11 @@ Context("with a depth of 0", func() { It("should not watch any dependencies", func() { - session = startGinkgoWithGopath("watch", "-succinct", "-r", "-depth=0") + session = startGinkgo(rootPath, "watch", "-succinct", "-r", "-depth=0") Eventually(session).Should(gbytes.Say("Identified 3 test suites")) - Eventually(session).Should(gbytes.Say(`A \[0 dependencies\]`)) - Eventually(session).Should(gbytes.Say(`B \[0 dependencies\]`)) - Eventually(session).Should(gbytes.Say(`C \[0 dependencies\]`)) + Eventually(session).Should(gbytes.Say(`A \[`)) + Eventually(session).Should(gbytes.Say(`B \[`)) + Eventually(session).Should(gbytes.Say(`C \[`)) modifyCode("A") Eventually(session).Should(gbytes.Say("Detected changes in")) @@ -188,11 +204,11 @@ }) It("should not trigger dependents when tests are changed", func() { - session = startGinkgoWithGopath("watch", "-succinct", "-r", "-depth=2") + session = startGinkgo(rootPath, "watch", "-succinct", "-r", "-depth=2") Eventually(session).Should(gbytes.Say("Identified 3 test suites")) - Eventually(session).Should(gbytes.Say(`A \[2 dependencies\]`)) - Eventually(session).Should(gbytes.Say(`B \[1 dependency\]`)) - Eventually(session).Should(gbytes.Say(`C \[0 dependencies\]`)) + Eventually(session).Should(gbytes.Say(`A \[`)) + Eventually(session).Should(gbytes.Say(`B \[`)) + Eventually(session).Should(gbytes.Say(`C \[`)) modifyTest("A") Eventually(session).Should(gbytes.Say("Detected changes in")) @@ -214,11 +230,11 @@ Describe("adjusting the watch regular expression", func() { Describe("the default regular expression", func() { It("should only trigger when go files are changed", func() { - session = startGinkgoWithGopath("watch", "-succinct", "-r", "-depth=2") + session = startGinkgo(rootPath, "watch", "-succinct", "-r", "-depth=2") Eventually(session).Should(gbytes.Say("Identified 3 test suites")) - Eventually(session).Should(gbytes.Say(`A \[2 dependencies\]`)) - Eventually(session).Should(gbytes.Say(`B \[1 dependency\]`)) - Eventually(session).Should(gbytes.Say(`C \[0 dependencies\]`)) + Eventually(session).Should(gbytes.Say(`A \[`)) + Eventually(session).Should(gbytes.Say(`B \[`)) + Eventually(session).Should(gbytes.Say(`C \[`)) modifyJSON("C") Consistently(session).ShouldNot(gbytes.Say("Detected changes in")) @@ -228,11 +244,11 @@ Describe("modifying the regular expression", func() { It("should trigger if the regexp matches", func() { - session = startGinkgoWithGopath("watch", "-succinct", "-r", "-depth=2", `-watchRegExp=\.json$`) + session = startGinkgo(rootPath, "watch", "-succinct", "-r", "-depth=2", `-watchRegExp=\.json$`) Eventually(session).Should(gbytes.Say("Identified 3 test suites")) - Eventually(session).Should(gbytes.Say(`A \[2 dependencies\]`)) - Eventually(session).Should(gbytes.Say(`B \[1 dependency\]`)) - Eventually(session).Should(gbytes.Say(`C \[0 dependencies\]`)) + Eventually(session).Should(gbytes.Say(`A \[`)) + Eventually(session).Should(gbytes.Say(`B \[`)) + Eventually(session).Should(gbytes.Say(`C \[`)) modifyJSON("C") Eventually(session).Should(gbytes.Say("Detected changes in")) @@ -245,19 +261,20 @@ Describe("when new test suite is added", func() { It("should start monitoring that test suite", func() { - session = startGinkgoWithGopath("watch", "-succinct", "-r") + session = startGinkgo(rootPath, "watch", "-succinct", "-r") Eventually(session).Should(gbytes.Say("Watching 3 suites")) - pathD := filepath.Join(rootPath, "src", "github.com", "onsi", "D") + pathD := filepath.Join(rootPath, "D") err := os.MkdirAll(pathD, 0700) Ω(err).ShouldNot(HaveOccurred()) copyIn(fixturePath(filepath.Join("watch_fixtures", "D")), pathD, false) + fixUpImportPath(pathD) Eventually(session).Should(gbytes.Say("Detected 1 new suite")) - Eventually(session).Should(gbytes.Say(`D \[1 dependency\]`)) + Eventually(session).Should(gbytes.Say(`D \[`)) Eventually(session).Should(gbytes.Say("D Suite")) modifyCode("D") diff -Nru golang-ginkgo-1.12.0/internal/global/init.go golang-ginkgo-1.14.2/internal/global/init.go --- golang-ginkgo-1.12.0/internal/global/init.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/global/init.go 2020-10-12 17:59:23.000000000 +0000 @@ -0,0 +1,22 @@ +package global + +import ( + "time" + + "github.com/onsi/ginkgo/internal/failer" + "github.com/onsi/ginkgo/internal/suite" +) + +const DefaultTimeout = time.Duration(1 * time.Second) + +var Suite *suite.Suite +var Failer *failer.Failer + +func init() { + InitializeGlobals() +} + +func InitializeGlobals() { + Failer = failer.New() + Suite = suite.New(Failer) +} diff -Nru golang-ginkgo-1.12.0/internal/leafnodes/shared_runner_test.go golang-ginkgo-1.14.2/internal/leafnodes/shared_runner_test.go --- golang-ginkgo-1.12.0/internal/leafnodes/shared_runner_test.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/leafnodes/shared_runner_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -47,7 +47,7 @@ }, 0, failer, componentCodeLocation).Run() }) - It("should have a succesful outcome", func() { + It("should have a successful outcome", func() { Ω(didRun).Should(BeTrue()) Ω(outcome).Should(Equal(types.SpecStatePassed)) @@ -166,7 +166,7 @@ }, timeoutDuration, failer, componentCodeLocation).Run() }) - It("should have a succesful outcome", func() { + It("should have a successful outcome", func() { Ω(didRun).Should(BeTrue()) Ω(outcome).Should(Equal(types.SpecStatePassed)) Ω(failure).Should(BeZero()) diff -Nru golang-ginkgo-1.12.0/internal/remote/aggregator.go golang-ginkgo-1.14.2/internal/remote/aggregator.go --- golang-ginkgo-1.12.0/internal/remote/aggregator.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/remote/aggregator.go 2020-10-12 17:59:23.000000000 +0000 @@ -197,11 +197,11 @@ switch specSummary.State { case types.SpecStatePassed: if specSummary.IsMeasurement { - aggregator.stenographer.AnnounceSuccesfulMeasurement(specSummary, aggregator.config.Succinct) + aggregator.stenographer.AnnounceSuccessfulMeasurement(specSummary, aggregator.config.Succinct) } else if specSummary.RunTime.Seconds() >= aggregator.config.SlowSpecThreshold { - aggregator.stenographer.AnnounceSuccesfulSlowSpec(specSummary, aggregator.config.Succinct) + aggregator.stenographer.AnnounceSuccessfulSlowSpec(specSummary, aggregator.config.Succinct) } else { - aggregator.stenographer.AnnounceSuccesfulSpec(specSummary) + aggregator.stenographer.AnnounceSuccessfulSpec(specSummary) } case types.SpecStatePending: diff -Nru golang-ginkgo-1.12.0/internal/remote/aggregator_test.go golang-ginkgo-1.14.2/internal/remote/aggregator_test.go --- golang-ginkgo-1.12.0/internal/remote/aggregator_test.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/remote/aggregator_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -160,7 +160,7 @@ It("should announce the specs, the before suites and the after suites", func() { Eventually(func() interface{} { return stenographer.Calls() - }).Should(ContainElement(call("AnnounceSuccesfulSpec", specSummary))) + }).Should(ContainElement(call("AnnounceSuccessfulSpec", specSummary))) Ω(stenographer.Calls()).Should(ContainElement(call("AnnounceCapturedOutput", beforeSummary.CapturedOutput))) Ω(stenographer.Calls()).Should(ContainElement(call("AnnounceCapturedOutput", afterSummary.CapturedOutput))) @@ -197,7 +197,7 @@ }) It("should announce completion", func() { - Ω(stenographer.Calls()[3]).Should(Equal(call("AnnounceSuccesfulSpec", specSummary))) + Ω(stenographer.Calls()[3]).Should(Equal(call("AnnounceSuccessfulSpec", specSummary))) }) It("should announce the captured output of the AfterSuite", func() { diff -Nru golang-ginkgo-1.12.0/internal/remote/output_interceptor_darwin.go golang-ginkgo-1.14.2/internal/remote/output_interceptor_darwin.go --- golang-ginkgo-1.12.0/internal/remote/output_interceptor_darwin.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/remote/output_interceptor_darwin.go 2020-10-12 17:59:23.000000000 +0000 @@ -0,0 +1,11 @@ +// +build darwin + +package remote + +import ( + "golang.org/x/sys/unix" +) + +func interceptorDupx(oldfd int, newfd int) { + unix.Dup2(oldfd, newfd) +} diff -Nru golang-ginkgo-1.12.0/internal/remote/output_interceptor_dragonfly.go golang-ginkgo-1.14.2/internal/remote/output_interceptor_dragonfly.go --- golang-ginkgo-1.12.0/internal/remote/output_interceptor_dragonfly.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/remote/output_interceptor_dragonfly.go 2020-10-12 17:59:23.000000000 +0000 @@ -0,0 +1,11 @@ +// +build dragonfly + +package remote + +import ( + "golang.org/x/sys/unix" +) + +func interceptorDupx(oldfd int, newfd int) { + unix.Dup2(oldfd, newfd) +} diff -Nru golang-ginkgo-1.12.0/internal/remote/output_interceptor_freebsd.go golang-ginkgo-1.14.2/internal/remote/output_interceptor_freebsd.go --- golang-ginkgo-1.12.0/internal/remote/output_interceptor_freebsd.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/remote/output_interceptor_freebsd.go 2020-10-12 17:59:23.000000000 +0000 @@ -0,0 +1,11 @@ +// +build freebsd + +package remote + +import ( + "golang.org/x/sys/unix" +) + +func interceptorDupx(oldfd int, newfd int) { + unix.Dup2(oldfd, newfd) +} diff -Nru golang-ginkgo-1.12.0/internal/remote/output_interceptor_linux.go golang-ginkgo-1.14.2/internal/remote/output_interceptor_linux.go --- golang-ginkgo-1.12.0/internal/remote/output_interceptor_linux.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/remote/output_interceptor_linux.go 2020-10-12 17:59:23.000000000 +0000 @@ -0,0 +1,12 @@ +// +build linux +// +build !mips64le + +package remote + +import ( + "golang.org/x/sys/unix" +) + +func interceptorDupx(oldfd int, newfd int) { + unix.Dup2(oldfd, newfd) +} diff -Nru golang-ginkgo-1.12.0/internal/remote/output_interceptor_linux_mips64le.go golang-ginkgo-1.14.2/internal/remote/output_interceptor_linux_mips64le.go --- golang-ginkgo-1.12.0/internal/remote/output_interceptor_linux_mips64le.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/remote/output_interceptor_linux_mips64le.go 2020-10-12 17:59:23.000000000 +0000 @@ -0,0 +1,12 @@ +// +build linux +// +build mips64le + +package remote + +import ( + "golang.org/x/sys/unix" +) + +func interceptorDupx(oldfd int, newfd int) { + unix.Dup3(oldfd, newfd, 0) +} diff -Nru golang-ginkgo-1.12.0/internal/remote/output_interceptor_netbsd.go golang-ginkgo-1.14.2/internal/remote/output_interceptor_netbsd.go --- golang-ginkgo-1.12.0/internal/remote/output_interceptor_netbsd.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/remote/output_interceptor_netbsd.go 2020-10-12 17:59:23.000000000 +0000 @@ -0,0 +1,11 @@ +// +build netbsd + +package remote + +import ( + "golang.org/x/sys/unix" +) + +func interceptorDupx(oldfd int, newfd int) { + unix.Dup2(oldfd, newfd) +} diff -Nru golang-ginkgo-1.12.0/internal/remote/output_interceptor_openbsd.go golang-ginkgo-1.14.2/internal/remote/output_interceptor_openbsd.go --- golang-ginkgo-1.12.0/internal/remote/output_interceptor_openbsd.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/remote/output_interceptor_openbsd.go 2020-10-12 17:59:23.000000000 +0000 @@ -0,0 +1,11 @@ +// +build openbsd + +package remote + +import ( + "golang.org/x/sys/unix" +) + +func interceptorDupx(oldfd int, newfd int) { + unix.Dup2(oldfd, newfd) +} diff -Nru golang-ginkgo-1.12.0/internal/remote/output_interceptor_solaris.go golang-ginkgo-1.14.2/internal/remote/output_interceptor_solaris.go --- golang-ginkgo-1.12.0/internal/remote/output_interceptor_solaris.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/remote/output_interceptor_solaris.go 2020-10-12 17:59:23.000000000 +0000 @@ -0,0 +1,11 @@ +// +build solaris + +package remote + +import ( + "golang.org/x/sys/unix" +) + +func interceptorDupx(oldfd int, newfd int) { + unix.Dup2(oldfd, newfd) +} diff -Nru golang-ginkgo-1.12.0/internal/remote/output_interceptor_unix.go golang-ginkgo-1.14.2/internal/remote/output_interceptor_unix.go --- golang-ginkgo-1.12.0/internal/remote/output_interceptor_unix.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/remote/output_interceptor_unix.go 2020-10-12 17:59:23.000000000 +0000 @@ -7,7 +7,7 @@ "io/ioutil" "os" - "github.com/hpcloud/tail" + "github.com/nxadm/tail" ) func NewOutputInterceptor() OutputInterceptor { @@ -35,12 +35,8 @@ return err } - // Call a function in ./syscall_dup_*.go - // If building for everything other than linux_arm64, - // use a "normal" syscall.Dup2(oldfd, newfd) call. If building for linux_arm64 (which doesn't have syscall.Dup2) - // call syscall.Dup3(oldfd, newfd, 0). They are nearly identical, see: http://linux.die.net/man/2/dup3 - syscallDup(int(interceptor.redirectFile.Fd()), 1) - syscallDup(int(interceptor.redirectFile.Fd()), 2) + interceptorDupx(int(interceptor.redirectFile.Fd()), 1) + interceptorDupx(int(interceptor.redirectFile.Fd()), 2) if interceptor.streamTarget != nil { interceptor.tailer, _ = tail.TailFile(interceptor.redirectFile.Name(), tail.Config{Follow: true}) diff -Nru golang-ginkgo-1.12.0/internal/remote/syscall_dup_linux_arm64.go golang-ginkgo-1.14.2/internal/remote/syscall_dup_linux_arm64.go --- golang-ginkgo-1.12.0/internal/remote/syscall_dup_linux_arm64.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/remote/syscall_dup_linux_arm64.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// +build linux,arm64 - -package remote - -import "syscall" - -// linux_arm64 doesn't have syscall.Dup2 which ginkgo uses, so -// use the nearly identical syscall.Dup3 instead -func syscallDup(oldfd int, newfd int) (err error) { - return syscall.Dup3(oldfd, newfd, 0) -} diff -Nru golang-ginkgo-1.12.0/internal/remote/syscall_dup_linux_riscv64.go golang-ginkgo-1.14.2/internal/remote/syscall_dup_linux_riscv64.go --- golang-ginkgo-1.12.0/internal/remote/syscall_dup_linux_riscv64.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/remote/syscall_dup_linux_riscv64.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// +build linux,riscv64 - -package remote - -import "syscall" - -// linux_riscv64 doesn't have syscall.Dup2 which ginkgo uses, so -// use the nearly identical syscall.Dup3 instead -func syscallDup(oldfd int, newfd int) (err error) { - return syscall.Dup3(oldfd, newfd, 0) -} diff -Nru golang-ginkgo-1.12.0/internal/remote/syscall_dup_solaris.go golang-ginkgo-1.14.2/internal/remote/syscall_dup_solaris.go --- golang-ginkgo-1.12.0/internal/remote/syscall_dup_solaris.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/remote/syscall_dup_solaris.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// +build solaris - -package remote - -import "golang.org/x/sys/unix" - -func syscallDup(oldfd int, newfd int) (err error) { - return unix.Dup2(oldfd, newfd) -} diff -Nru golang-ginkgo-1.12.0/internal/remote/syscall_dup_unix.go golang-ginkgo-1.14.2/internal/remote/syscall_dup_unix.go --- golang-ginkgo-1.12.0/internal/remote/syscall_dup_unix.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/remote/syscall_dup_unix.go 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// +build !linux !arm64 -// +build !linux !riscv64 -// +build !windows -// +build !solaris - -package remote - -import "syscall" - -func syscallDup(oldfd int, newfd int) (err error) { - return syscall.Dup2(oldfd, newfd) -} diff -Nru golang-ginkgo-1.12.0/internal/suite/suite.go golang-ginkgo-1.14.2/internal/suite/suite.go --- golang-ginkgo-1.12.0/internal/suite/suite.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/suite/suite.go 2020-10-12 17:59:23.000000000 +0000 @@ -22,25 +22,37 @@ Fail() } +type deferredContainerNode struct { + text string + body func() + flag types.FlagType + codeLocation types.CodeLocation +} + type Suite struct { topLevelContainer *containernode.ContainerNode currentContainer *containernode.ContainerNode - containerIndex int - beforeSuiteNode leafnodes.SuiteNode - afterSuiteNode leafnodes.SuiteNode - runner *specrunner.SpecRunner - failer *failer.Failer - running bool + + deferredContainerNodes []deferredContainerNode + + containerIndex int + beforeSuiteNode leafnodes.SuiteNode + afterSuiteNode leafnodes.SuiteNode + runner *specrunner.SpecRunner + failer *failer.Failer + running bool + expandTopLevelNodes bool } func New(failer *failer.Failer) *Suite { topLevelContainer := containernode.New("[Top Level]", types.FlagTypeNone, types.CodeLocation{}) return &Suite{ - topLevelContainer: topLevelContainer, - currentContainer: topLevelContainer, - failer: failer, - containerIndex: 1, + topLevelContainer: topLevelContainer, + currentContainer: topLevelContainer, + failer: failer, + containerIndex: 1, + deferredContainerNodes: []deferredContainerNode{}, } } @@ -53,6 +65,11 @@ panic("ginkgo.parallel.node is one-indexed and must be <= ginkgo.parallel.total") } + suite.expandTopLevelNodes = true + for _, deferredNode := range suite.deferredContainerNodes { + suite.PushContainerNode(deferredNode.text, deferredNode.body, deferredNode.flag, deferredNode.codeLocation) + } + r := rand.New(rand.NewSource(config.RandomSeed)) suite.topLevelContainer.Shuffle(r) iterator, hasProgrammaticFocus := suite.generateSpecsIterator(description, config) @@ -102,6 +119,9 @@ } func (suite *Suite) CurrentRunningSpecSummary() (*types.SpecSummary, bool) { + if !suite.running { + return nil, false + } return suite.runner.CurrentSpecSummary() } @@ -134,6 +154,23 @@ } func (suite *Suite) PushContainerNode(text string, body func(), flag types.FlagType, codeLocation types.CodeLocation) { + /* + We defer walking the container nodes (which immediately evaluates the `body` function) + until `RunSpecs` is called. We do this by storing off the deferred container nodes. Then, when + `RunSpecs` is called we actually go through and add the container nodes to the test structure. + + This allows us to defer calling all the `body` functions until _after_ the top level functions + have been walked, _after_ func init()s have been called, and _after_ `go test` has called `flag.Parse()`. + + This allows users to load up configuration information in the `TestX` go test hook just before `RunSpecs` + is invoked and solves issues like #693 and makes the lifecycle easier to reason about. + + */ + if !suite.expandTopLevelNodes { + suite.deferredContainerNodes = append(suite.deferredContainerNodes, deferredContainerNode{text, body, flag, codeLocation}) + return + } + container := containernode.New(text, flag, codeLocation) suite.currentContainer.PushContainerNode(container) diff -Nru golang-ginkgo-1.12.0/internal/suite/suite_suite_test.go golang-ginkgo-1.14.2/internal/suite/suite_suite_test.go --- golang-ginkgo-1.12.0/internal/suite/suite_suite_test.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/suite/suite_suite_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -1,19 +1,25 @@ package suite_test import ( + "fmt" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "testing" ) +var dynamicallyGeneratedTests = []string{} + func Test(t *testing.T) { RegisterFailHandler(Fail) + dynamicallyGeneratedTests = []string{"Test A", "Test B", "Test C"} RunSpecs(t, "Suite") } var numBeforeSuiteRuns = 0 var numAfterSuiteRuns = 0 +var numDynamicallyGeneratedTests = 0 var _ = BeforeSuite(func() { numBeforeSuiteRuns++ @@ -23,6 +29,16 @@ numAfterSuiteRuns++ Ω(numBeforeSuiteRuns).Should(Equal(1)) Ω(numAfterSuiteRuns).Should(Equal(1)) + Ω(numDynamicallyGeneratedTests).Should(Equal(3), "Expected three test to be dynamically generated") +}) + +var _ = Describe("Top-level cotnainer node lifecycle", func() { + for _, test := range dynamicallyGeneratedTests { + numDynamicallyGeneratedTests += 1 + It(fmt.Sprintf("runs dynamically generated test: %s", test), func() { + Ω(true).Should(BeTrue()) + }) + } }) //Fakes diff -Nru golang-ginkgo-1.12.0/internal/testingtproxy/testing_t_proxy.go golang-ginkgo-1.14.2/internal/testingtproxy/testing_t_proxy.go --- golang-ginkgo-1.12.0/internal/testingtproxy/testing_t_proxy.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/testingtproxy/testing_t_proxy.go 2020-10-12 17:59:23.000000000 +0000 @@ -6,21 +6,34 @@ ) type failFunc func(message string, callerSkip ...int) +type skipFunc func(message string, callerSkip ...int) +type failedFunc func() bool +type nameFunc func() string -func New(writer io.Writer, fail failFunc, offset int) *ginkgoTestingTProxy { +func New(writer io.Writer, fail failFunc, skip skipFunc, failed failedFunc, name nameFunc, offset int) *ginkgoTestingTProxy { return &ginkgoTestingTProxy{ fail: fail, offset: offset, writer: writer, + skip: skip, + failed: failed, + name: name, } } type ginkgoTestingTProxy struct { fail failFunc + skip skipFunc + failed failedFunc + name nameFunc offset int writer io.Writer } +func (t *ginkgoTestingTProxy) Cleanup(func()) { + // No-op +} + func (t *ginkgoTestingTProxy) Error(args ...interface{}) { t.fail(fmt.Sprintln(args...), t.offset) } @@ -37,6 +50,10 @@ t.fail("failed", t.offset) } +func (t *ginkgoTestingTProxy) Failed() bool { + return t.failed() +} + func (t *ginkgoTestingTProxy) Fatal(args ...interface{}) { t.fail(fmt.Sprintln(args...), t.offset) } @@ -45,6 +62,10 @@ t.fail(fmt.Sprintf(format, args...), t.offset) } +func (t *ginkgoTestingTProxy) Helper() { + // No-op +} + func (t *ginkgoTestingTProxy) Log(args ...interface{}) { fmt.Fprintln(t.writer, args...) } @@ -53,24 +74,31 @@ t.Log(fmt.Sprintf(format, args...)) } -func (t *ginkgoTestingTProxy) Failed() bool { - return false +func (t *ginkgoTestingTProxy) Name() string { + return t.name() } func (t *ginkgoTestingTProxy) Parallel() { + // No-op } func (t *ginkgoTestingTProxy) Skip(args ...interface{}) { - fmt.Println(args...) + t.skip(fmt.Sprintln(args...), t.offset) } -func (t *ginkgoTestingTProxy) Skipf(format string, args ...interface{}) { - t.Skip(fmt.Sprintf(format, args...)) +func (t *ginkgoTestingTProxy) SkipNow() { + t.skip("skip", t.offset) } -func (t *ginkgoTestingTProxy) SkipNow() { +func (t *ginkgoTestingTProxy) Skipf(format string, args ...interface{}) { + t.skip(fmt.Sprintf(format, args...), t.offset) } func (t *ginkgoTestingTProxy) Skipped() bool { return false } + +func (t *ginkgoTestingTProxy) TempDir() string { + // No-op + return "" +} diff -Nru golang-ginkgo-1.12.0/internal/testingtproxy/testingtproxy_suite_test.go golang-ginkgo-1.14.2/internal/testingtproxy/testingtproxy_suite_test.go --- golang-ginkgo-1.12.0/internal/testingtproxy/testingtproxy_suite_test.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/testingtproxy/testingtproxy_suite_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -0,0 +1,13 @@ +package testingtproxy_test + +import ( + "testing" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +func TestTestingtproxy(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Testingtproxy Suite") +} diff -Nru golang-ginkgo-1.12.0/internal/testingtproxy/testingtproxy_test.go golang-ginkgo-1.14.2/internal/testingtproxy/testingtproxy_test.go --- golang-ginkgo-1.12.0/internal/testingtproxy/testingtproxy_test.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-ginkgo-1.14.2/internal/testingtproxy/testingtproxy_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -0,0 +1,154 @@ +package testingtproxy_test + +import ( + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "github.com/onsi/gomega/gbytes" + + "github.com/onsi/ginkgo/internal/testingtproxy" +) + +type messagedCall struct { + message string + callerSkip []int +} + +var _ = Describe("Testingtproxy", func() { + var t GinkgoTInterface + + var failFunc func(message string, callerSkip ...int) + var skipFunc func(message string, callerSkip ...int) + var failedFunc func() bool + var nameFunc func() string + + var nameToReturn string + var failedToReturn bool + var failFuncCall messagedCall + var skipFuncCall messagedCall + var offset int + var buf *gbytes.Buffer + + BeforeEach(func() { + failFuncCall = messagedCall{} + skipFuncCall = messagedCall{} + nameToReturn = "" + failedToReturn = false + offset = 3 + + failFunc = func(message string, callerSkip ...int) { + failFuncCall.message = message + failFuncCall.callerSkip = callerSkip + } + + skipFunc = func(message string, callerSkip ...int) { + skipFuncCall.message = message + skipFuncCall.callerSkip = callerSkip + } + + failedFunc = func() bool { + return failedToReturn + } + + nameFunc = func() string { + return nameToReturn + } + + buf = gbytes.NewBuffer() + + t = testingtproxy.New(buf, failFunc, skipFunc, failedFunc, nameFunc, offset) + }) + + It("ignores Cleanup", func() { + GinkgoT().Cleanup(func() { + panic("bam!") + }) //is a no-op + }) + + It("supports Error", func() { + t.Error("a", 17) + Ω(failFuncCall.message).Should(Equal("a 17\n")) + Ω(failFuncCall.callerSkip).Should(Equal([]int{offset})) + }) + + It("supports Errorf", func() { + t.Errorf("%s %d!", "a", 17) + Ω(failFuncCall.message).Should(Equal("a 17!")) + Ω(failFuncCall.callerSkip).Should(Equal([]int{offset})) + }) + + It("supports Fail", func() { + t.Fail() + Ω(failFuncCall.message).Should(Equal("failed")) + Ω(failFuncCall.callerSkip).Should(Equal([]int{offset})) + }) + + It("supports FailNow", func() { + t.Fail() + Ω(failFuncCall.message).Should(Equal("failed")) + Ω(failFuncCall.callerSkip).Should(Equal([]int{offset})) + }) + + It("supports Fatal", func() { + t.Fatal("a", 17) + Ω(failFuncCall.message).Should(Equal("a 17\n")) + Ω(failFuncCall.callerSkip).Should(Equal([]int{offset})) + }) + + It("supports Fatalf", func() { + t.Fatalf("%s %d!", "a", 17) + Ω(failFuncCall.message).Should(Equal("a 17!")) + Ω(failFuncCall.callerSkip).Should(Equal([]int{offset})) + }) + + It("ignores Helper", func() { + GinkgoT().Helper() //is a no-op + }) + + It("supports Log", func() { + t.Log("a", 17) + Ω(string(buf.Contents())).Should(Equal("a 17\n")) + }) + + It("supports Logf", func() { + t.Logf("%s %d!", "a", 17) + Ω(string(buf.Contents())).Should(Equal("a 17!\n")) + }) + + It("supports Name", func() { + nameToReturn = "C.S. Lewis" + Ω(t.Name()).Should(Equal("C.S. Lewis")) + + Ω(GinkgoT().Name()).Should(ContainSubstring("supports Name")) + }) + + It("ignores Parallel", func() { + GinkgoT().Parallel() //is a no-op + }) + + It("supports Skip", func() { + t.Skip("a", 17) + Ω(skipFuncCall.message).Should(Equal("a 17\n")) + Ω(skipFuncCall.callerSkip).Should(Equal([]int{offset})) + }) + + It("supports SkipNow", func() { + t.SkipNow() + Ω(skipFuncCall.message).Should(Equal("skip")) + Ω(skipFuncCall.callerSkip).Should(Equal([]int{offset})) + }) + + It("supports Skipf", func() { + t.Skipf("%s %d!", "a", 17) + Ω(skipFuncCall.message).Should(Equal("a 17!")) + Ω(skipFuncCall.callerSkip).Should(Equal([]int{offset})) + }) + + It("always returns false for Skipped", func() { + Ω(GinkgoT().Skipped()).Should(BeFalse()) + }) + + It("returns empty string for TempDir", func() { + Ω(GinkgoT().TempDir()).Should(Equal("")) + }) +}) diff -Nru golang-ginkgo-1.12.0/README.md golang-ginkgo-1.14.2/README.md --- golang-ginkgo-1.12.0/README.md 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/README.md 2020-10-12 17:59:23.000000000 +0000 @@ -1,29 +1,45 @@ -![Ginkgo: A Go BDD Testing Framework](http://onsi.github.io/ginkgo/images/ginkgo.png) +![Ginkgo: A Go BDD Testing Framework](https://onsi.github.io/ginkgo/images/ginkgo.png) [![Build Status](https://travis-ci.org/onsi/ginkgo.svg?branch=master)](https://travis-ci.org/onsi/ginkgo) -Jump to the [docs](http://onsi.github.io/ginkgo/) to learn more. To start rolling your Ginkgo tests *now* [keep reading](#set-me-up)! +Jump to the [docs](https://onsi.github.io/ginkgo/) to learn more. To start rolling your Ginkgo tests *now* [keep reading](#set-me-up)! -If you have a question, comment, bug report, feature request, etc. please open a GitHub issue. +If you have a question, comment, bug report, feature request, etc. please open a GitHub issue, or visit the [Ginkgo Slack channel](https://app.slack.com/client/T029RQSE6/CQQ50BBNW). + +## TLDR +Ginkgo builds on Go's `testing` package, allowing expressive [Behavior-Driven Development](https://en.wikipedia.org/wiki/Behavior-driven_development) ("BDD") style tests. +It is typically (and optionally) paired with the [Gomega](https://github.com/onsi/gomega) matcher library. + +```go +Describe("the strings package", func() { + Context("strings.Contains()", func() { + When("the string contains the substring in the middle", func() { + It("returns `true`", func() { + Expect(strings.Contains("Ginkgo is awesome", "is")).To(BeTrue()) + }) + }) + }) +}) +``` ## Feature List -- Ginkgo uses Go's `testing` package and can live alongside your existing `testing` tests. It's easy to [bootstrap](http://onsi.github.io/ginkgo/#bootstrapping-a-suite) and start writing your [first tests](http://onsi.github.io/ginkgo/#adding-specs-to-a-suite) +- Ginkgo uses Go's `testing` package and can live alongside your existing `testing` tests. It's easy to [bootstrap](https://onsi.github.io/ginkgo/#bootstrapping-a-suite) and start writing your [first tests](https://onsi.github.io/ginkgo/#adding-specs-to-a-suite) -- Structure your BDD-style tests expressively: - - Nestable [`Describe`, `Context` and `When` container blocks](http://onsi.github.io/ginkgo/#organizing-specs-with-containers-describe-and-context) - - [`BeforeEach` and `AfterEach` blocks](http://onsi.github.io/ginkgo/#extracting-common-setup-beforeeach) for setup and teardown - - [`It` and `Specify` blocks](http://onsi.github.io/ginkgo/#individual-specs-) that hold your assertions - - [`JustBeforeEach` blocks](http://onsi.github.io/ginkgo/#separating-creation-and-configuration-justbeforeeach) that separate creation from configuration (also known as the subject action pattern). - - [`BeforeSuite` and `AfterSuite` blocks](http://onsi.github.io/ginkgo/#global-setup-and-teardown-beforesuite-and-aftersuite) to prep for and cleanup after a suite. +- Ginkgo allows you to write tests in Go using expressive [Behavior-Driven Development](https://en.wikipedia.org/wiki/Behavior-driven_development) ("BDD") style: + - Nestable [`Describe`, `Context` and `When` container blocks](https://onsi.github.io/ginkgo/#organizing-specs-with-containers-describe-and-context) + - [`BeforeEach` and `AfterEach` blocks](https://onsi.github.io/ginkgo/#extracting-common-setup-beforeeach) for setup and teardown + - [`It` and `Specify` blocks](https://onsi.github.io/ginkgo/#individual-specs-it) that hold your assertions + - [`JustBeforeEach` blocks](https://onsi.github.io/ginkgo/#separating-creation-and-configuration-justbeforeeach) that separate creation from configuration (also known as the subject action pattern). + - [`BeforeSuite` and `AfterSuite` blocks](https://onsi.github.io/ginkgo/#global-setup-and-teardown-beforesuite-and-aftersuite) to prep for and cleanup after a suite. - A comprehensive test runner that lets you: - - Mark specs as [pending](http://onsi.github.io/ginkgo/#pending-specs) - - [Focus](http://onsi.github.io/ginkgo/#focused-specs) individual specs, and groups of specs, either programmatically or on the command line - - Run your tests in [random order](http://onsi.github.io/ginkgo/#spec-permutation), and then reuse random seeds to replicate the same order. - - Break up your test suite into parallel processes for straightforward [test parallelization](http://onsi.github.io/ginkgo/#parallel-specs) + - Mark specs as [pending](https://onsi.github.io/ginkgo/#pending-specs) + - [Focus](https://onsi.github.io/ginkgo/#focused-specs) individual specs, and groups of specs, either programmatically or on the command line + - Run your tests in [random order](https://onsi.github.io/ginkgo/#spec-permutation), and then reuse random seeds to replicate the same order. + - Break up your test suite into parallel processes for straightforward [test parallelization](https://onsi.github.io/ginkgo/#parallel-specs) -- `ginkgo`: a command line interface with plenty of handy command line arguments for [running your tests](http://onsi.github.io/ginkgo/#running-tests) and [generating](http://onsi.github.io/ginkgo/#generators) test files. Here are a few choice examples: +- `ginkgo`: a command line interface with plenty of handy command line arguments for [running your tests](https://onsi.github.io/ginkgo/#running-tests) and [generating](https://onsi.github.io/ginkgo/#generators) test files. Here are a few choice examples: - `ginkgo -nodes=N` runs your tests in `N` parallel processes and print out coherent output in realtime - `ginkgo -cover` runs your tests using Go's code coverage tool - `ginkgo convert` converts an XUnit-style `testing` package to a Ginkgo-style package @@ -37,37 +53,59 @@ - `ginkgo watch` [watches](https://onsi.github.io/ginkgo/#watching-for-changes) packages *and their dependencies* for changes, then reruns tests. Run tests immediately as you develop! -- Built-in support for testing [asynchronicity](http://onsi.github.io/ginkgo/#asynchronous-tests) +- Built-in support for testing [asynchronicity](https://onsi.github.io/ginkgo/#asynchronous-tests) -- Built-in support for [benchmarking](http://onsi.github.io/ginkgo/#benchmark-tests) your code. Control the number of benchmark samples as you gather runtimes and other, arbitrary, bits of numerical information about your code. +- Built-in support for [benchmarking](https://onsi.github.io/ginkgo/#benchmark-tests) your code. Control the number of benchmark samples as you gather runtimes and other, arbitrary, bits of numerical information about your code. - [Completions for Sublime Text](https://github.com/onsi/ginkgo-sublime-completions): just use [Package Control](https://sublime.wbond.net/) to install `Ginkgo Completions`. - [Completions for VSCode](https://github.com/onsi/vscode-ginkgo): just use VSCode's extension installer to install `vscode-ginkgo`. -- Straightforward support for third-party testing libraries such as [Gomock](https://code.google.com/p/gomock/) and [Testify](https://github.com/stretchr/testify). Check out the [docs](http://onsi.github.io/ginkgo/#third-party-integrations) for details. +- Straightforward support for third-party testing libraries such as [Gomock](https://code.google.com/p/gomock/) and [Testify](https://github.com/stretchr/testify). Check out the [docs](https://onsi.github.io/ginkgo/#third-party-integrations) for details. - A modular architecture that lets you easily: - - Write [custom reporters](http://onsi.github.io/ginkgo/#writing-custom-reporters) (for example, Ginkgo comes with a [JUnit XML reporter](http://onsi.github.io/ginkgo/#generating-junit-xml-output) and a TeamCity reporter). - - [Adapt an existing matcher library (or write your own!)](http://onsi.github.io/ginkgo/#using-other-matcher-libraries) to work with Ginkgo + - Write [custom reporters](https://onsi.github.io/ginkgo/#writing-custom-reporters) (for example, Ginkgo comes with a [JUnit XML reporter](https://onsi.github.io/ginkgo/#generating-junit-xml-output) and a TeamCity reporter). + - [Adapt an existing matcher library (or write your own!)](https://onsi.github.io/ginkgo/#using-other-matcher-libraries) to work with Ginkgo -## [Gomega](http://github.com/onsi/gomega): Ginkgo's Preferred Matcher Library +## [Gomega](https://github.com/onsi/gomega): Ginkgo's Preferred Matcher Library -Ginkgo is best paired with Gomega. Learn more about Gomega [here](http://onsi.github.io/gomega/) +Ginkgo is best paired with Gomega. Learn more about Gomega [here](https://onsi.github.io/gomega/) -## [Agouti](http://github.com/sclevine/agouti): A Go Acceptance Testing Framework +## [Agouti](https://github.com/sclevine/agouti): A Go Acceptance Testing Framework -Agouti allows you run WebDriver integration tests. Learn more about Agouti [here](http://agouti.org) +Agouti allows you run WebDriver integration tests. Learn more about Agouti [here](https://agouti.org) -## Set Me Up! +## Getting Started -You'll need the Go command-line tools. Ginkgo is tested with Go 1.6+, but preferably you should get the latest. Follow the [installation instructions](https://golang.org/doc/install) if you don't have it installed. +You'll need the Go command-line tools. Follow the [installation instructions](https://golang.org/doc/install) if you don't have it installed. +### Global installation +To install the Ginkgo command line interface: ```bash +go get -u github.com/onsi/ginkgo/ginkgo +``` +Note that this will install it to `$GOBIN`, which will need to be in the `$PATH` (or equivalent). Run `go help install` for more information. + +### Go module ["tools package"](https://github.com/golang/go/issues/25922): +Create (or update) a file called `tools/tools.go` with the following contents: +```go +// +build tools -go get -u github.com/onsi/ginkgo/ginkgo # installs the ginkgo CLI -go get -u github.com/onsi/gomega/... # fetches the matcher library +package tools +import ( + _ "github.com/onsi/ginkgo/ginkgo" +) + +// This file imports packages that are used when running go generate, or used +// during the development process but not otherwise depended on by built code. +``` +The Ginkgo command can then be run via `go run github.com/onsi/ginkgo/ginkgo`. +This approach allows the version of Ginkgo to be maintained under source control for reproducible results, +and is well suited to automated test pipelines. + +### Bootstrapping +```bash cd path/to/package/you/want/to/test ginkgo bootstrap # set up a new ginkgo suite @@ -87,16 +125,16 @@ ### What Go gives you out of the box -Testing is a first class citizen in Go, however Go's built-in testing primitives are somewhat limited: The [testing](http://golang.org/pkg/testing) package provides basic XUnit style tests and no assertion library. +Testing is a first class citizen in Go, however Go's built-in testing primitives are somewhat limited: The [testing](https://golang.org/pkg/testing) package provides basic XUnit style tests and no assertion library. ### Matcher libraries for Go's XUnit style tests A number of matcher libraries have been written to augment Go's built-in XUnit style tests. Here are two that have gained traction: - [testify](https://github.com/stretchr/testify) -- [gocheck](http://labix.org/gocheck) +- [gocheck](https://labix.org/gocheck) -You can also use Ginkgo's matcher library [Gomega](https://github.com/onsi/gomega) in [XUnit style tests](http://onsi.github.io/gomega/#using-gomega-with-golangs-xunitstyle-tests) +You can also use Ginkgo's matcher library [Gomega](https://github.com/onsi/gomega) in [XUnit style tests](https://onsi.github.io/gomega/#using-gomega-with-golangs-xunitstyle-tests) ### BDD style testing frameworks diff -Nru golang-ginkgo-1.12.0/reporters/default_reporter.go golang-ginkgo-1.14.2/reporters/default_reporter.go --- golang-ginkgo-1.12.0/reporters/default_reporter.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/reporters/default_reporter.go 2020-10-12 17:59:23.000000000 +0000 @@ -57,11 +57,11 @@ switch specSummary.State { case types.SpecStatePassed: if specSummary.IsMeasurement { - reporter.stenographer.AnnounceSuccesfulMeasurement(specSummary, reporter.config.Succinct) + reporter.stenographer.AnnounceSuccessfulMeasurement(specSummary, reporter.config.Succinct) } else if specSummary.RunTime.Seconds() >= reporter.config.SlowSpecThreshold { - reporter.stenographer.AnnounceSuccesfulSlowSpec(specSummary, reporter.config.Succinct) + reporter.stenographer.AnnounceSuccessfulSlowSpec(specSummary, reporter.config.Succinct) } else { - reporter.stenographer.AnnounceSuccesfulSpec(specSummary) + reporter.stenographer.AnnounceSuccessfulSpec(specSummary) if reporter.config.ReportPassed { reporter.stenographer.AnnounceCapturedOutput(specSummary.CapturedOutput) } diff -Nru golang-ginkgo-1.12.0/reporters/default_reporter_test.go golang-ginkgo-1.14.2/reporters/default_reporter_test.go --- golang-ginkgo-1.12.0/reporters/default_reporter_test.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/reporters/default_reporter_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -221,7 +221,7 @@ }) It("should announce the measurement", func() { - Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulMeasurement", spec, false))) + Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccessfulMeasurement", spec, false))) }) }) @@ -231,13 +231,13 @@ }) It("should announce that it was slow", func() { - Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulSlowSpec", spec, false))) + Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccessfulSlowSpec", spec, false))) }) }) Context("When the spec is successful", func() { It("should announce the successful spec", func() { - Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulSpec", spec))) + Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccessfulSpec", spec))) }) Context("When ReportPassed flag is set", func() { @@ -357,7 +357,7 @@ }) It("should announce the measurement", func() { - Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulMeasurement", spec, true))) + Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccessfulMeasurement", spec, true))) }) }) @@ -367,13 +367,13 @@ }) It("should announce that it was slow", func() { - Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulSlowSpec", spec, true))) + Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccessfulSlowSpec", spec, true))) }) }) Context("When the spec is successful", func() { It("should announce the successful spec", func() { - Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulSpec", spec))) + Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccessfulSpec", spec))) }) Context("When ReportPassed flag is set", func() { diff -Nru golang-ginkgo-1.12.0/reporters/junit_reporter.go golang-ginkgo-1.14.2/reporters/junit_reporter.go --- golang-ginkgo-1.12.0/reporters/junit_reporter.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/reporters/junit_reporter.go 2020-10-12 17:59:23.000000000 +0000 @@ -50,7 +50,7 @@ } type JUnitSkipped struct { - XMLName xml.Name `xml:"skipped"` + Message string `xml:",chardata"` } type JUnitReporter struct { @@ -132,6 +132,9 @@ } if specSummary.State == types.SpecStateSkipped || specSummary.State == types.SpecStatePending { testCase.Skipped = &JUnitSkipped{} + if specSummary.Failure.Message != "" { + testCase.Skipped.Message = failureMessage(specSummary.Failure) + } } testCase.Time = specSummary.RunTime.Seconds() reporter.suite.TestCases = append(reporter.suite.TestCases, testCase) diff -Nru golang-ginkgo-1.12.0/reporters/junit_reporter_test.go golang-ginkgo-1.14.2/reporters/junit_reporter_test.go --- golang-ginkgo-1.12.0/reporters/junit_reporter_test.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/reporters/junit_reporter_test.go 2020-10-12 17:59:23.000000000 +0000 @@ -24,16 +24,16 @@ readOutputFile := func() reporters.JUnitTestSuite { bytes, err := ioutil.ReadFile(outputFile) - Ω(err).ShouldNot(HaveOccurred()) + Expect(err).ToNot(HaveOccurred()) var suite reporters.JUnitTestSuite err = xml.Unmarshal(bytes, &suite) - Ω(err).ShouldNot(HaveOccurred()) + Expect(err).ToNot(HaveOccurred()) return suite } BeforeEach(func() { f, err := ioutil.TempFile("", "output") - Ω(err).ShouldNot(HaveOccurred()) + Expect(err).ToNot(HaveOccurred()) f.Close() outputFile = f.Name() @@ -82,18 +82,18 @@ It("should record the test as passing, including detailed output", func() { output := readOutputFile() - Ω(output.Name).Should(Equal("My test suite")) - Ω(output.Tests).Should(Equal(1)) - Ω(output.Failures).Should(Equal(0)) - Ω(output.Time).Should(Equal(reportedSuiteTime)) - Ω(output.Errors).Should(Equal(0)) - Ω(output.TestCases).Should(HaveLen(1)) - Ω(output.TestCases[0].Name).Should(Equal("A B C")) - Ω(output.TestCases[0].ClassName).Should(Equal("My test suite")) - Ω(output.TestCases[0].FailureMessage).Should(BeNil()) - Ω(output.TestCases[0].Skipped).Should(BeNil()) - Ω(output.TestCases[0].Time).Should(Equal(5.0)) - Ω(output.TestCases[0].PassedMessage.Message).Should(ContainSubstring("Test scenario")) + Expect(output.Name).To(Equal("My test suite")) + Expect(output.Tests).To(Equal(1)) + Expect(output.Failures).To(Equal(0)) + Expect(output.Time).To(Equal(reportedSuiteTime)) + Expect(output.Errors).To(Equal(0)) + Expect(output.TestCases).To(HaveLen(1)) + Expect(output.TestCases[0].Name).To(Equal("A B C")) + Expect(output.TestCases[0].ClassName).To(Equal("My test suite")) + Expect(output.TestCases[0].FailureMessage).To(BeNil()) + Expect(output.TestCases[0].Skipped).To(BeNil()) + Expect(output.TestCases[0].Time).To(Equal(5.0)) + Expect(output.TestCases[0].PassedMessage.Message).To(ContainSubstring("Test scenario")) }) }) @@ -116,13 +116,13 @@ // Set the ReportFile config flag with a new directory and new file path to be created. d, err := ioutil.TempDir("", "new-junit-dir") - Ω(err).ShouldNot(HaveOccurred()) + Expect(err).ToNot(HaveOccurred()) f, err := ioutil.TempFile(d, "output") - Ω(err).ShouldNot(HaveOccurred()) + Expect(err).ToNot(HaveOccurred()) f.Close() outputFile = f.Name() err = os.RemoveAll(d) - Ω(err).ShouldNot(HaveOccurred()) + Expect(err).ToNot(HaveOccurred()) reporter.ReporterConfig.ReportFile = outputFile spec := &types.SpecSummary{ @@ -144,17 +144,17 @@ It("should create the report (and parent directories) as specified by ReportFile path", func() { output := readOutputFile() - Ω(output.Name).Should(Equal("My test suite")) - Ω(output.Tests).Should(Equal(1)) - Ω(output.Failures).Should(Equal(0)) - Ω(output.Time).Should(Equal(reportedSuiteTime)) - Ω(output.Errors).Should(Equal(0)) - Ω(output.TestCases).Should(HaveLen(1)) - Ω(output.TestCases[0].Name).Should(Equal("A B C")) - Ω(output.TestCases[0].ClassName).Should(Equal("My test suite")) - Ω(output.TestCases[0].FailureMessage).Should(BeNil()) - Ω(output.TestCases[0].Skipped).Should(BeNil()) - Ω(output.TestCases[0].Time).Should(Equal(5.0)) + Expect(output.Name).To(Equal("My test suite")) + Expect(output.Tests).To(Equal(1)) + Expect(output.Failures).To(Equal(0)) + Expect(output.Time).To(Equal(reportedSuiteTime)) + Expect(output.Errors).To(Equal(0)) + Expect(output.TestCases).To(HaveLen(1)) + Expect(output.TestCases[0].Name).To(Equal("A B C")) + Expect(output.TestCases[0].ClassName).To(Equal("My test suite")) + Expect(output.TestCases[0].FailureMessage).To(BeNil()) + Expect(output.TestCases[0].Skipped).To(BeNil()) + Expect(output.TestCases[0].Time).To(Equal(5.0)) }) }) @@ -182,19 +182,19 @@ It("should record the test as having failed", func() { output := readOutputFile() - Ω(output.Name).Should(Equal("My test suite")) - Ω(output.Tests).Should(Equal(1)) - Ω(output.Failures).Should(Equal(1)) - Ω(output.Time).Should(Equal(reportedSuiteTime)) - Ω(output.Errors).Should(Equal(0)) - Ω(output.TestCases[0].Name).Should(Equal("BeforeSuite")) - Ω(output.TestCases[0].Time).Should(Equal(3.0)) - Ω(output.TestCases[0].ClassName).Should(Equal("My test suite")) - Ω(output.TestCases[0].FailureMessage.Type).Should(Equal("Failure")) - Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring("failed to setup")) - Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring(beforeSuite.Failure.ComponentCodeLocation.String())) - Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring(beforeSuite.Failure.Location.String())) - Ω(output.TestCases[0].Skipped).Should(BeNil()) + Expect(output.Name).To(Equal("My test suite")) + Expect(output.Tests).To(Equal(1)) + Expect(output.Failures).To(Equal(1)) + Expect(output.Time).To(Equal(reportedSuiteTime)) + Expect(output.Errors).To(Equal(0)) + Expect(output.TestCases[0].Name).To(Equal("BeforeSuite")) + Expect(output.TestCases[0].Time).To(Equal(3.0)) + Expect(output.TestCases[0].ClassName).To(Equal("My test suite")) + Expect(output.TestCases[0].FailureMessage.Type).To(Equal("Failure")) + Expect(output.TestCases[0].FailureMessage.Message).To(ContainSubstring("failed to setup")) + Expect(output.TestCases[0].FailureMessage.Message).To(ContainSubstring(beforeSuite.Failure.ComponentCodeLocation.String())) + Expect(output.TestCases[0].FailureMessage.Message).To(ContainSubstring(beforeSuite.Failure.Location.String())) + Expect(output.TestCases[0].Skipped).To(BeNil()) }) }) @@ -222,19 +222,19 @@ It("should record the test as having failed", func() { output := readOutputFile() - Ω(output.Name).Should(Equal("My test suite")) - Ω(output.Tests).Should(Equal(1)) - Ω(output.Failures).Should(Equal(1)) - Ω(output.Time).Should(Equal(reportedSuiteTime)) - Ω(output.Errors).Should(Equal(0)) - Ω(output.TestCases[0].Name).Should(Equal("AfterSuite")) - Ω(output.TestCases[0].Time).Should(Equal(3.0)) - Ω(output.TestCases[0].ClassName).Should(Equal("My test suite")) - Ω(output.TestCases[0].FailureMessage.Type).Should(Equal("Failure")) - Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring("failed to setup")) - Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring(afterSuite.Failure.ComponentCodeLocation.String())) - Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring(afterSuite.Failure.Location.String())) - Ω(output.TestCases[0].Skipped).Should(BeNil()) + Expect(output.Name).To(Equal("My test suite")) + Expect(output.Tests).To(Equal(1)) + Expect(output.Failures).To(Equal(1)) + Expect(output.Time).To(Equal(reportedSuiteTime)) + Expect(output.Errors).To(Equal(0)) + Expect(output.TestCases[0].Name).To(Equal("AfterSuite")) + Expect(output.TestCases[0].Time).To(Equal(3.0)) + Expect(output.TestCases[0].ClassName).To(Equal("My test suite")) + Expect(output.TestCases[0].FailureMessage.Type).To(Equal("Failure")) + Expect(output.TestCases[0].FailureMessage.Message).To(ContainSubstring("failed to setup")) + Expect(output.TestCases[0].FailureMessage.Message).To(ContainSubstring(afterSuite.Failure.ComponentCodeLocation.String())) + Expect(output.TestCases[0].FailureMessage.Message).To(ContainSubstring(afterSuite.Failure.Location.String())) + Expect(output.TestCases[0].Skipped).To(BeNil()) }) }) @@ -278,21 +278,21 @@ It("should record test as failing", func() { output := readOutputFile() - Ω(output.Name).Should(Equal("My test suite")) - Ω(output.Tests).Should(Equal(1)) - Ω(output.Failures).Should(Equal(1)) - Ω(output.Time).Should(Equal(reportedSuiteTime)) - Ω(output.Errors).Should(Equal(0)) - Ω(output.TestCases[0].Name).Should(Equal("A B C")) - Ω(output.TestCases[0].ClassName).Should(Equal("My test suite")) - Ω(output.TestCases[0].FailureMessage.Type).Should(Equal(specStateCase.message)) - Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring("I failed")) - Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring(spec.Failure.ComponentCodeLocation.String())) - Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring(spec.Failure.Location.String())) - Ω(output.TestCases[0].Skipped).Should(BeNil()) + Expect(output.Name).To(Equal("My test suite")) + Expect(output.Tests).To(Equal(1)) + Expect(output.Failures).To(Equal(1)) + Expect(output.Time).To(Equal(reportedSuiteTime)) + Expect(output.Errors).To(Equal(0)) + Expect(output.TestCases[0].Name).To(Equal("A B C")) + Expect(output.TestCases[0].ClassName).To(Equal("My test suite")) + Expect(output.TestCases[0].FailureMessage.Type).To(Equal(specStateCase.message)) + Expect(output.TestCases[0].FailureMessage.Message).To(ContainSubstring("I failed")) + Expect(output.TestCases[0].FailureMessage.Message).To(ContainSubstring(spec.Failure.ComponentCodeLocation.String())) + Expect(output.TestCases[0].FailureMessage.Message).To(ContainSubstring(spec.Failure.Location.String())) + Expect(output.TestCases[0].Skipped).To(BeNil()) if specStateCase.state == types.SpecStatePanicked { - Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring("\nPanic: " + specStateCase.forwardedPanic + "\n")) - Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring("\nFull stack:\n" + spec.Failure.Location.FullStackTrace)) + Expect(output.TestCases[0].FailureMessage.Message).To(ContainSubstring("\nPanic: " + specStateCase.forwardedPanic + "\n")) + Expect(output.TestCases[0].FailureMessage.Message).To(ContainSubstring("\nFull stack:\n" + spec.Failure.Location.FullStackTrace)) } }) }) @@ -307,6 +307,9 @@ ComponentTexts: []string{"[Top Level]", "A", "B", "C"}, State: specStateCase, RunTime: 5 * time.Second, + Failure: types.SpecFailure{ + Message: "skipped reason", + }, } reporter.SpecWillRun(spec) reporter.SpecDidComplete(spec) @@ -320,12 +323,12 @@ It("should record test as failing", func() { output := readOutputFile() - Ω(output.Tests).Should(Equal(1)) - Ω(output.Failures).Should(Equal(0)) - Ω(output.Time).Should(Equal(reportedSuiteTime)) - Ω(output.Errors).Should(Equal(0)) - Ω(output.TestCases[0].Name).Should(Equal("A B C")) - Ω(output.TestCases[0].Skipped).ShouldNot(BeNil()) + Expect(output.Tests).To(Equal(1)) + Expect(output.Failures).To(Equal(0)) + Expect(output.Time).To(Equal(reportedSuiteTime)) + Expect(output.Errors).To(Equal(0)) + Expect(output.TestCases[0].Name).To(Equal("A B C")) + Expect(output.TestCases[0].Skipped.Message).To(ContainSubstring("skipped reason")) }) }) } diff -Nru golang-ginkgo-1.12.0/reporters/stenographer/fake_stenographer.go golang-ginkgo-1.14.2/reporters/stenographer/fake_stenographer.go --- golang-ginkgo-1.12.0/reporters/stenographer/fake_stenographer.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/reporters/stenographer/fake_stenographer.go 2020-10-12 17:59:23.000000000 +0000 @@ -105,16 +105,16 @@ stenographer.registerCall("AnnounceCapturedOutput", output) } -func (stenographer *FakeStenographer) AnnounceSuccesfulSpec(spec *types.SpecSummary) { - stenographer.registerCall("AnnounceSuccesfulSpec", spec) +func (stenographer *FakeStenographer) AnnounceSuccessfulSpec(spec *types.SpecSummary) { + stenographer.registerCall("AnnounceSuccessfulSpec", spec) } -func (stenographer *FakeStenographer) AnnounceSuccesfulSlowSpec(spec *types.SpecSummary, succinct bool) { - stenographer.registerCall("AnnounceSuccesfulSlowSpec", spec, succinct) +func (stenographer *FakeStenographer) AnnounceSuccessfulSlowSpec(spec *types.SpecSummary, succinct bool) { + stenographer.registerCall("AnnounceSuccessfulSlowSpec", spec, succinct) } -func (stenographer *FakeStenographer) AnnounceSuccesfulMeasurement(spec *types.SpecSummary, succinct bool) { - stenographer.registerCall("AnnounceSuccesfulMeasurement", spec, succinct) +func (stenographer *FakeStenographer) AnnounceSuccessfulMeasurement(spec *types.SpecSummary, succinct bool) { + stenographer.registerCall("AnnounceSuccessfulMeasurement", spec, succinct) } func (stenographer *FakeStenographer) AnnouncePendingSpec(spec *types.SpecSummary, noisy bool) { diff -Nru golang-ginkgo-1.12.0/reporters/stenographer/stenographer.go golang-ginkgo-1.14.2/reporters/stenographer/stenographer.go --- golang-ginkgo-1.12.0/reporters/stenographer/stenographer.go 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/reporters/stenographer/stenographer.go 2020-10-12 17:59:23.000000000 +0000 @@ -47,9 +47,9 @@ AnnounceCapturedOutput(output string) - AnnounceSuccesfulSpec(spec *types.SpecSummary) - AnnounceSuccesfulSlowSpec(spec *types.SpecSummary, succinct bool) - AnnounceSuccesfulMeasurement(spec *types.SpecSummary, succinct bool) + AnnounceSuccessfulSpec(spec *types.SpecSummary) + AnnounceSuccessfulSlowSpec(spec *types.SpecSummary, succinct bool) + AnnounceSuccessfulMeasurement(spec *types.SpecSummary, succinct bool) AnnouncePendingSpec(spec *types.SpecSummary, noisy bool) AnnounceSkippedSpec(spec *types.SpecSummary, succinct bool, fullTrace bool) @@ -245,12 +245,12 @@ s.midBlock() } -func (s *consoleStenographer) AnnounceSuccesfulSpec(spec *types.SpecSummary) { +func (s *consoleStenographer) AnnounceSuccessfulSpec(spec *types.SpecSummary) { s.print(0, s.colorize(greenColor, s.denoter)) s.stream() } -func (s *consoleStenographer) AnnounceSuccesfulSlowSpec(spec *types.SpecSummary, succinct bool) { +func (s *consoleStenographer) AnnounceSuccessfulSlowSpec(spec *types.SpecSummary, succinct bool) { s.printBlockWithMessage( s.colorize(greenColor, "%s [SLOW TEST:%.3f seconds]", s.denoter, spec.RunTime.Seconds()), "", @@ -259,7 +259,7 @@ ) } -func (s *consoleStenographer) AnnounceSuccesfulMeasurement(spec *types.SpecSummary, succinct bool) { +func (s *consoleStenographer) AnnounceSuccessfulMeasurement(spec *types.SpecSummary, succinct bool) { s.printBlockWithMessage( s.colorize(greenColor, "%s [MEASUREMENT]", s.denoter), s.measurementReport(spec, succinct), diff -Nru golang-ginkgo-1.12.0/.travis.yml golang-ginkgo-1.14.2/.travis.yml --- golang-ginkgo-1.12.0/.travis.yml 2020-02-01 10:35:24.000000000 +0000 +++ golang-ginkgo-1.14.2/.travis.yml 2020-10-12 17:59:23.000000000 +0000 @@ -1,7 +1,7 @@ language: go go: - - 1.12.x - 1.13.x + - 1.14.x - tip cache: