Update go dependencies
This commit is contained in:
parent
15ffb51394
commit
bb4d483837
1621 changed files with 86368 additions and 284392 deletions
3
vendor/github.com/onsi/ginkgo/.gitignore
generated
vendored
3
vendor/github.com/onsi/ginkgo/.gitignore
generated
vendored
|
|
@ -2,4 +2,5 @@
|
|||
TODO
|
||||
tmp/**/*
|
||||
*.coverprofile
|
||||
.vscode
|
||||
.vscode
|
||||
.idea/
|
||||
5
vendor/github.com/onsi/ginkgo/.travis.yml
generated
vendored
5
vendor/github.com/onsi/ginkgo/.travis.yml
generated
vendored
|
|
@ -1,9 +1,10 @@
|
|||
language: go
|
||||
go:
|
||||
- 1.5.x
|
||||
- 1.6.x
|
||||
- 1.7.x
|
||||
- 1.8.x
|
||||
- 1.9.x
|
||||
- 1.10.x
|
||||
|
||||
install:
|
||||
- go get -v -t ./...
|
||||
|
|
@ -12,4 +13,4 @@ install:
|
|||
- go install github.com/onsi/ginkgo/ginkgo
|
||||
- export PATH=$PATH:$HOME/gopath/bin
|
||||
|
||||
script: $HOME/gopath/bin/ginkgo -r --randomizeAllSpecs --randomizeSuites --race --trace
|
||||
script: $HOME/gopath/bin/ginkgo -r --randomizeAllSpecs --randomizeSuites --race --trace && go vet
|
||||
|
|
|
|||
31
vendor/github.com/onsi/ginkgo/CHANGELOG.md
generated
vendored
31
vendor/github.com/onsi/ginkgo/CHANGELOG.md
generated
vendored
|
|
@ -1,3 +1,34 @@
|
|||
## 1.5.0 5/10/2018
|
||||
|
||||
### New Features
|
||||
- Supports go v1.10 (#443, #446, #451) [e873237, 468e89e, e37dbfe, a37f4c0, c0b857d, bca5260, 4177ca8]
|
||||
- Add a When() synonym for Context() (#386) [747514b, 7484dad, 7354a07, dd826c8]
|
||||
- Re-add noisySkippings flag [652e15c]
|
||||
- Allow coverage to be displayed for focused specs (#367) [11459a8]
|
||||
- Handle -outputdir flag (#364) [228e3a8]
|
||||
- Handle -coverprofile flag (#355) [43392d5]
|
||||
|
||||
### Fixes
|
||||
- When using custom reporters register the custom reporters *before* the default reporter. This allows users to see the output of any print statements in their customer reporters. (#365) [8382b23]
|
||||
- When running a test and calculating the coverage using the `-coverprofile` and `-outputdir` flags, Ginkgo fails with an error if the directory does not exist. This is due to an [issue in go 1.10](https://github.com/golang/go/issues/24588) (#446) [b36a6e0]
|
||||
- `unfocus` command ignores vendor folder (#459) [e5e551c, c556e43, a3b6351, 9a820dd]
|
||||
- Ignore packages whose tests are all ignored by go (#456) [7430ca7, 6d8be98]
|
||||
- Increase the threshold when checking time measuments (#455) [2f714bf, 68f622c]
|
||||
- Fix race condition in coverage tests (#423) [a5a8ff7, ab9c08b]
|
||||
- Add an extra new line after reporting spec run completion for test2json [874520d]
|
||||
- added name name field to junit reported testsuite [ae61c63]
|
||||
- Do not set the run time of a spec when the dryRun flag is used (#438) [457e2d9, ba8e856]
|
||||
- Process FWhen and FSpecify when unfocusing (#434) [9008c7b, ee65bd, df87dfe]
|
||||
- Synchronise the access to the state of specs to avoid race conditions (#430) [7d481bc, ae6829d]
|
||||
- Added Duration on GinkgoTestDescription (#383) [5f49dad, 528417e, 0747408, 329d7ed]
|
||||
- Fix Ginkgo stack trace on failure for Specify (#415) [b977ede, 65ca40e, 6c46eb8]
|
||||
- Update README with Go 1.6+, Golang -> Go (#409) [17f6b97, bc14b66, 20d1598]
|
||||
- Use fmt.Errorf instead of errors.New(fmt.Sprintf (#401) [a299f56, 44e2eaa]
|
||||
- Imports in generated code should follow conventions (#398) [0bec0b0, e8536d8]
|
||||
- Prevent data race error when Recording a benchmark value from multiple go routines (#390) [c0c4881, 7a241e9]
|
||||
- Replace GOPATH in Environment [4b883f0]
|
||||
|
||||
|
||||
## 1.4.0 7/16/2017
|
||||
|
||||
- `ginkgo` now provides a hint if you accidentally forget to run `ginkgo bootstrap` to generate a `*_suite_test.go` file that actually invokes the Ginkgo test runner. [#345](https://github.com/onsi/ginkgo/pull/345)
|
||||
|
|
|
|||
3
vendor/github.com/onsi/ginkgo/CONTRIBUTING.md
generated
vendored
3
vendor/github.com/onsi/ginkgo/CONTRIBUTING.md
generated
vendored
|
|
@ -7,6 +7,7 @@ Your contributions to Ginkgo are essential for its long-term maintenance and imp
|
|||
- If you're adding functionality to the Ginkgo library, make sure to add appropriate unit and/or integration tests (under the `integration` folder).
|
||||
- If you're adding functionality to the Ginkgo CLI note that there are very few unit tests. Please add an integration test.
|
||||
- Please run all tests locally (`ginkgo -r -p`) and make sure they go green before submitting the PR
|
||||
- Please run following linter locally `go vet ./...` and make sure output does not contain any warnings
|
||||
- Update the documentation. In addition to standard `godoc` comments Ginkgo has extensive documentation on the `gh-pages` branch. If relevant, please submit a docs PR to that branch alongside your code PR.
|
||||
|
||||
Thanks for supporting Ginkgo!
|
||||
Thanks for supporting Ginkgo!
|
||||
|
|
|
|||
32
vendor/github.com/onsi/ginkgo/README.md
generated
vendored
32
vendor/github.com/onsi/ginkgo/README.md
generated
vendored
|
|
@ -1,4 +1,4 @@
|
|||

|
||||

|
||||
|
||||
[](https://travis-ci.org/onsi/ginkgo)
|
||||
|
||||
|
|
@ -11,9 +11,9 @@ If you have a question, comment, bug report, feature request, etc. please open a
|
|||
- 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)
|
||||
|
||||
- Structure your BDD-style tests expressively:
|
||||
- Nestable [`Describe` and `Context` container blocks](http://onsi.github.io/ginkgo/#organizing-specs-with-containers-describe-and-context)
|
||||
- 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` blocks](http://onsi.github.io/ginkgo/#individual-specs-) that hold your assertions
|
||||
- [`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.
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ If you have a question, comment, bug report, feature request, etc. please open a
|
|||
|
||||
- `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 -nodes=N` runs your tests in `N` parallel processes and print out coherent output in realtime
|
||||
- `ginkgo -cover` runs your tests using Golang's code coverage tool
|
||||
- `ginkgo -cover` runs your tests using Go's code coverage tool
|
||||
- `ginkgo convert` converts an XUnit-style `testing` package to a Ginkgo-style package
|
||||
- `ginkgo -focus="REGEXP"` and `ginkgo -skip="REGEXP"` allow you to specify a subset of tests to run via regular expression
|
||||
- `ginkgo -r` runs all tests suites under the current directory
|
||||
|
|
@ -55,18 +55,18 @@ If you have a question, comment, bug report, feature request, etc. please open a
|
|||
|
||||
Ginkgo is best paired with Gomega. Learn more about Gomega [here](http://onsi.github.io/gomega/)
|
||||
|
||||
## [Agouti](http://github.com/sclevine/agouti): A Golang Acceptance Testing Framework
|
||||
## [Agouti](http://github.com/sclevine/agouti): A Go Acceptance Testing Framework
|
||||
|
||||
Agouti allows you run WebDriver integration tests. Learn more about Agouti [here](http://agouti.org)
|
||||
|
||||
## Set Me Up!
|
||||
|
||||
You'll need Golang v1.3+ (Ubuntu users: you probably have Golang v1.0 -- you'll need to upgrade!)
|
||||
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.
|
||||
|
||||
```bash
|
||||
|
||||
go get github.com/onsi/ginkgo/ginkgo # installs the ginkgo CLI
|
||||
go get github.com/onsi/gomega # fetches the matcher library
|
||||
go get -u github.com/onsi/ginkgo/ginkgo # installs the ginkgo CLI
|
||||
go get -u github.com/onsi/gomega/... # fetches the matcher library
|
||||
|
||||
cd path/to/package/you/want/to/test
|
||||
|
||||
|
|
@ -85,11 +85,11 @@ Of course, I heartily recommend [Ginkgo](https://github.com/onsi/ginkgo) and [Go
|
|||
|
||||
With that said, it's great to know what your options are :)
|
||||
|
||||
### What Golang gives you out of the box
|
||||
### What Go gives you out of the box
|
||||
|
||||
Testing is a first class citizen in Golang, 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](http://golang.org/pkg/testing) package provides basic XUnit style tests and no assertion library.
|
||||
|
||||
### Matcher libraries for Golang's XUnit style tests
|
||||
### 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:
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ You can also use Ginkgo's matcher library [Gomega](https://github.com/onsi/gomeg
|
|||
|
||||
### BDD style testing frameworks
|
||||
|
||||
There are a handful of BDD-style testing frameworks written for Golang. Here are a few:
|
||||
There are a handful of BDD-style testing frameworks written for Go. Here are a few:
|
||||
|
||||
- [Ginkgo](https://github.com/onsi/ginkgo) ;)
|
||||
- [GoConvey](https://github.com/smartystreets/goconvey)
|
||||
|
|
@ -108,10 +108,16 @@ There are a handful of BDD-style testing frameworks written for Golang. Here ar
|
|||
- [Mao](https://github.com/azer/mao)
|
||||
- [Zen](https://github.com/pranavraja/zen)
|
||||
|
||||
Finally, @shageman has [put together](https://github.com/shageman/gotestit) a comprehensive comparison of golang testing libraries.
|
||||
Finally, @shageman has [put together](https://github.com/shageman/gotestit) a comprehensive comparison of Go testing libraries.
|
||||
|
||||
Go explore!
|
||||
|
||||
## License
|
||||
|
||||
Ginkgo is MIT-Licensed
|
||||
|
||||
## Contributing
|
||||
|
||||
Since Ginkgo tests also internal packages, when you fork, you'll have to replace imports with your repository.<br />
|
||||
Use `before_pr.sh` for that<br />
|
||||
After you finished your changes and before you push your pull request, use `after_pr.sh` to revert those changes
|
||||
|
|
|
|||
14
vendor/github.com/onsi/ginkgo/RELEASING.md
generated
vendored
Normal file
14
vendor/github.com/onsi/ginkgo/RELEASING.md
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
A Ginkgo release is a tagged git sha and a GitHub release. To cut a release:
|
||||
|
||||
1. Ensure CHANGELOG.md is up to date.
|
||||
- Use `git log --pretty=format:'- %s [%h]' HEAD...vX.X.X` to list all the commits since the last release
|
||||
- Categorize the changes into
|
||||
- Breaking Changes (requires a major version)
|
||||
- New Features (minor version)
|
||||
- Fixes (fix version)
|
||||
- Maintenance (which in general should not be mentioned in `CHANGELOG.md` as they have no user impact)
|
||||
1. Update `VERSION` in `config/config.go`
|
||||
1. Create a commit with the version number as the commit message (e.g. `v1.3.0`)
|
||||
1. Tag the commit with the version number as the tag name (e.g. `v1.3.0`)
|
||||
1. Push the commit and tag to GitHub
|
||||
1. Create a new [GitHub release](https://help.github.com/articles/creating-releases/) with the version number as the tag (e.g. `v1.3.0`). List the key changes in the release notes.
|
||||
13
vendor/github.com/onsi/ginkgo/before_pr.sh
generated
vendored
Executable file
13
vendor/github.com/onsi/ginkgo/before_pr.sh
generated
vendored
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
# Take current path
|
||||
path=$(pwd)
|
||||
|
||||
# Split it
|
||||
IFS='\/'; arrIN=($path); unset IFS;
|
||||
|
||||
# Find directory before ginkgo
|
||||
len=${#arrIN[@]}
|
||||
|
||||
userDir=${arrIN[$len-2]}
|
||||
|
||||
# Replace onsi with userdir
|
||||
find . -type f -name '*.go' -exec sed -i '' s/github.com\\/onsi\\/ginkgo\\/internal/github.com\\/$userDir\\/ginkgo\\/internal/ {} +
|
||||
10
vendor/github.com/onsi/ginkgo/config/config.go
generated
vendored
10
vendor/github.com/onsi/ginkgo/config/config.go
generated
vendored
|
|
@ -20,7 +20,7 @@ import (
|
|||
"fmt"
|
||||
)
|
||||
|
||||
const VERSION = "1.4.0"
|
||||
const VERSION = "1.5.0"
|
||||
|
||||
type GinkgoConfigType struct {
|
||||
RandomSeed int64
|
||||
|
|
@ -47,6 +47,7 @@ type DefaultReporterConfigType struct {
|
|||
NoColor bool
|
||||
SlowSpecThreshold float64
|
||||
NoisyPendings bool
|
||||
NoisySkippings bool
|
||||
Succinct bool
|
||||
Verbose bool
|
||||
FullTrace bool
|
||||
|
|
@ -64,7 +65,7 @@ func processPrefix(prefix string) string {
|
|||
func Flags(flagSet *flag.FlagSet, prefix string, includeParallelFlags bool) {
|
||||
prefix = processPrefix(prefix)
|
||||
flagSet.Int64Var(&(GinkgoConfig.RandomSeed), prefix+"seed", time.Now().Unix(), "The seed used to randomize the spec suite.")
|
||||
flagSet.BoolVar(&(GinkgoConfig.RandomizeAllSpecs), prefix+"randomizeAllSpecs", false, "If set, ginkgo will randomize all specs together. By default, ginkgo only randomizes the top level Describe/Context groups.")
|
||||
flagSet.BoolVar(&(GinkgoConfig.RandomizeAllSpecs), prefix+"randomizeAllSpecs", false, "If set, ginkgo will randomize all specs together. By default, ginkgo only randomizes the top level Describe, Context and When groups.")
|
||||
flagSet.BoolVar(&(GinkgoConfig.SkipMeasurements), prefix+"skipMeasurements", false, "If set, ginkgo will skip any measurement specs.")
|
||||
flagSet.BoolVar(&(GinkgoConfig.FailOnPending), prefix+"failOnPending", false, "If set, ginkgo will mark the test suite as failed if any specs are pending.")
|
||||
flagSet.BoolVar(&(GinkgoConfig.FailFast), prefix+"failFast", false, "If set, ginkgo will stop running a test suite after a failure occurs.")
|
||||
|
|
@ -90,6 +91,7 @@ func Flags(flagSet *flag.FlagSet, prefix string, includeParallelFlags bool) {
|
|||
flagSet.BoolVar(&(DefaultReporterConfig.NoColor), prefix+"noColor", false, "If set, suppress color output in default reporter.")
|
||||
flagSet.Float64Var(&(DefaultReporterConfig.SlowSpecThreshold), prefix+"slowSpecThreshold", 5.0, "(in seconds) Specs that take longer to run than this threshold are flagged as slow by the default reporter.")
|
||||
flagSet.BoolVar(&(DefaultReporterConfig.NoisyPendings), prefix+"noisyPendings", true, "If set, default reporter will shout about pending tests.")
|
||||
flagSet.BoolVar(&(DefaultReporterConfig.NoisySkippings), prefix+"noisySkippings", true, "If set, default reporter will shout about skipping tests.")
|
||||
flagSet.BoolVar(&(DefaultReporterConfig.Verbose), prefix+"v", false, "If set, default reporter print out all specs as they begin.")
|
||||
flagSet.BoolVar(&(DefaultReporterConfig.Succinct), prefix+"succinct", false, "If set, default reporter prints out a very succinct report")
|
||||
flagSet.BoolVar(&(DefaultReporterConfig.FullTrace), prefix+"trace", false, "If set, default reporter prints out the full stack trace when a failure occurs")
|
||||
|
|
@ -171,6 +173,10 @@ func BuildFlagArgs(prefix string, ginkgo GinkgoConfigType, reporter DefaultRepor
|
|||
result = append(result, fmt.Sprintf("--%snoisyPendings=false", prefix))
|
||||
}
|
||||
|
||||
if !reporter.NoisySkippings {
|
||||
result = append(result, fmt.Sprintf("--%snoisySkippings=false", prefix))
|
||||
}
|
||||
|
||||
if reporter.Verbose {
|
||||
result = append(result, fmt.Sprintf("--%sv", prefix))
|
||||
}
|
||||
|
|
|
|||
59
vendor/github.com/onsi/ginkgo/ginkgo_dsl.go
generated
vendored
59
vendor/github.com/onsi/ginkgo/ginkgo_dsl.go
generated
vendored
|
|
@ -149,7 +149,8 @@ type GinkgoTestDescription struct {
|
|||
FileName string
|
||||
LineNumber int
|
||||
|
||||
Failed bool
|
||||
Failed bool
|
||||
Duration time.Duration
|
||||
}
|
||||
|
||||
//CurrentGinkgoTestDescripton returns information about the current running test.
|
||||
|
|
@ -169,6 +170,7 @@ func CurrentGinkgoTestDescription() GinkgoTestDescription {
|
|||
FileName: subjectCodeLocation.FileName,
|
||||
LineNumber: subjectCodeLocation.LineNumber,
|
||||
Failed: summary.HasFailureState(),
|
||||
Duration: summary.RunTime,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -202,7 +204,7 @@ func RunSpecs(t GinkgoTestingT, description string) bool {
|
|||
//To run your tests with Ginkgo's default reporter and your custom reporter(s), replace
|
||||
//RunSpecs() with this method.
|
||||
func RunSpecsWithDefaultAndCustomReporters(t GinkgoTestingT, description string, specReporters []Reporter) bool {
|
||||
specReporters = append([]Reporter{buildDefaultReporter()}, specReporters...)
|
||||
specReporters = append(specReporters, buildDefaultReporter())
|
||||
return RunSpecsWithCustomReporters(t, description, specReporters)
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +218,7 @@ func RunSpecsWithCustomReporters(t GinkgoTestingT, description string, specRepor
|
|||
reporters[i] = reporter
|
||||
}
|
||||
passed, hasFocusedTests := globalSuite.Run(t, description, reporters, writer, config.GinkgoConfig)
|
||||
if passed && hasFocusedTests {
|
||||
if passed && hasFocusedTests && strings.TrimSpace(os.Getenv("GINKGO_EDITOR_INTEGRATION")) == "" {
|
||||
fmt.Println("PASS | FOCUSED")
|
||||
os.Exit(types.GINKGO_FOCUS_EXIT_CODE)
|
||||
}
|
||||
|
|
@ -233,7 +235,7 @@ func buildDefaultReporter() Reporter {
|
|||
}
|
||||
}
|
||||
|
||||
//Skip notifies Ginkgo that the current spec should be skipped.
|
||||
//Skip notifies Ginkgo that the current spec was skipped.
|
||||
func Skip(message string, callerSkip ...int) {
|
||||
skip := 0
|
||||
if len(callerSkip) > 0 {
|
||||
|
|
@ -275,9 +277,9 @@ func GinkgoRecover() {
|
|||
//Describe blocks allow you to organize your specs. A Describe block can contain any number of
|
||||
//BeforeEach, AfterEach, JustBeforeEach, It, and Measurement blocks.
|
||||
//
|
||||
//In addition you can nest Describe and Context blocks. Describe and Context blocks are functionally
|
||||
//In addition you can nest Describe, Context and When blocks. Describe, Context and When blocks are functionally
|
||||
//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.
|
||||
//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))
|
||||
return true
|
||||
|
|
@ -304,9 +306,9 @@ func XDescribe(text string, body func()) bool {
|
|||
//Context blocks allow you to organize your specs. A Context block can contain any number of
|
||||
//BeforeEach, AfterEach, JustBeforeEach, It, and Measurement blocks.
|
||||
//
|
||||
//In addition you can nest Describe and Context blocks. Describe and Context blocks are functionally
|
||||
//In addition you can nest Describe, Context and When blocks. Describe, Context and When blocks are functionally
|
||||
//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.
|
||||
//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))
|
||||
return true
|
||||
|
|
@ -330,6 +332,35 @@ func XContext(text string, body func()) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
//When blocks allow you to organize your specs. A When block can contain any number of
|
||||
//BeforeEach, AfterEach, JustBeforeEach, It, and Measurement blocks.
|
||||
//
|
||||
//In addition you can nest Describe, Context and When blocks. Describe, Context and When blocks are functionally
|
||||
//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))
|
||||
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))
|
||||
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))
|
||||
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))
|
||||
return true
|
||||
}
|
||||
|
||||
//It blocks contain your test code and assertions. You cannot nest any other Ginkgo blocks
|
||||
//within an It block.
|
||||
//
|
||||
|
|
@ -362,22 +393,26 @@ func XIt(text string, _ ...interface{}) bool {
|
|||
//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 {
|
||||
return It(text, body, timeout...)
|
||||
globalSuite.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 {
|
||||
return FIt(text, body, timeout...)
|
||||
globalSuite.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 {
|
||||
return PIt(text, is...)
|
||||
globalSuite.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 {
|
||||
return XIt(text, is...)
|
||||
globalSuite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0)
|
||||
return true
|
||||
}
|
||||
|
||||
//By allows you to better document large Its.
|
||||
|
|
|
|||
13
vendor/github.com/onsi/ginkgo/internal/codelocation/code_location_suite_test.go
generated
vendored
13
vendor/github.com/onsi/ginkgo/internal/codelocation/code_location_suite_test.go
generated
vendored
|
|
@ -1,13 +0,0 @@
|
|||
package codelocation_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCodelocation(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "CodeLocation Suite")
|
||||
}
|
||||
79
vendor/github.com/onsi/ginkgo/internal/codelocation/code_location_test.go
generated
vendored
79
vendor/github.com/onsi/ginkgo/internal/codelocation/code_location_test.go
generated
vendored
|
|
@ -1,79 +0,0 @@
|
|||
package codelocation_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
. "github.com/onsi/gomega"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
var _ = Describe("CodeLocation", func() {
|
||||
var (
|
||||
codeLocation types.CodeLocation
|
||||
expectedFileName string
|
||||
expectedLineNumber int
|
||||
)
|
||||
|
||||
caller0 := func() {
|
||||
codeLocation = codelocation.New(1)
|
||||
}
|
||||
|
||||
caller1 := func() {
|
||||
_, expectedFileName, expectedLineNumber, _ = runtime.Caller(0)
|
||||
expectedLineNumber += 2
|
||||
caller0()
|
||||
}
|
||||
|
||||
BeforeEach(func() {
|
||||
caller1()
|
||||
})
|
||||
|
||||
It("should use the passed in skip parameter to pick out the correct file & line number", func() {
|
||||
Ω(codeLocation.FileName).Should(Equal(expectedFileName))
|
||||
Ω(codeLocation.LineNumber).Should(Equal(expectedLineNumber))
|
||||
})
|
||||
|
||||
Describe("stringer behavior", func() {
|
||||
It("should stringify nicely", func() {
|
||||
Ω(codeLocation.String()).Should(ContainSubstring("code_location_test.go:%d", expectedLineNumber))
|
||||
})
|
||||
})
|
||||
|
||||
//There's no better way than to test this private method as it
|
||||
//goes out of its way to prune out ginkgo related code in the stack trace
|
||||
Describe("PruneStack", func() {
|
||||
It("should remove any references to ginkgo and pkg/testing and pkg/runtime", func() {
|
||||
input := `/Skip/me
|
||||
Skip: skip()
|
||||
/Skip/me
|
||||
Skip: skip()
|
||||
/Users/whoever/gospace/src/github.com/onsi/ginkgo/whatever.go:10 (0x12314)
|
||||
Something: Func()
|
||||
/Users/whoever/gospace/src/github.com/onsi/ginkgo/whatever_else.go:10 (0x12314)
|
||||
SomethingInternalToGinkgo: Func()
|
||||
/usr/goroot/pkg/strings/oops.go:10 (0x12341)
|
||||
Oops: BlowUp()
|
||||
/Users/whoever/gospace/src/mycode/code.go:10 (0x12341)
|
||||
MyCode: Func()
|
||||
/Users/whoever/gospace/src/mycode/code_test.go:10 (0x12341)
|
||||
MyCodeTest: Func()
|
||||
/Users/whoever/gospace/src/mycode/code_suite_test.go:12 (0x37f08)
|
||||
TestFoo: RunSpecs(t, "Foo Suite")
|
||||
/usr/goroot/pkg/testing/testing.go:12 (0x37f08)
|
||||
TestingT: Blah()
|
||||
/usr/goroot/pkg/runtime/runtime.go:12 (0x37f08)
|
||||
Something: Func()
|
||||
`
|
||||
prunedStack := codelocation.PruneStack(input, 1)
|
||||
Ω(prunedStack).Should(Equal(`/usr/goroot/pkg/strings/oops.go:10 (0x12341)
|
||||
Oops: BlowUp()
|
||||
/Users/whoever/gospace/src/mycode/code.go:10 (0x12341)
|
||||
MyCode: Func()
|
||||
/Users/whoever/gospace/src/mycode/code_test.go:10 (0x12341)
|
||||
MyCodeTest: Func()
|
||||
/Users/whoever/gospace/src/mycode/code_suite_test.go:12 (0x37f08)
|
||||
TestFoo: RunSpecs(t, "Foo Suite")`))
|
||||
})
|
||||
})
|
||||
})
|
||||
13
vendor/github.com/onsi/ginkgo/internal/containernode/container_node_suite_test.go
generated
vendored
13
vendor/github.com/onsi/ginkgo/internal/containernode/container_node_suite_test.go
generated
vendored
|
|
@ -1,13 +0,0 @@
|
|||
package containernode_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestContainernode(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Containernode Suite")
|
||||
}
|
||||
212
vendor/github.com/onsi/ginkgo/internal/containernode/container_node_test.go
generated
vendored
212
vendor/github.com/onsi/ginkgo/internal/containernode/container_node_test.go
generated
vendored
|
|
@ -1,212 +0,0 @@
|
|||
package containernode_test
|
||||
|
||||
import (
|
||||
"github.com/onsi/ginkgo/internal/leafnodes"
|
||||
"math/rand"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
. "github.com/onsi/ginkgo/internal/containernode"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
)
|
||||
|
||||
var _ = Describe("Container Node", func() {
|
||||
var (
|
||||
codeLocation types.CodeLocation
|
||||
container *ContainerNode
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
codeLocation = codelocation.New(0)
|
||||
container = New("description text", types.FlagTypeFocused, codeLocation)
|
||||
})
|
||||
|
||||
Describe("creating a container node", func() {
|
||||
It("can answer questions about itself", func() {
|
||||
Ω(container.Text()).Should(Equal("description text"))
|
||||
Ω(container.Flag()).Should(Equal(types.FlagTypeFocused))
|
||||
Ω(container.CodeLocation()).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("pushing setup nodes", func() {
|
||||
It("can append setup nodes of various types and fetch them by type", func() {
|
||||
befA := leafnodes.NewBeforeEachNode(func() {}, codelocation.New(0), 0, nil, 0)
|
||||
befB := leafnodes.NewBeforeEachNode(func() {}, codelocation.New(0), 0, nil, 0)
|
||||
aftA := leafnodes.NewAfterEachNode(func() {}, codelocation.New(0), 0, nil, 0)
|
||||
aftB := leafnodes.NewAfterEachNode(func() {}, codelocation.New(0), 0, nil, 0)
|
||||
jusBefA := leafnodes.NewJustBeforeEachNode(func() {}, codelocation.New(0), 0, nil, 0)
|
||||
jusBefB := leafnodes.NewJustBeforeEachNode(func() {}, codelocation.New(0), 0, nil, 0)
|
||||
|
||||
container.PushSetupNode(befA)
|
||||
container.PushSetupNode(befB)
|
||||
container.PushSetupNode(aftA)
|
||||
container.PushSetupNode(aftB)
|
||||
container.PushSetupNode(jusBefA)
|
||||
container.PushSetupNode(jusBefB)
|
||||
|
||||
subject := leafnodes.NewItNode("subject", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
|
||||
container.PushSubjectNode(subject)
|
||||
|
||||
Ω(container.SetupNodesOfType(types.SpecComponentTypeBeforeEach)).Should(Equal([]leafnodes.BasicNode{befA, befB}))
|
||||
Ω(container.SetupNodesOfType(types.SpecComponentTypeAfterEach)).Should(Equal([]leafnodes.BasicNode{aftA, aftB}))
|
||||
Ω(container.SetupNodesOfType(types.SpecComponentTypeJustBeforeEach)).Should(Equal([]leafnodes.BasicNode{jusBefA, jusBefB}))
|
||||
Ω(container.SetupNodesOfType(types.SpecComponentTypeIt)).Should(BeEmpty()) //subjects are not setup nodes
|
||||
})
|
||||
})
|
||||
|
||||
Context("With appended containers and subject nodes", func() {
|
||||
var (
|
||||
itA, itB, innerItA, innerItB leafnodes.SubjectNode
|
||||
innerContainer *ContainerNode
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
itA = leafnodes.NewItNode("Banana", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
|
||||
itB = leafnodes.NewItNode("Apple", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
|
||||
|
||||
innerItA = leafnodes.NewItNode("inner A", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
|
||||
innerItB = leafnodes.NewItNode("inner B", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
|
||||
|
||||
innerContainer = New("Orange", types.FlagTypeNone, codelocation.New(0))
|
||||
|
||||
container.PushSubjectNode(itA)
|
||||
container.PushContainerNode(innerContainer)
|
||||
innerContainer.PushSubjectNode(innerItA)
|
||||
innerContainer.PushSubjectNode(innerItB)
|
||||
container.PushSubjectNode(itB)
|
||||
})
|
||||
|
||||
Describe("Collating", func() {
|
||||
It("should return a collated set of containers and subject nodes in the correct order", func() {
|
||||
collated := container.Collate()
|
||||
Ω(collated).Should(HaveLen(4))
|
||||
|
||||
Ω(collated[0]).Should(Equal(CollatedNodes{
|
||||
Containers: []*ContainerNode{container},
|
||||
Subject: itA,
|
||||
}))
|
||||
|
||||
Ω(collated[1]).Should(Equal(CollatedNodes{
|
||||
Containers: []*ContainerNode{container, innerContainer},
|
||||
Subject: innerItA,
|
||||
}))
|
||||
|
||||
Ω(collated[2]).Should(Equal(CollatedNodes{
|
||||
Containers: []*ContainerNode{container, innerContainer},
|
||||
Subject: innerItB,
|
||||
}))
|
||||
|
||||
Ω(collated[3]).Should(Equal(CollatedNodes{
|
||||
Containers: []*ContainerNode{container},
|
||||
Subject: itB,
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Backpropagating Programmatic Focus", func() {
|
||||
//This allows inner focused specs to override the focus of outer focussed
|
||||
//specs and more closely maps to what a developer wants to happen
|
||||
//when debugging a test suite
|
||||
|
||||
Context("when a parent is focused *and* an inner subject is focused", func() {
|
||||
BeforeEach(func() {
|
||||
container = New("description text", types.FlagTypeFocused, codeLocation)
|
||||
itA = leafnodes.NewItNode("A", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
|
||||
container.PushSubjectNode(itA)
|
||||
|
||||
innerContainer = New("Orange", types.FlagTypeNone, codelocation.New(0))
|
||||
container.PushContainerNode(innerContainer)
|
||||
innerItA = leafnodes.NewItNode("inner A", func() {}, types.FlagTypeFocused, codelocation.New(0), 0, nil, 0)
|
||||
innerContainer.PushSubjectNode(innerItA)
|
||||
})
|
||||
|
||||
It("should unfocus the parent", func() {
|
||||
container.BackPropagateProgrammaticFocus()
|
||||
|
||||
Ω(container.Flag()).Should(Equal(types.FlagTypeNone))
|
||||
Ω(itA.Flag()).Should(Equal(types.FlagTypeNone))
|
||||
Ω(innerContainer.Flag()).Should(Equal(types.FlagTypeNone))
|
||||
Ω(innerItA.Flag()).Should(Equal(types.FlagTypeFocused))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a parent is focused *and* an inner container is focused", func() {
|
||||
BeforeEach(func() {
|
||||
container = New("description text", types.FlagTypeFocused, codeLocation)
|
||||
itA = leafnodes.NewItNode("A", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
|
||||
container.PushSubjectNode(itA)
|
||||
|
||||
innerContainer = New("Orange", types.FlagTypeFocused, codelocation.New(0))
|
||||
container.PushContainerNode(innerContainer)
|
||||
innerItA = leafnodes.NewItNode("inner A", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
|
||||
innerContainer.PushSubjectNode(innerItA)
|
||||
})
|
||||
|
||||
It("should unfocus the parent", func() {
|
||||
container.BackPropagateProgrammaticFocus()
|
||||
|
||||
Ω(container.Flag()).Should(Equal(types.FlagTypeNone))
|
||||
Ω(itA.Flag()).Should(Equal(types.FlagTypeNone))
|
||||
Ω(innerContainer.Flag()).Should(Equal(types.FlagTypeFocused))
|
||||
Ω(innerItA.Flag()).Should(Equal(types.FlagTypeNone))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a parent is pending and a child is focused", func() {
|
||||
BeforeEach(func() {
|
||||
container = New("description text", types.FlagTypeFocused, codeLocation)
|
||||
itA = leafnodes.NewItNode("A", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
|
||||
container.PushSubjectNode(itA)
|
||||
|
||||
innerContainer = New("Orange", types.FlagTypePending, codelocation.New(0))
|
||||
container.PushContainerNode(innerContainer)
|
||||
innerItA = leafnodes.NewItNode("inner A", func() {}, types.FlagTypeFocused, codelocation.New(0), 0, nil, 0)
|
||||
innerContainer.PushSubjectNode(innerItA)
|
||||
})
|
||||
|
||||
It("should not do anything", func() {
|
||||
container.BackPropagateProgrammaticFocus()
|
||||
|
||||
Ω(container.Flag()).Should(Equal(types.FlagTypeFocused))
|
||||
Ω(itA.Flag()).Should(Equal(types.FlagTypeNone))
|
||||
Ω(innerContainer.Flag()).Should(Equal(types.FlagTypePending))
|
||||
Ω(innerItA.Flag()).Should(Equal(types.FlagTypeFocused))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Shuffling", func() {
|
||||
var unshuffledCollation []CollatedNodes
|
||||
BeforeEach(func() {
|
||||
unshuffledCollation = container.Collate()
|
||||
|
||||
r := rand.New(rand.NewSource(17))
|
||||
container.Shuffle(r)
|
||||
})
|
||||
|
||||
It("should sort, and then shuffle, the top level contents of the container", func() {
|
||||
shuffledCollation := container.Collate()
|
||||
Ω(shuffledCollation).Should(HaveLen(len(unshuffledCollation)))
|
||||
Ω(shuffledCollation).ShouldNot(Equal(unshuffledCollation))
|
||||
|
||||
for _, entry := range unshuffledCollation {
|
||||
Ω(shuffledCollation).Should(ContainElement(entry))
|
||||
}
|
||||
|
||||
innerAIndex, innerBIndex := 0, 0
|
||||
for i, entry := range shuffledCollation {
|
||||
if entry.Subject == innerItA {
|
||||
innerAIndex = i
|
||||
} else if entry.Subject == innerItB {
|
||||
innerBIndex = i
|
||||
}
|
||||
}
|
||||
|
||||
Ω(innerAIndex).Should(Equal(innerBIndex - 1))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
13
vendor/github.com/onsi/ginkgo/internal/failer/failer_suite_test.go
generated
vendored
13
vendor/github.com/onsi/ginkgo/internal/failer/failer_suite_test.go
generated
vendored
|
|
@ -1,13 +0,0 @@
|
|||
package failer_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFailer(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Failer Suite")
|
||||
}
|
||||
141
vendor/github.com/onsi/ginkgo/internal/failer/failer_test.go
generated
vendored
141
vendor/github.com/onsi/ginkgo/internal/failer/failer_test.go
generated
vendored
|
|
@ -1,141 +0,0 @@
|
|||
package failer_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/internal/failer"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
)
|
||||
|
||||
var _ = Describe("Failer", func() {
|
||||
var (
|
||||
failer *Failer
|
||||
codeLocationA types.CodeLocation
|
||||
codeLocationB types.CodeLocation
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
codeLocationA = codelocation.New(0)
|
||||
codeLocationB = codelocation.New(0)
|
||||
failer = New()
|
||||
})
|
||||
|
||||
Context("with no failures", func() {
|
||||
It("should return success when drained", func() {
|
||||
failure, state := failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
|
||||
Ω(failure).Should(BeZero())
|
||||
Ω(state).Should(Equal(types.SpecStatePassed))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Skip", func() {
|
||||
It("should handle failures", func() {
|
||||
failer.Skip("something skipped", codeLocationA)
|
||||
failure, state := failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
|
||||
Ω(failure).Should(Equal(types.SpecFailure{
|
||||
Message: "something skipped",
|
||||
Location: codeLocationA,
|
||||
ForwardedPanic: "",
|
||||
ComponentType: types.SpecComponentTypeIt,
|
||||
ComponentIndex: 3,
|
||||
ComponentCodeLocation: codeLocationB,
|
||||
}))
|
||||
Ω(state).Should(Equal(types.SpecStateSkipped))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Fail", func() {
|
||||
It("should handle failures", func() {
|
||||
failer.Fail("something failed", codeLocationA)
|
||||
failure, state := failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
|
||||
Ω(failure).Should(Equal(types.SpecFailure{
|
||||
Message: "something failed",
|
||||
Location: codeLocationA,
|
||||
ForwardedPanic: "",
|
||||
ComponentType: types.SpecComponentTypeIt,
|
||||
ComponentIndex: 3,
|
||||
ComponentCodeLocation: codeLocationB,
|
||||
}))
|
||||
Ω(state).Should(Equal(types.SpecStateFailed))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Panic", func() {
|
||||
It("should handle panics", func() {
|
||||
failer.Panic(codeLocationA, "some forwarded panic")
|
||||
failure, state := failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
|
||||
Ω(failure).Should(Equal(types.SpecFailure{
|
||||
Message: "Test Panicked",
|
||||
Location: codeLocationA,
|
||||
ForwardedPanic: "some forwarded panic",
|
||||
ComponentType: types.SpecComponentTypeIt,
|
||||
ComponentIndex: 3,
|
||||
ComponentCodeLocation: codeLocationB,
|
||||
}))
|
||||
Ω(state).Should(Equal(types.SpecStatePanicked))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Timeout", func() {
|
||||
It("should handle timeouts", func() {
|
||||
failer.Timeout(codeLocationA)
|
||||
failure, state := failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
|
||||
Ω(failure).Should(Equal(types.SpecFailure{
|
||||
Message: "Timed out",
|
||||
Location: codeLocationA,
|
||||
ForwardedPanic: "",
|
||||
ComponentType: types.SpecComponentTypeIt,
|
||||
ComponentIndex: 3,
|
||||
ComponentCodeLocation: codeLocationB,
|
||||
}))
|
||||
Ω(state).Should(Equal(types.SpecStateTimedOut))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when multiple failures are registered", func() {
|
||||
BeforeEach(func() {
|
||||
failer.Fail("something failed", codeLocationA)
|
||||
failer.Fail("something else failed", codeLocationA)
|
||||
})
|
||||
|
||||
It("should only report the first one when drained", func() {
|
||||
failure, state := failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
|
||||
|
||||
Ω(failure).Should(Equal(types.SpecFailure{
|
||||
Message: "something failed",
|
||||
Location: codeLocationA,
|
||||
ForwardedPanic: "",
|
||||
ComponentType: types.SpecComponentTypeIt,
|
||||
ComponentIndex: 3,
|
||||
ComponentCodeLocation: codeLocationB,
|
||||
}))
|
||||
Ω(state).Should(Equal(types.SpecStateFailed))
|
||||
})
|
||||
|
||||
It("should report subsequent failures after being drained", func() {
|
||||
failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
|
||||
failer.Fail("yet another thing failed", codeLocationA)
|
||||
|
||||
failure, state := failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
|
||||
|
||||
Ω(failure).Should(Equal(types.SpecFailure{
|
||||
Message: "yet another thing failed",
|
||||
Location: codeLocationA,
|
||||
ForwardedPanic: "",
|
||||
ComponentType: types.SpecComponentTypeIt,
|
||||
ComponentIndex: 3,
|
||||
ComponentCodeLocation: codeLocationB,
|
||||
}))
|
||||
Ω(state).Should(Equal(types.SpecStateFailed))
|
||||
})
|
||||
|
||||
It("should report sucess on subsequent drains if no errors occur", func() {
|
||||
failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
|
||||
failure, state := failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
|
||||
Ω(failure).Should(BeZero())
|
||||
Ω(state).Should(Equal(types.SpecStatePassed))
|
||||
})
|
||||
})
|
||||
})
|
||||
4
vendor/github.com/onsi/ginkgo/internal/leafnodes/benchmarker.go
generated
vendored
4
vendor/github.com/onsi/ginkgo/internal/leafnodes/benchmarker.go
generated
vendored
|
|
@ -35,15 +35,15 @@ func (b *benchmarker) Time(name string, body func(), info ...interface{}) (elaps
|
|||
}
|
||||
|
||||
func (b *benchmarker) RecordValue(name string, value float64, info ...interface{}) {
|
||||
measurement := b.getMeasurement(name, "Smallest", " Largest", " Average", "", 3, info...)
|
||||
b.mu.Lock()
|
||||
measurement := b.getMeasurement(name, "Smallest", " Largest", " Average", "", 3, info...)
|
||||
defer b.mu.Unlock()
|
||||
measurement.Results = append(measurement.Results, value)
|
||||
}
|
||||
|
||||
func (b *benchmarker) RecordValueWithPrecision(name string, value float64, units string, precision int, info ...interface{}) {
|
||||
measurement := b.getMeasurement(name, "Smallest", " Largest", " Average", units, precision, info...)
|
||||
b.mu.Lock()
|
||||
measurement := b.getMeasurement(name, "Smallest", " Largest", " Average", units, precision, info...)
|
||||
defer b.mu.Unlock()
|
||||
measurement.Results = append(measurement.Results, value)
|
||||
}
|
||||
|
|
|
|||
3
vendor/github.com/onsi/ginkgo/internal/leafnodes/it_node.go
generated
vendored
3
vendor/github.com/onsi/ginkgo/internal/leafnodes/it_node.go
generated
vendored
|
|
@ -1,9 +1,10 @@
|
|||
package leafnodes
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/failer"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ItNode struct {
|
||||
|
|
|
|||
22
vendor/github.com/onsi/ginkgo/internal/leafnodes/it_node_test.go
generated
vendored
22
vendor/github.com/onsi/ginkgo/internal/leafnodes/it_node_test.go
generated
vendored
|
|
@ -1,22 +0,0 @@
|
|||
package leafnodes_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/internal/leafnodes"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
)
|
||||
|
||||
var _ = Describe("It Nodes", func() {
|
||||
It("should report the correct type, text, flag, and code location", func() {
|
||||
codeLocation := codelocation.New(0)
|
||||
it := NewItNode("my it node", func() {}, types.FlagTypeFocused, codeLocation, 0, nil, 3)
|
||||
Ω(it.Type()).Should(Equal(types.SpecComponentTypeIt))
|
||||
Ω(it.Flag()).Should(Equal(types.FlagTypeFocused))
|
||||
Ω(it.Text()).Should(Equal("my it node"))
|
||||
Ω(it.CodeLocation()).Should(Equal(codeLocation))
|
||||
Ω(it.Samples()).Should(Equal(1))
|
||||
})
|
||||
})
|
||||
13
vendor/github.com/onsi/ginkgo/internal/leafnodes/leaf_node_suite_test.go
generated
vendored
13
vendor/github.com/onsi/ginkgo/internal/leafnodes/leaf_node_suite_test.go
generated
vendored
|
|
@ -1,13 +0,0 @@
|
|||
package leafnodes_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLeafNode(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "LeafNode Suite")
|
||||
}
|
||||
3
vendor/github.com/onsi/ginkgo/internal/leafnodes/measure_node.go
generated
vendored
3
vendor/github.com/onsi/ginkgo/internal/leafnodes/measure_node.go
generated
vendored
|
|
@ -1,9 +1,10 @@
|
|||
package leafnodes
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/failer"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
type MeasureNode struct {
|
||||
|
|
|
|||
154
vendor/github.com/onsi/ginkgo/internal/leafnodes/measure_node_test.go
generated
vendored
154
vendor/github.com/onsi/ginkgo/internal/leafnodes/measure_node_test.go
generated
vendored
|
|
@ -1,154 +0,0 @@
|
|||
package leafnodes_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/internal/leafnodes"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
Failer "github.com/onsi/ginkgo/internal/failer"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
"time"
|
||||
)
|
||||
|
||||
var _ = Describe("Measure Nodes", func() {
|
||||
It("should report the correct type, text, flag, and code location", func() {
|
||||
codeLocation := codelocation.New(0)
|
||||
measure := NewMeasureNode("my measure node", func(b Benchmarker) {}, types.FlagTypeFocused, codeLocation, 10, nil, 3)
|
||||
Ω(measure.Type()).Should(Equal(types.SpecComponentTypeMeasure))
|
||||
Ω(measure.Flag()).Should(Equal(types.FlagTypeFocused))
|
||||
Ω(measure.Text()).Should(Equal("my measure node"))
|
||||
Ω(measure.CodeLocation()).Should(Equal(codeLocation))
|
||||
Ω(measure.Samples()).Should(Equal(10))
|
||||
})
|
||||
|
||||
Describe("benchmarking", func() {
|
||||
var measure *MeasureNode
|
||||
|
||||
Describe("Value", func() {
|
||||
BeforeEach(func() {
|
||||
measure = NewMeasureNode("the measurement", func(b Benchmarker) {
|
||||
b.RecordValue("foo", 7, "info!")
|
||||
b.RecordValue("foo", 2)
|
||||
b.RecordValue("foo", 3)
|
||||
b.RecordValue("bar", 0.3)
|
||||
b.RecordValue("bar", 0.1)
|
||||
b.RecordValue("bar", 0.5)
|
||||
b.RecordValue("bar", 0.7)
|
||||
}, types.FlagTypeFocused, codelocation.New(0), 1, Failer.New(), 3)
|
||||
Ω(measure.Run()).Should(Equal(types.SpecStatePassed))
|
||||
})
|
||||
|
||||
It("records passed in values and reports on them", func() {
|
||||
report := measure.MeasurementsReport()
|
||||
Ω(report).Should(HaveLen(2))
|
||||
Ω(report["foo"].Name).Should(Equal("foo"))
|
||||
Ω(report["foo"].Info).Should(Equal("info!"))
|
||||
Ω(report["foo"].Order).Should(Equal(0))
|
||||
Ω(report["foo"].SmallestLabel).Should(Equal("Smallest"))
|
||||
Ω(report["foo"].LargestLabel).Should(Equal(" Largest"))
|
||||
Ω(report["foo"].AverageLabel).Should(Equal(" Average"))
|
||||
Ω(report["foo"].Units).Should(Equal(""))
|
||||
Ω(report["foo"].Results).Should(Equal([]float64{7, 2, 3}))
|
||||
Ω(report["foo"].Smallest).Should(BeNumerically("==", 2))
|
||||
Ω(report["foo"].Largest).Should(BeNumerically("==", 7))
|
||||
Ω(report["foo"].Average).Should(BeNumerically("==", 4))
|
||||
Ω(report["foo"].StdDeviation).Should(BeNumerically("~", 2.16, 0.01))
|
||||
|
||||
Ω(report["bar"].Name).Should(Equal("bar"))
|
||||
Ω(report["bar"].Info).Should(BeNil())
|
||||
Ω(report["bar"].SmallestLabel).Should(Equal("Smallest"))
|
||||
Ω(report["bar"].Order).Should(Equal(1))
|
||||
Ω(report["bar"].LargestLabel).Should(Equal(" Largest"))
|
||||
Ω(report["bar"].AverageLabel).Should(Equal(" Average"))
|
||||
Ω(report["bar"].Units).Should(Equal(""))
|
||||
Ω(report["bar"].Results).Should(Equal([]float64{0.3, 0.1, 0.5, 0.7}))
|
||||
Ω(report["bar"].Smallest).Should(BeNumerically("==", 0.1))
|
||||
Ω(report["bar"].Largest).Should(BeNumerically("==", 0.7))
|
||||
Ω(report["bar"].Average).Should(BeNumerically("==", 0.4))
|
||||
Ω(report["bar"].StdDeviation).Should(BeNumerically("~", 0.22, 0.01))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Value with precision", func() {
|
||||
BeforeEach(func() {
|
||||
measure = NewMeasureNode("the measurement", func(b Benchmarker) {
|
||||
b.RecordValueWithPrecision("foo", 7, "ms", 7, "info!")
|
||||
b.RecordValueWithPrecision("foo", 2, "ms", 6)
|
||||
b.RecordValueWithPrecision("foo", 3, "ms", 5)
|
||||
b.RecordValueWithPrecision("bar", 0.3, "ns", 4)
|
||||
b.RecordValueWithPrecision("bar", 0.1, "ns", 3)
|
||||
b.RecordValueWithPrecision("bar", 0.5, "ns", 2)
|
||||
b.RecordValueWithPrecision("bar", 0.7, "ns", 1)
|
||||
}, types.FlagTypeFocused, codelocation.New(0), 1, Failer.New(), 3)
|
||||
Ω(measure.Run()).Should(Equal(types.SpecStatePassed))
|
||||
})
|
||||
|
||||
It("records passed in values and reports on them", func() {
|
||||
report := measure.MeasurementsReport()
|
||||
Ω(report).Should(HaveLen(2))
|
||||
Ω(report["foo"].Name).Should(Equal("foo"))
|
||||
Ω(report["foo"].Info).Should(Equal("info!"))
|
||||
Ω(report["foo"].Order).Should(Equal(0))
|
||||
Ω(report["foo"].SmallestLabel).Should(Equal("Smallest"))
|
||||
Ω(report["foo"].LargestLabel).Should(Equal(" Largest"))
|
||||
Ω(report["foo"].AverageLabel).Should(Equal(" Average"))
|
||||
Ω(report["foo"].Units).Should(Equal("ms"))
|
||||
Ω(report["foo"].Results).Should(Equal([]float64{7, 2, 3}))
|
||||
Ω(report["foo"].Smallest).Should(BeNumerically("==", 2))
|
||||
Ω(report["foo"].Largest).Should(BeNumerically("==", 7))
|
||||
Ω(report["foo"].Average).Should(BeNumerically("==", 4))
|
||||
Ω(report["foo"].StdDeviation).Should(BeNumerically("~", 2.16, 0.01))
|
||||
|
||||
Ω(report["bar"].Name).Should(Equal("bar"))
|
||||
Ω(report["bar"].Info).Should(BeNil())
|
||||
Ω(report["bar"].SmallestLabel).Should(Equal("Smallest"))
|
||||
Ω(report["bar"].Order).Should(Equal(1))
|
||||
Ω(report["bar"].LargestLabel).Should(Equal(" Largest"))
|
||||
Ω(report["bar"].AverageLabel).Should(Equal(" Average"))
|
||||
Ω(report["bar"].Units).Should(Equal("ns"))
|
||||
Ω(report["bar"].Results).Should(Equal([]float64{0.3, 0.1, 0.5, 0.7}))
|
||||
Ω(report["bar"].Smallest).Should(BeNumerically("==", 0.1))
|
||||
Ω(report["bar"].Largest).Should(BeNumerically("==", 0.7))
|
||||
Ω(report["bar"].Average).Should(BeNumerically("==", 0.4))
|
||||
Ω(report["bar"].StdDeviation).Should(BeNumerically("~", 0.22, 0.01))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Time", func() {
|
||||
BeforeEach(func() {
|
||||
measure = NewMeasureNode("the measurement", func(b Benchmarker) {
|
||||
b.Time("foo", func() {
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}, "info!")
|
||||
b.Time("foo", func() {
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
})
|
||||
b.Time("foo", func() {
|
||||
time.Sleep(170 * time.Millisecond)
|
||||
})
|
||||
}, types.FlagTypeFocused, codelocation.New(0), 1, Failer.New(), 3)
|
||||
Ω(measure.Run()).Should(Equal(types.SpecStatePassed))
|
||||
})
|
||||
|
||||
It("records passed in values and reports on them", func() {
|
||||
report := measure.MeasurementsReport()
|
||||
Ω(report).Should(HaveLen(1))
|
||||
Ω(report["foo"].Name).Should(Equal("foo"))
|
||||
Ω(report["foo"].Info).Should(Equal("info!"))
|
||||
Ω(report["foo"].SmallestLabel).Should(Equal("Fastest Time"))
|
||||
Ω(report["foo"].LargestLabel).Should(Equal("Slowest Time"))
|
||||
Ω(report["foo"].AverageLabel).Should(Equal("Average Time"))
|
||||
Ω(report["foo"].Units).Should(Equal("s"))
|
||||
Ω(report["foo"].Results).Should(HaveLen(3))
|
||||
Ω(report["foo"].Results[0]).Should(BeNumerically("~", 0.1, 0.01))
|
||||
Ω(report["foo"].Results[1]).Should(BeNumerically("~", 0.2, 0.01))
|
||||
Ω(report["foo"].Results[2]).Should(BeNumerically("~", 0.17, 0.01))
|
||||
Ω(report["foo"].Smallest).Should(BeNumerically("~", 0.1, 0.01))
|
||||
Ω(report["foo"].Largest).Should(BeNumerically("~", 0.2, 0.01))
|
||||
Ω(report["foo"].Average).Should(BeNumerically("~", 0.16, 0.01))
|
||||
Ω(report["foo"].StdDeviation).Should(BeNumerically("~", 0.04, 0.01))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
5
vendor/github.com/onsi/ginkgo/internal/leafnodes/runner.go
generated
vendored
5
vendor/github.com/onsi/ginkgo/internal/leafnodes/runner.go
generated
vendored
|
|
@ -2,11 +2,12 @@ package leafnodes
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
"github.com/onsi/ginkgo/internal/failer"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
type runner struct {
|
||||
|
|
|
|||
3
vendor/github.com/onsi/ginkgo/internal/leafnodes/setup_nodes.go
generated
vendored
3
vendor/github.com/onsi/ginkgo/internal/leafnodes/setup_nodes.go
generated
vendored
|
|
@ -1,9 +1,10 @@
|
|||
package leafnodes
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/failer"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
"time"
|
||||
)
|
||||
|
||||
type SetupNode struct {
|
||||
|
|
|
|||
40
vendor/github.com/onsi/ginkgo/internal/leafnodes/setup_nodes_test.go
generated
vendored
40
vendor/github.com/onsi/ginkgo/internal/leafnodes/setup_nodes_test.go
generated
vendored
|
|
@ -1,40 +0,0 @@
|
|||
package leafnodes_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
. "github.com/onsi/ginkgo/internal/leafnodes"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
)
|
||||
|
||||
var _ = Describe("Setup Nodes", func() {
|
||||
Describe("BeforeEachNodes", func() {
|
||||
It("should report the correct type and code location", func() {
|
||||
codeLocation := codelocation.New(0)
|
||||
beforeEach := NewBeforeEachNode(func() {}, codeLocation, 0, nil, 3)
|
||||
Ω(beforeEach.Type()).Should(Equal(types.SpecComponentTypeBeforeEach))
|
||||
Ω(beforeEach.CodeLocation()).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("AfterEachNodes", func() {
|
||||
It("should report the correct type and code location", func() {
|
||||
codeLocation := codelocation.New(0)
|
||||
afterEach := NewAfterEachNode(func() {}, codeLocation, 0, nil, 3)
|
||||
Ω(afterEach.Type()).Should(Equal(types.SpecComponentTypeAfterEach))
|
||||
Ω(afterEach.CodeLocation()).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("JustBeforeEachNodes", func() {
|
||||
It("should report the correct type and code location", func() {
|
||||
codeLocation := codelocation.New(0)
|
||||
justBeforeEach := NewJustBeforeEachNode(func() {}, codeLocation, 0, nil, 3)
|
||||
Ω(justBeforeEach.Type()).Should(Equal(types.SpecComponentTypeJustBeforeEach))
|
||||
Ω(justBeforeEach.CodeLocation()).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
})
|
||||
356
vendor/github.com/onsi/ginkgo/internal/leafnodes/shared_runner_test.go
generated
vendored
356
vendor/github.com/onsi/ginkgo/internal/leafnodes/shared_runner_test.go
generated
vendored
|
|
@ -1,356 +0,0 @@
|
|||
package leafnodes_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/internal/leafnodes"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
Failer "github.com/onsi/ginkgo/internal/failer"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
)
|
||||
|
||||
type runnable interface {
|
||||
Run() (outcome types.SpecState, failure types.SpecFailure)
|
||||
CodeLocation() types.CodeLocation
|
||||
}
|
||||
|
||||
func SynchronousSharedRunnerBehaviors(build func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable, componentType types.SpecComponentType, componentIndex int) {
|
||||
var (
|
||||
outcome types.SpecState
|
||||
failure types.SpecFailure
|
||||
|
||||
failer *Failer.Failer
|
||||
|
||||
componentCodeLocation types.CodeLocation
|
||||
innerCodeLocation types.CodeLocation
|
||||
|
||||
didRun bool
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
failer = Failer.New()
|
||||
componentCodeLocation = codelocation.New(0)
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
|
||||
didRun = false
|
||||
})
|
||||
|
||||
Describe("synchronous functions", func() {
|
||||
Context("when the function passes", func() {
|
||||
BeforeEach(func() {
|
||||
outcome, failure = build(func() {
|
||||
didRun = true
|
||||
}, 0, failer, componentCodeLocation).Run()
|
||||
})
|
||||
|
||||
It("should have a succesful outcome", func() {
|
||||
Ω(didRun).Should(BeTrue())
|
||||
|
||||
Ω(outcome).Should(Equal(types.SpecStatePassed))
|
||||
Ω(failure).Should(BeZero())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a failure occurs", func() {
|
||||
BeforeEach(func() {
|
||||
outcome, failure = build(func() {
|
||||
didRun = true
|
||||
failer.Fail("bam", innerCodeLocation)
|
||||
panic("should not matter")
|
||||
}, 0, failer, componentCodeLocation).Run()
|
||||
})
|
||||
|
||||
It("should return the failure", func() {
|
||||
Ω(didRun).Should(BeTrue())
|
||||
|
||||
Ω(outcome).Should(Equal(types.SpecStateFailed))
|
||||
Ω(failure).Should(Equal(types.SpecFailure{
|
||||
Message: "bam",
|
||||
Location: innerCodeLocation,
|
||||
ForwardedPanic: "",
|
||||
ComponentIndex: componentIndex,
|
||||
ComponentType: componentType,
|
||||
ComponentCodeLocation: componentCodeLocation,
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a panic occurs", func() {
|
||||
BeforeEach(func() {
|
||||
outcome, failure = build(func() {
|
||||
didRun = true
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
panic("ack!")
|
||||
}, 0, failer, componentCodeLocation).Run()
|
||||
})
|
||||
|
||||
It("should return the panic", func() {
|
||||
Ω(didRun).Should(BeTrue())
|
||||
|
||||
Ω(outcome).Should(Equal(types.SpecStatePanicked))
|
||||
Ω(failure.ForwardedPanic).Should(Equal("ack!"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a panic occurs with a nil value", func() {
|
||||
BeforeEach(func() {
|
||||
outcome, failure = build(func() {
|
||||
didRun = true
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
panic(nil)
|
||||
}, 0, failer, componentCodeLocation).Run()
|
||||
})
|
||||
|
||||
It("should return the nil-valued panic", func() {
|
||||
Ω(didRun).Should(BeTrue())
|
||||
|
||||
Ω(outcome).Should(Equal(types.SpecStatePanicked))
|
||||
Ω(failure.ForwardedPanic).Should(Equal("<nil>"))
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
func AsynchronousSharedRunnerBehaviors(build func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable, componentType types.SpecComponentType, componentIndex int) {
|
||||
var (
|
||||
outcome types.SpecState
|
||||
failure types.SpecFailure
|
||||
|
||||
failer *Failer.Failer
|
||||
|
||||
componentCodeLocation types.CodeLocation
|
||||
innerCodeLocation types.CodeLocation
|
||||
|
||||
didRun bool
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
failer = Failer.New()
|
||||
componentCodeLocation = codelocation.New(0)
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
|
||||
didRun = false
|
||||
})
|
||||
|
||||
Describe("asynchronous functions", func() {
|
||||
var timeoutDuration time.Duration
|
||||
|
||||
BeforeEach(func() {
|
||||
timeoutDuration = time.Duration(1 * float64(time.Second))
|
||||
})
|
||||
|
||||
Context("when running", func() {
|
||||
It("should run the function as a goroutine, and block until it's done", func() {
|
||||
proveAsync := make(chan bool)
|
||||
|
||||
build(func(done Done) {
|
||||
didRun = true
|
||||
proveAsync <- true
|
||||
close(done)
|
||||
}, timeoutDuration, failer, componentCodeLocation).Run()
|
||||
|
||||
Eventually(proveAsync).Should(Receive(Equal(true)))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the function passes", func() {
|
||||
BeforeEach(func() {
|
||||
outcome, failure = build(func(done Done) {
|
||||
didRun = true
|
||||
close(done)
|
||||
}, timeoutDuration, failer, componentCodeLocation).Run()
|
||||
})
|
||||
|
||||
It("should have a succesful outcome", func() {
|
||||
Ω(didRun).Should(BeTrue())
|
||||
Ω(outcome).Should(Equal(types.SpecStatePassed))
|
||||
Ω(failure).Should(BeZero())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the function fails", func() {
|
||||
BeforeEach(func() {
|
||||
outcome, failure = build(func(done Done) {
|
||||
didRun = true
|
||||
failer.Fail("bam", innerCodeLocation)
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
panic("doesn't matter")
|
||||
close(done)
|
||||
}, 10*time.Millisecond, failer, componentCodeLocation).Run()
|
||||
})
|
||||
|
||||
It("should return the failure", func() {
|
||||
Ω(didRun).Should(BeTrue())
|
||||
|
||||
Ω(outcome).Should(Equal(types.SpecStateFailed))
|
||||
Ω(failure).Should(Equal(types.SpecFailure{
|
||||
Message: "bam",
|
||||
Location: innerCodeLocation,
|
||||
ForwardedPanic: "",
|
||||
ComponentIndex: componentIndex,
|
||||
ComponentType: componentType,
|
||||
ComponentCodeLocation: componentCodeLocation,
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the function times out", func() {
|
||||
var guard chan struct{}
|
||||
|
||||
BeforeEach(func() {
|
||||
guard = make(chan struct{})
|
||||
outcome, failure = build(func(done Done) {
|
||||
didRun = true
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
close(guard)
|
||||
panic("doesn't matter")
|
||||
close(done)
|
||||
}, 10*time.Millisecond, failer, componentCodeLocation).Run()
|
||||
})
|
||||
|
||||
It("should return the timeout", func() {
|
||||
<-guard
|
||||
Ω(didRun).Should(BeTrue())
|
||||
|
||||
Ω(outcome).Should(Equal(types.SpecStateTimedOut))
|
||||
Ω(failure).Should(Equal(types.SpecFailure{
|
||||
Message: "Timed out",
|
||||
Location: componentCodeLocation,
|
||||
ForwardedPanic: "",
|
||||
ComponentIndex: componentIndex,
|
||||
ComponentType: componentType,
|
||||
ComponentCodeLocation: componentCodeLocation,
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the function panics", func() {
|
||||
BeforeEach(func() {
|
||||
outcome, failure = build(func(done Done) {
|
||||
didRun = true
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
panic("ack!")
|
||||
}, 100*time.Millisecond, failer, componentCodeLocation).Run()
|
||||
})
|
||||
|
||||
It("should return the panic", func() {
|
||||
Ω(didRun).Should(BeTrue())
|
||||
|
||||
Ω(outcome).Should(Equal(types.SpecStatePanicked))
|
||||
Ω(failure.ForwardedPanic).Should(Equal("ack!"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the function panics with a nil value", func() {
|
||||
BeforeEach(func() {
|
||||
outcome, failure = build(func(done Done) {
|
||||
didRun = true
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
panic(nil)
|
||||
}, 100*time.Millisecond, failer, componentCodeLocation).Run()
|
||||
})
|
||||
|
||||
It("should return the nil-valued panic", func() {
|
||||
Ω(didRun).Should(BeTrue())
|
||||
|
||||
Ω(outcome).Should(Equal(types.SpecStatePanicked))
|
||||
Ω(failure.ForwardedPanic).Should(Equal("<nil>"))
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func InvalidSharedRunnerBehaviors(build func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable, componentType types.SpecComponentType) {
|
||||
var (
|
||||
failer *Failer.Failer
|
||||
componentCodeLocation types.CodeLocation
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
failer = Failer.New()
|
||||
componentCodeLocation = codelocation.New(0)
|
||||
})
|
||||
|
||||
Describe("invalid functions", func() {
|
||||
Context("when passed something that's not a function", func() {
|
||||
It("should panic", func() {
|
||||
Ω(func() {
|
||||
build("not a function", 0, failer, componentCodeLocation)
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the function takes the wrong kind of argument", func() {
|
||||
It("should panic", func() {
|
||||
Ω(func() {
|
||||
build(func(oops string) {}, 0, failer, componentCodeLocation)
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the function takes more than one argument", func() {
|
||||
It("should panic", func() {
|
||||
Ω(func() {
|
||||
build(func(done Done, oops string) {}, 0, failer, componentCodeLocation)
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
var _ = Describe("Shared RunnableNode behavior", func() {
|
||||
Describe("It Nodes", func() {
|
||||
build := func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable {
|
||||
return NewItNode("", body, types.FlagTypeFocused, componentCodeLocation, timeout, failer, 3)
|
||||
}
|
||||
|
||||
SynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeIt, 3)
|
||||
AsynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeIt, 3)
|
||||
InvalidSharedRunnerBehaviors(build, types.SpecComponentTypeIt)
|
||||
})
|
||||
|
||||
Describe("Measure Nodes", func() {
|
||||
build := func(body interface{}, _ time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable {
|
||||
return NewMeasureNode("", func(Benchmarker) {
|
||||
reflect.ValueOf(body).Call([]reflect.Value{})
|
||||
}, types.FlagTypeFocused, componentCodeLocation, 10, failer, 3)
|
||||
}
|
||||
|
||||
SynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeMeasure, 3)
|
||||
})
|
||||
|
||||
Describe("BeforeEach Nodes", func() {
|
||||
build := func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable {
|
||||
return NewBeforeEachNode(body, componentCodeLocation, timeout, failer, 3)
|
||||
}
|
||||
|
||||
SynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeBeforeEach, 3)
|
||||
AsynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeBeforeEach, 3)
|
||||
InvalidSharedRunnerBehaviors(build, types.SpecComponentTypeBeforeEach)
|
||||
})
|
||||
|
||||
Describe("AfterEach Nodes", func() {
|
||||
build := func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable {
|
||||
return NewAfterEachNode(body, componentCodeLocation, timeout, failer, 3)
|
||||
}
|
||||
|
||||
SynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeAfterEach, 3)
|
||||
AsynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeAfterEach, 3)
|
||||
InvalidSharedRunnerBehaviors(build, types.SpecComponentTypeAfterEach)
|
||||
})
|
||||
|
||||
Describe("JustBeforeEach Nodes", func() {
|
||||
build := func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable {
|
||||
return NewJustBeforeEachNode(body, componentCodeLocation, timeout, failer, 3)
|
||||
}
|
||||
|
||||
SynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeJustBeforeEach, 3)
|
||||
AsynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeJustBeforeEach, 3)
|
||||
InvalidSharedRunnerBehaviors(build, types.SpecComponentTypeJustBeforeEach)
|
||||
})
|
||||
})
|
||||
3
vendor/github.com/onsi/ginkgo/internal/leafnodes/suite_nodes.go
generated
vendored
3
vendor/github.com/onsi/ginkgo/internal/leafnodes/suite_nodes.go
generated
vendored
|
|
@ -1,9 +1,10 @@
|
|||
package leafnodes
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/failer"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
"time"
|
||||
)
|
||||
|
||||
type SuiteNode interface {
|
||||
|
|
|
|||
230
vendor/github.com/onsi/ginkgo/internal/leafnodes/suite_nodes_test.go
generated
vendored
230
vendor/github.com/onsi/ginkgo/internal/leafnodes/suite_nodes_test.go
generated
vendored
|
|
@ -1,230 +0,0 @@
|
|||
package leafnodes_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
. "github.com/onsi/ginkgo/internal/leafnodes"
|
||||
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
Failer "github.com/onsi/ginkgo/internal/failer"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
)
|
||||
|
||||
var _ = Describe("SuiteNodes", func() {
|
||||
Describe("BeforeSuite nodes", func() {
|
||||
var befSuite SuiteNode
|
||||
var failer *Failer.Failer
|
||||
var codeLocation types.CodeLocation
|
||||
var innerCodeLocation types.CodeLocation
|
||||
var outcome bool
|
||||
|
||||
BeforeEach(func() {
|
||||
failer = Failer.New()
|
||||
codeLocation = codelocation.New(0)
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
})
|
||||
|
||||
Context("when the body passes", func() {
|
||||
BeforeEach(func() {
|
||||
befSuite = NewBeforeSuiteNode(func() {
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}, codeLocation, 0, failer)
|
||||
outcome = befSuite.Run(0, 0, "")
|
||||
})
|
||||
|
||||
It("should return true when run and report as passed", func() {
|
||||
Ω(outcome).Should(BeTrue())
|
||||
Ω(befSuite.Passed()).Should(BeTrue())
|
||||
})
|
||||
|
||||
It("should have the correct summary", func() {
|
||||
summary := befSuite.Summary()
|
||||
Ω(summary.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite))
|
||||
Ω(summary.CodeLocation).Should(Equal(codeLocation))
|
||||
Ω(summary.State).Should(Equal(types.SpecStatePassed))
|
||||
Ω(summary.RunTime).Should(BeNumerically(">=", 10*time.Millisecond))
|
||||
Ω(summary.Failure).Should(BeZero())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the body fails", func() {
|
||||
BeforeEach(func() {
|
||||
befSuite = NewBeforeSuiteNode(func() {
|
||||
failer.Fail("oops", innerCodeLocation)
|
||||
}, codeLocation, 0, failer)
|
||||
outcome = befSuite.Run(0, 0, "")
|
||||
})
|
||||
|
||||
It("should return false when run and report as failed", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(befSuite.Passed()).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should have the correct summary", func() {
|
||||
summary := befSuite.Summary()
|
||||
Ω(summary.State).Should(Equal(types.SpecStateFailed))
|
||||
Ω(summary.Failure.Message).Should(Equal("oops"))
|
||||
Ω(summary.Failure.Location).Should(Equal(innerCodeLocation))
|
||||
Ω(summary.Failure.ForwardedPanic).Should(BeEmpty())
|
||||
Ω(summary.Failure.ComponentIndex).Should(Equal(0))
|
||||
Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite))
|
||||
Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the body times out", func() {
|
||||
BeforeEach(func() {
|
||||
befSuite = NewBeforeSuiteNode(func(done Done) {
|
||||
}, codeLocation, time.Millisecond, failer)
|
||||
outcome = befSuite.Run(0, 0, "")
|
||||
})
|
||||
|
||||
It("should return false when run and report as failed", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(befSuite.Passed()).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should have the correct summary", func() {
|
||||
summary := befSuite.Summary()
|
||||
Ω(summary.State).Should(Equal(types.SpecStateTimedOut))
|
||||
Ω(summary.Failure.ForwardedPanic).Should(BeEmpty())
|
||||
Ω(summary.Failure.ComponentIndex).Should(Equal(0))
|
||||
Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite))
|
||||
Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the body panics", func() {
|
||||
BeforeEach(func() {
|
||||
befSuite = NewBeforeSuiteNode(func() {
|
||||
panic("bam")
|
||||
}, codeLocation, 0, failer)
|
||||
outcome = befSuite.Run(0, 0, "")
|
||||
})
|
||||
|
||||
It("should return false when run and report as failed", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(befSuite.Passed()).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should have the correct summary", func() {
|
||||
summary := befSuite.Summary()
|
||||
Ω(summary.State).Should(Equal(types.SpecStatePanicked))
|
||||
Ω(summary.Failure.ForwardedPanic).Should(Equal("bam"))
|
||||
Ω(summary.Failure.ComponentIndex).Should(Equal(0))
|
||||
Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite))
|
||||
Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("AfterSuite nodes", func() {
|
||||
var aftSuite SuiteNode
|
||||
var failer *Failer.Failer
|
||||
var codeLocation types.CodeLocation
|
||||
var innerCodeLocation types.CodeLocation
|
||||
var outcome bool
|
||||
|
||||
BeforeEach(func() {
|
||||
failer = Failer.New()
|
||||
codeLocation = codelocation.New(0)
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
})
|
||||
|
||||
Context("when the body passes", func() {
|
||||
BeforeEach(func() {
|
||||
aftSuite = NewAfterSuiteNode(func() {
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}, codeLocation, 0, failer)
|
||||
outcome = aftSuite.Run(0, 0, "")
|
||||
})
|
||||
|
||||
It("should return true when run and report as passed", func() {
|
||||
Ω(outcome).Should(BeTrue())
|
||||
Ω(aftSuite.Passed()).Should(BeTrue())
|
||||
})
|
||||
|
||||
It("should have the correct summary", func() {
|
||||
summary := aftSuite.Summary()
|
||||
Ω(summary.ComponentType).Should(Equal(types.SpecComponentTypeAfterSuite))
|
||||
Ω(summary.CodeLocation).Should(Equal(codeLocation))
|
||||
Ω(summary.State).Should(Equal(types.SpecStatePassed))
|
||||
Ω(summary.RunTime).Should(BeNumerically(">=", 10*time.Millisecond))
|
||||
Ω(summary.Failure).Should(BeZero())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the body fails", func() {
|
||||
BeforeEach(func() {
|
||||
aftSuite = NewAfterSuiteNode(func() {
|
||||
failer.Fail("oops", innerCodeLocation)
|
||||
}, codeLocation, 0, failer)
|
||||
outcome = aftSuite.Run(0, 0, "")
|
||||
})
|
||||
|
||||
It("should return false when run and report as failed", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(aftSuite.Passed()).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should have the correct summary", func() {
|
||||
summary := aftSuite.Summary()
|
||||
Ω(summary.State).Should(Equal(types.SpecStateFailed))
|
||||
Ω(summary.Failure.Message).Should(Equal("oops"))
|
||||
Ω(summary.Failure.Location).Should(Equal(innerCodeLocation))
|
||||
Ω(summary.Failure.ForwardedPanic).Should(BeEmpty())
|
||||
Ω(summary.Failure.ComponentIndex).Should(Equal(0))
|
||||
Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeAfterSuite))
|
||||
Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the body times out", func() {
|
||||
BeforeEach(func() {
|
||||
aftSuite = NewAfterSuiteNode(func(done Done) {
|
||||
}, codeLocation, time.Millisecond, failer)
|
||||
outcome = aftSuite.Run(0, 0, "")
|
||||
})
|
||||
|
||||
It("should return false when run and report as failed", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(aftSuite.Passed()).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should have the correct summary", func() {
|
||||
summary := aftSuite.Summary()
|
||||
Ω(summary.State).Should(Equal(types.SpecStateTimedOut))
|
||||
Ω(summary.Failure.ForwardedPanic).Should(BeEmpty())
|
||||
Ω(summary.Failure.ComponentIndex).Should(Equal(0))
|
||||
Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeAfterSuite))
|
||||
Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the body panics", func() {
|
||||
BeforeEach(func() {
|
||||
aftSuite = NewAfterSuiteNode(func() {
|
||||
panic("bam")
|
||||
}, codeLocation, 0, failer)
|
||||
outcome = aftSuite.Run(0, 0, "")
|
||||
})
|
||||
|
||||
It("should return false when run and report as failed", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(aftSuite.Passed()).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should have the correct summary", func() {
|
||||
summary := aftSuite.Summary()
|
||||
Ω(summary.State).Should(Equal(types.SpecStatePanicked))
|
||||
Ω(summary.Failure.ForwardedPanic).Should(Equal("bam"))
|
||||
Ω(summary.Failure.ComponentIndex).Should(Equal(0))
|
||||
Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeAfterSuite))
|
||||
Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
5
vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_after_suite_node.go
generated
vendored
5
vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_after_suite_node.go
generated
vendored
|
|
@ -2,11 +2,12 @@ package leafnodes
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/onsi/ginkgo/internal/failer"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/failer"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
)
|
||||
|
||||
type synchronizedAfterSuiteNode struct {
|
||||
|
|
|
|||
196
vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_after_suite_node_test.go
generated
vendored
196
vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_after_suite_node_test.go
generated
vendored
|
|
@ -1,196 +0,0 @@
|
|||
package leafnodes_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/internal/leafnodes"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
. "github.com/onsi/gomega"
|
||||
"sync"
|
||||
|
||||
"github.com/onsi/gomega/ghttp"
|
||||
"net/http"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
Failer "github.com/onsi/ginkgo/internal/failer"
|
||||
"time"
|
||||
)
|
||||
|
||||
var _ = Describe("SynchronizedAfterSuiteNode", func() {
|
||||
var failer *Failer.Failer
|
||||
var node SuiteNode
|
||||
var codeLocation types.CodeLocation
|
||||
var innerCodeLocation types.CodeLocation
|
||||
var outcome bool
|
||||
var server *ghttp.Server
|
||||
var things []string
|
||||
var lock *sync.Mutex
|
||||
|
||||
BeforeEach(func() {
|
||||
things = []string{}
|
||||
server = ghttp.NewServer()
|
||||
codeLocation = codelocation.New(0)
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
failer = Failer.New()
|
||||
lock = &sync.Mutex{}
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
server.Close()
|
||||
})
|
||||
|
||||
newNode := func(bodyA interface{}, bodyB interface{}) SuiteNode {
|
||||
return NewSynchronizedAfterSuiteNode(bodyA, bodyB, codeLocation, time.Millisecond, failer)
|
||||
}
|
||||
|
||||
ranThing := func(thing string) {
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
things = append(things, thing)
|
||||
}
|
||||
|
||||
thingsThatRan := func() []string {
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
return things
|
||||
}
|
||||
|
||||
Context("when not running in parallel", func() {
|
||||
Context("when all is well", func() {
|
||||
BeforeEach(func() {
|
||||
node = newNode(func() {
|
||||
ranThing("A")
|
||||
}, func() {
|
||||
ranThing("B")
|
||||
})
|
||||
|
||||
outcome = node.Run(1, 1, server.URL())
|
||||
})
|
||||
|
||||
It("should run A, then B", func() {
|
||||
Ω(thingsThatRan()).Should(Equal([]string{"A", "B"}))
|
||||
})
|
||||
|
||||
It("should report success", func() {
|
||||
Ω(outcome).Should(BeTrue())
|
||||
Ω(node.Passed()).Should(BeTrue())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStatePassed))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when A fails", func() {
|
||||
BeforeEach(func() {
|
||||
node = newNode(func() {
|
||||
ranThing("A")
|
||||
failer.Fail("bam", innerCodeLocation)
|
||||
}, func() {
|
||||
ranThing("B")
|
||||
})
|
||||
|
||||
outcome = node.Run(1, 1, server.URL())
|
||||
})
|
||||
|
||||
It("should still run B", func() {
|
||||
Ω(thingsThatRan()).Should(Equal([]string{"A", "B"}))
|
||||
})
|
||||
|
||||
It("should report failure", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(node.Passed()).Should(BeFalse())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStateFailed))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when B fails", func() {
|
||||
BeforeEach(func() {
|
||||
node = newNode(func() {
|
||||
ranThing("A")
|
||||
}, func() {
|
||||
ranThing("B")
|
||||
failer.Fail("bam", innerCodeLocation)
|
||||
})
|
||||
|
||||
outcome = node.Run(1, 1, server.URL())
|
||||
})
|
||||
|
||||
It("should run all the things", func() {
|
||||
Ω(thingsThatRan()).Should(Equal([]string{"A", "B"}))
|
||||
})
|
||||
|
||||
It("should report failure", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(node.Passed()).Should(BeFalse())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStateFailed))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("when running in parallel", func() {
|
||||
Context("as the first node", func() {
|
||||
BeforeEach(func() {
|
||||
server.AppendHandlers(ghttp.CombineHandlers(
|
||||
ghttp.VerifyRequest("GET", "/RemoteAfterSuiteData"),
|
||||
func(writer http.ResponseWriter, request *http.Request) {
|
||||
ranThing("Request1")
|
||||
},
|
||||
ghttp.RespondWithJSONEncoded(200, types.RemoteAfterSuiteData{false}),
|
||||
), ghttp.CombineHandlers(
|
||||
ghttp.VerifyRequest("GET", "/RemoteAfterSuiteData"),
|
||||
func(writer http.ResponseWriter, request *http.Request) {
|
||||
ranThing("Request2")
|
||||
},
|
||||
ghttp.RespondWithJSONEncoded(200, types.RemoteAfterSuiteData{false}),
|
||||
), ghttp.CombineHandlers(
|
||||
ghttp.VerifyRequest("GET", "/RemoteAfterSuiteData"),
|
||||
func(writer http.ResponseWriter, request *http.Request) {
|
||||
ranThing("Request3")
|
||||
},
|
||||
ghttp.RespondWithJSONEncoded(200, types.RemoteAfterSuiteData{true}),
|
||||
))
|
||||
|
||||
node = newNode(func() {
|
||||
ranThing("A")
|
||||
}, func() {
|
||||
ranThing("B")
|
||||
})
|
||||
|
||||
outcome = node.Run(1, 3, server.URL())
|
||||
})
|
||||
|
||||
It("should run A and, when the server says its time, run B", func() {
|
||||
Ω(thingsThatRan()).Should(Equal([]string{"A", "Request1", "Request2", "Request3", "B"}))
|
||||
})
|
||||
|
||||
It("should report success", func() {
|
||||
Ω(outcome).Should(BeTrue())
|
||||
Ω(node.Passed()).Should(BeTrue())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStatePassed))
|
||||
})
|
||||
})
|
||||
|
||||
Context("as any other node", func() {
|
||||
BeforeEach(func() {
|
||||
node = newNode(func() {
|
||||
ranThing("A")
|
||||
}, func() {
|
||||
ranThing("B")
|
||||
})
|
||||
|
||||
outcome = node.Run(2, 3, server.URL())
|
||||
})
|
||||
|
||||
It("should run A, and not run B", func() {
|
||||
Ω(thingsThatRan()).Should(Equal([]string{"A"}))
|
||||
})
|
||||
|
||||
It("should not talk to the server", func() {
|
||||
Ω(server.ReceivedRequests()).Should(BeEmpty())
|
||||
})
|
||||
|
||||
It("should report success", func() {
|
||||
Ω(outcome).Should(BeTrue())
|
||||
Ω(node.Passed()).Should(BeTrue())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStatePassed))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
7
vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_before_suite_node.go
generated
vendored
7
vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_before_suite_node.go
generated
vendored
|
|
@ -3,12 +3,13 @@ package leafnodes
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"github.com/onsi/ginkgo/internal/failer"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/failer"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
)
|
||||
|
||||
type synchronizedBeforeSuiteNode struct {
|
||||
|
|
@ -109,8 +110,6 @@ func (node *synchronizedBeforeSuiteNode) waitForA(syncHost string) (types.SpecSt
|
|||
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
}
|
||||
|
||||
return types.SpecStateFailed, failure("Shouldn't get here!")
|
||||
}
|
||||
|
||||
func (node *synchronizedBeforeSuiteNode) Passed() bool {
|
||||
|
|
|
|||
445
vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_before_suite_node_test.go
generated
vendored
445
vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_before_suite_node_test.go
generated
vendored
|
|
@ -1,445 +0,0 @@
|
|||
package leafnodes_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/internal/leafnodes"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/onsi/gomega/ghttp"
|
||||
"net/http"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
Failer "github.com/onsi/ginkgo/internal/failer"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
"time"
|
||||
)
|
||||
|
||||
var _ = Describe("SynchronizedBeforeSuiteNode", func() {
|
||||
var failer *Failer.Failer
|
||||
var node SuiteNode
|
||||
var codeLocation types.CodeLocation
|
||||
var innerCodeLocation types.CodeLocation
|
||||
var outcome bool
|
||||
var server *ghttp.Server
|
||||
|
||||
BeforeEach(func() {
|
||||
server = ghttp.NewServer()
|
||||
codeLocation = codelocation.New(0)
|
||||
innerCodeLocation = codelocation.New(0)
|
||||
failer = Failer.New()
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
server.Close()
|
||||
})
|
||||
|
||||
newNode := func(bodyA interface{}, bodyB interface{}) SuiteNode {
|
||||
return NewSynchronizedBeforeSuiteNode(bodyA, bodyB, codeLocation, time.Millisecond, failer)
|
||||
}
|
||||
|
||||
Describe("when not running in parallel", func() {
|
||||
Context("when all is well", func() {
|
||||
var data []byte
|
||||
BeforeEach(func() {
|
||||
data = nil
|
||||
|
||||
node = newNode(func() []byte {
|
||||
return []byte("my data")
|
||||
}, func(d []byte) {
|
||||
data = d
|
||||
})
|
||||
|
||||
outcome = node.Run(1, 1, server.URL())
|
||||
})
|
||||
|
||||
It("should run A, then B passing the output from A to B", func() {
|
||||
Ω(data).Should(Equal([]byte("my data")))
|
||||
})
|
||||
|
||||
It("should report success", func() {
|
||||
Ω(outcome).Should(BeTrue())
|
||||
Ω(node.Passed()).Should(BeTrue())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStatePassed))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when A fails", func() {
|
||||
var ranB bool
|
||||
BeforeEach(func() {
|
||||
ranB = false
|
||||
node = newNode(func() []byte {
|
||||
failer.Fail("boom", innerCodeLocation)
|
||||
return nil
|
||||
}, func([]byte) {
|
||||
ranB = true
|
||||
})
|
||||
|
||||
outcome = node.Run(1, 1, server.URL())
|
||||
})
|
||||
|
||||
It("should not run B", func() {
|
||||
Ω(ranB).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should report failure", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(node.Passed()).Should(BeFalse())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStateFailed))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when B fails", func() {
|
||||
BeforeEach(func() {
|
||||
node = newNode(func() []byte {
|
||||
return nil
|
||||
}, func([]byte) {
|
||||
failer.Fail("boom", innerCodeLocation)
|
||||
})
|
||||
|
||||
outcome = node.Run(1, 1, server.URL())
|
||||
})
|
||||
|
||||
It("should report failure", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(node.Passed()).Should(BeFalse())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStateFailed))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when A times out", func() {
|
||||
var ranB bool
|
||||
BeforeEach(func() {
|
||||
ranB = false
|
||||
node = newNode(func(Done) []byte {
|
||||
time.Sleep(time.Second)
|
||||
return nil
|
||||
}, func([]byte) {
|
||||
ranB = true
|
||||
})
|
||||
|
||||
outcome = node.Run(1, 1, server.URL())
|
||||
})
|
||||
|
||||
It("should not run B", func() {
|
||||
Ω(ranB).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should report failure", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(node.Passed()).Should(BeFalse())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStateTimedOut))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when B times out", func() {
|
||||
BeforeEach(func() {
|
||||
node = newNode(func() []byte {
|
||||
return nil
|
||||
}, func([]byte, Done) {
|
||||
time.Sleep(time.Second)
|
||||
})
|
||||
|
||||
outcome = node.Run(1, 1, server.URL())
|
||||
})
|
||||
|
||||
It("should report failure", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(node.Passed()).Should(BeFalse())
|
||||
Ω(node.Summary().State).Should(Equal(types.SpecStateTimedOut))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("when running in parallel", func() {
|
||||
var ranB bool
|
||||
var parallelNode, parallelTotal int
|
||||
BeforeEach(func() {
|
||||
ranB = false
|
||||
parallelNode, parallelTotal = 1, 3
|
||||
})
|
||||
|
||||
Context("as the first node, it runs A", func() {
|
||||
var expectedState types.RemoteBeforeSuiteData
|
||||
|
||||
BeforeEach(func() {
|
||||
parallelNode, parallelTotal = 1, 3
|
||||
})
|
||||
|
||||
JustBeforeEach(func() {
|
||||
server.AppendHandlers(ghttp.CombineHandlers(
|
||||
ghttp.VerifyRequest("POST", "/BeforeSuiteState"),
|
||||
ghttp.VerifyJSONRepresenting(expectedState),
|
||||
))
|
||||
|
||||
outcome = node.Run(parallelNode, parallelTotal, server.URL())
|
||||
})
|
||||
|
||||
Context("when A succeeds", func() {
|
||||
BeforeEach(func() {
|
||||
expectedState = types.RemoteBeforeSuiteData{[]byte("my data"), types.RemoteBeforeSuiteStatePassed}
|
||||
|
||||
node = newNode(func() []byte {
|
||||
return []byte("my data")
|
||||
}, func([]byte) {
|
||||
ranB = true
|
||||
})
|
||||
})
|
||||
|
||||
It("should post about A succeeding", func() {
|
||||
Ω(server.ReceivedRequests()).Should(HaveLen(1))
|
||||
})
|
||||
|
||||
It("should run B", func() {
|
||||
Ω(ranB).Should(BeTrue())
|
||||
})
|
||||
|
||||
It("should report success", func() {
|
||||
Ω(outcome).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when A fails", func() {
|
||||
BeforeEach(func() {
|
||||
expectedState = types.RemoteBeforeSuiteData{nil, types.RemoteBeforeSuiteStateFailed}
|
||||
|
||||
node = newNode(func() []byte {
|
||||
panic("BAM")
|
||||
return []byte("my data")
|
||||
}, func([]byte) {
|
||||
ranB = true
|
||||
})
|
||||
})
|
||||
|
||||
It("should post about A failing", func() {
|
||||
Ω(server.ReceivedRequests()).Should(HaveLen(1))
|
||||
})
|
||||
|
||||
It("should not run B", func() {
|
||||
Ω(ranB).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should report failure", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("as the Nth node", func() {
|
||||
var statusCode int
|
||||
var response interface{}
|
||||
var ranA bool
|
||||
var bData []byte
|
||||
|
||||
BeforeEach(func() {
|
||||
ranA = false
|
||||
bData = nil
|
||||
|
||||
statusCode = http.StatusOK
|
||||
|
||||
server.AppendHandlers(ghttp.CombineHandlers(
|
||||
ghttp.VerifyRequest("GET", "/BeforeSuiteState"),
|
||||
ghttp.RespondWith(http.StatusOK, string((types.RemoteBeforeSuiteData{nil, types.RemoteBeforeSuiteStatePending}).ToJSON())),
|
||||
), ghttp.CombineHandlers(
|
||||
ghttp.VerifyRequest("GET", "/BeforeSuiteState"),
|
||||
ghttp.RespondWith(http.StatusOK, string((types.RemoteBeforeSuiteData{nil, types.RemoteBeforeSuiteStatePending}).ToJSON())),
|
||||
), ghttp.CombineHandlers(
|
||||
ghttp.VerifyRequest("GET", "/BeforeSuiteState"),
|
||||
ghttp.RespondWithJSONEncodedPtr(&statusCode, &response),
|
||||
))
|
||||
|
||||
node = newNode(func() []byte {
|
||||
ranA = true
|
||||
return nil
|
||||
}, func(data []byte) {
|
||||
bData = data
|
||||
})
|
||||
|
||||
parallelNode, parallelTotal = 2, 3
|
||||
})
|
||||
|
||||
Context("when A on node1 succeeds", func() {
|
||||
BeforeEach(func() {
|
||||
response = types.RemoteBeforeSuiteData{[]byte("my data"), types.RemoteBeforeSuiteStatePassed}
|
||||
outcome = node.Run(parallelNode, parallelTotal, server.URL())
|
||||
})
|
||||
|
||||
It("should not run A", func() {
|
||||
Ω(ranA).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should poll for A", func() {
|
||||
Ω(server.ReceivedRequests()).Should(HaveLen(3))
|
||||
})
|
||||
|
||||
It("should run B when the polling succeeds", func() {
|
||||
Ω(bData).Should(Equal([]byte("my data")))
|
||||
})
|
||||
|
||||
It("should succeed", func() {
|
||||
Ω(outcome).Should(BeTrue())
|
||||
Ω(node.Passed()).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when A on node1 fails", func() {
|
||||
BeforeEach(func() {
|
||||
response = types.RemoteBeforeSuiteData{[]byte("my data"), types.RemoteBeforeSuiteStateFailed}
|
||||
outcome = node.Run(parallelNode, parallelTotal, server.URL())
|
||||
})
|
||||
|
||||
It("should not run A", func() {
|
||||
Ω(ranA).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should poll for A", func() {
|
||||
Ω(server.ReceivedRequests()).Should(HaveLen(3))
|
||||
})
|
||||
|
||||
It("should not run B", func() {
|
||||
Ω(bData).Should(BeNil())
|
||||
})
|
||||
|
||||
It("should fail", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(node.Passed()).Should(BeFalse())
|
||||
|
||||
summary := node.Summary()
|
||||
Ω(summary.State).Should(Equal(types.SpecStateFailed))
|
||||
Ω(summary.Failure.Message).Should(Equal("BeforeSuite on Node 1 failed"))
|
||||
Ω(summary.Failure.Location).Should(Equal(codeLocation))
|
||||
Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite))
|
||||
Ω(summary.Failure.ComponentIndex).Should(Equal(0))
|
||||
Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when node1 disappears", func() {
|
||||
BeforeEach(func() {
|
||||
response = types.RemoteBeforeSuiteData{[]byte("my data"), types.RemoteBeforeSuiteStateDisappeared}
|
||||
outcome = node.Run(parallelNode, parallelTotal, server.URL())
|
||||
})
|
||||
|
||||
It("should not run A", func() {
|
||||
Ω(ranA).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should poll for A", func() {
|
||||
Ω(server.ReceivedRequests()).Should(HaveLen(3))
|
||||
})
|
||||
|
||||
It("should not run B", func() {
|
||||
Ω(bData).Should(BeNil())
|
||||
})
|
||||
|
||||
It("should fail", func() {
|
||||
Ω(outcome).Should(BeFalse())
|
||||
Ω(node.Passed()).Should(BeFalse())
|
||||
|
||||
summary := node.Summary()
|
||||
Ω(summary.State).Should(Equal(types.SpecStateFailed))
|
||||
Ω(summary.Failure.Message).Should(Equal("Node 1 disappeared before completing BeforeSuite"))
|
||||
Ω(summary.Failure.Location).Should(Equal(codeLocation))
|
||||
Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite))
|
||||
Ω(summary.Failure.ComponentIndex).Should(Equal(0))
|
||||
Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("construction", func() {
|
||||
Describe("the first function", func() {
|
||||
Context("when the first function returns a byte array", func() {
|
||||
Context("and takes nothing", func() {
|
||||
It("should be fine", func() {
|
||||
Ω(func() {
|
||||
newNode(func() []byte { return nil }, func([]byte) {})
|
||||
}).ShouldNot(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Context("and takes a done function", func() {
|
||||
It("should be fine", func() {
|
||||
Ω(func() {
|
||||
newNode(func(Done) []byte { return nil }, func([]byte) {})
|
||||
}).ShouldNot(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Context("and takes more than one thing", func() {
|
||||
It("should panic", func() {
|
||||
Ω(func() {
|
||||
newNode(func(Done, Done) []byte { return nil }, func([]byte) {})
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Context("and takes something else", func() {
|
||||
It("should panic", func() {
|
||||
Ω(func() {
|
||||
newNode(func(bool) []byte { return nil }, func([]byte) {})
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the first function does not return a byte array", func() {
|
||||
It("should panic", func() {
|
||||
Ω(func() {
|
||||
newNode(func() {}, func([]byte) {})
|
||||
}).Should(Panic())
|
||||
|
||||
Ω(func() {
|
||||
newNode(func() []int { return nil }, func([]byte) {})
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("the second function", func() {
|
||||
Context("when the second function takes a byte array", func() {
|
||||
It("should be fine", func() {
|
||||
Ω(func() {
|
||||
newNode(func() []byte { return nil }, func([]byte) {})
|
||||
}).ShouldNot(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when it also takes a done channel", func() {
|
||||
It("should be fine", func() {
|
||||
Ω(func() {
|
||||
newNode(func() []byte { return nil }, func([]byte, Done) {})
|
||||
}).ShouldNot(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Context("if it takes anything else", func() {
|
||||
It("should panic", func() {
|
||||
Ω(func() {
|
||||
newNode(func() []byte { return nil }, func([]byte, chan bool) {})
|
||||
}).Should(Panic())
|
||||
|
||||
Ω(func() {
|
||||
newNode(func() []byte { return nil }, func(string) {})
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Context("if it takes nothing at all", func() {
|
||||
It("should panic", func() {
|
||||
Ω(func() {
|
||||
newNode(func() []byte { return nil }, func() {})
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Context("if it returns something", func() {
|
||||
It("should panic", func() {
|
||||
Ω(func() {
|
||||
newNode(func() []byte { return nil }, func([]byte) []byte { return nil })
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
2
vendor/github.com/onsi/ginkgo/internal/remote/aggregator.go
generated
vendored
2
vendor/github.com/onsi/ginkgo/internal/remote/aggregator.go
generated
vendored
|
|
@ -207,7 +207,7 @@ func (aggregator *Aggregator) announceSpec(specSummary *types.SpecSummary) {
|
|||
case types.SpecStatePending:
|
||||
aggregator.stenographer.AnnouncePendingSpec(specSummary, aggregator.config.NoisyPendings && !aggregator.config.Succinct)
|
||||
case types.SpecStateSkipped:
|
||||
aggregator.stenographer.AnnounceSkippedSpec(specSummary, aggregator.config.Succinct, aggregator.config.FullTrace)
|
||||
aggregator.stenographer.AnnounceSkippedSpec(specSummary, aggregator.config.Succinct || !aggregator.config.NoisySkippings, aggregator.config.FullTrace)
|
||||
case types.SpecStateTimedOut:
|
||||
aggregator.stenographer.AnnounceSpecTimedOut(specSummary, aggregator.config.Succinct, aggregator.config.FullTrace)
|
||||
case types.SpecStatePanicked:
|
||||
|
|
|
|||
315
vendor/github.com/onsi/ginkgo/internal/remote/aggregator_test.go
generated
vendored
315
vendor/github.com/onsi/ginkgo/internal/remote/aggregator_test.go
generated
vendored
|
|
@ -1,315 +0,0 @@
|
|||
package remote_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo/config"
|
||||
. "github.com/onsi/ginkgo/internal/remote"
|
||||
st "github.com/onsi/ginkgo/reporters/stenographer"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
)
|
||||
|
||||
var _ = Describe("Aggregator", func() {
|
||||
var (
|
||||
aggregator *Aggregator
|
||||
reporterConfig config.DefaultReporterConfigType
|
||||
stenographer *st.FakeStenographer
|
||||
result chan bool
|
||||
|
||||
ginkgoConfig1 config.GinkgoConfigType
|
||||
ginkgoConfig2 config.GinkgoConfigType
|
||||
|
||||
suiteSummary1 *types.SuiteSummary
|
||||
suiteSummary2 *types.SuiteSummary
|
||||
|
||||
beforeSummary *types.SetupSummary
|
||||
afterSummary *types.SetupSummary
|
||||
specSummary *types.SpecSummary
|
||||
|
||||
suiteDescription string
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
reporterConfig = config.DefaultReporterConfigType{
|
||||
NoColor: false,
|
||||
SlowSpecThreshold: 0.1,
|
||||
NoisyPendings: true,
|
||||
Succinct: false,
|
||||
Verbose: true,
|
||||
}
|
||||
stenographer = st.NewFakeStenographer()
|
||||
result = make(chan bool, 1)
|
||||
aggregator = NewAggregator(2, result, reporterConfig, stenographer)
|
||||
|
||||
//
|
||||
// now set up some fixture data
|
||||
//
|
||||
|
||||
ginkgoConfig1 = config.GinkgoConfigType{
|
||||
RandomSeed: 1138,
|
||||
RandomizeAllSpecs: true,
|
||||
ParallelNode: 1,
|
||||
ParallelTotal: 2,
|
||||
}
|
||||
|
||||
ginkgoConfig2 = config.GinkgoConfigType{
|
||||
RandomSeed: 1138,
|
||||
RandomizeAllSpecs: true,
|
||||
ParallelNode: 2,
|
||||
ParallelTotal: 2,
|
||||
}
|
||||
|
||||
suiteDescription = "My Parallel Suite"
|
||||
|
||||
suiteSummary1 = &types.SuiteSummary{
|
||||
SuiteDescription: suiteDescription,
|
||||
|
||||
NumberOfSpecsBeforeParallelization: 30,
|
||||
NumberOfTotalSpecs: 17,
|
||||
NumberOfSpecsThatWillBeRun: 15,
|
||||
NumberOfPendingSpecs: 1,
|
||||
NumberOfSkippedSpecs: 1,
|
||||
}
|
||||
|
||||
suiteSummary2 = &types.SuiteSummary{
|
||||
SuiteDescription: suiteDescription,
|
||||
|
||||
NumberOfSpecsBeforeParallelization: 30,
|
||||
NumberOfTotalSpecs: 13,
|
||||
NumberOfSpecsThatWillBeRun: 8,
|
||||
NumberOfPendingSpecs: 2,
|
||||
NumberOfSkippedSpecs: 3,
|
||||
}
|
||||
|
||||
beforeSummary = &types.SetupSummary{
|
||||
State: types.SpecStatePassed,
|
||||
CapturedOutput: "BeforeSuiteOutput",
|
||||
}
|
||||
|
||||
afterSummary = &types.SetupSummary{
|
||||
State: types.SpecStatePassed,
|
||||
CapturedOutput: "AfterSuiteOutput",
|
||||
}
|
||||
|
||||
specSummary = &types.SpecSummary{
|
||||
State: types.SpecStatePassed,
|
||||
CapturedOutput: "SpecOutput",
|
||||
}
|
||||
})
|
||||
|
||||
call := func(method string, args ...interface{}) st.FakeStenographerCall {
|
||||
return st.NewFakeStenographerCall(method, args...)
|
||||
}
|
||||
|
||||
beginSuite := func() {
|
||||
stenographer.Reset()
|
||||
aggregator.SpecSuiteWillBegin(ginkgoConfig2, suiteSummary2)
|
||||
aggregator.SpecSuiteWillBegin(ginkgoConfig1, suiteSummary1)
|
||||
Eventually(func() interface{} {
|
||||
return len(stenographer.Calls())
|
||||
}).Should(BeNumerically(">=", 3))
|
||||
}
|
||||
|
||||
Describe("Announcing the beginning of the suite", func() {
|
||||
Context("When one of the parallel-suites starts", func() {
|
||||
BeforeEach(func() {
|
||||
aggregator.SpecSuiteWillBegin(ginkgoConfig2, suiteSummary2)
|
||||
})
|
||||
|
||||
It("should be silent", func() {
|
||||
Consistently(func() interface{} { return stenographer.Calls() }).Should(BeEmpty())
|
||||
})
|
||||
})
|
||||
|
||||
Context("once all of the parallel-suites have started", func() {
|
||||
BeforeEach(func() {
|
||||
aggregator.SpecSuiteWillBegin(ginkgoConfig2, suiteSummary2)
|
||||
aggregator.SpecSuiteWillBegin(ginkgoConfig1, suiteSummary1)
|
||||
Eventually(func() interface{} {
|
||||
return stenographer.Calls()
|
||||
}).Should(HaveLen(3))
|
||||
})
|
||||
|
||||
It("should announce the beginning of the suite", func() {
|
||||
Ω(stenographer.Calls()).Should(HaveLen(3))
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuite", suiteDescription, ginkgoConfig1.RandomSeed, true, false)))
|
||||
Ω(stenographer.Calls()[1]).Should(Equal(call("AnnounceTotalNumberOfSpecs", 30, false)))
|
||||
Ω(stenographer.Calls()[2]).Should(Equal(call("AnnounceAggregatedParallelRun", 2, false)))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Announcing specs and before suites", func() {
|
||||
Context("when the parallel-suites have not all started", func() {
|
||||
BeforeEach(func() {
|
||||
aggregator.BeforeSuiteDidRun(beforeSummary)
|
||||
aggregator.AfterSuiteDidRun(afterSummary)
|
||||
aggregator.SpecDidComplete(specSummary)
|
||||
})
|
||||
|
||||
It("should not announce any specs", func() {
|
||||
Consistently(func() interface{} { return stenographer.Calls() }).Should(BeEmpty())
|
||||
})
|
||||
|
||||
Context("when the parallel-suites subsequently start", func() {
|
||||
BeforeEach(func() {
|
||||
beginSuite()
|
||||
})
|
||||
|
||||
It("should announce the specs, the before suites and the after suites", func() {
|
||||
Eventually(func() interface{} {
|
||||
return stenographer.Calls()
|
||||
}).Should(ContainElement(call("AnnounceSuccesfulSpec", specSummary)))
|
||||
|
||||
Ω(stenographer.Calls()).Should(ContainElement(call("AnnounceCapturedOutput", beforeSummary.CapturedOutput)))
|
||||
Ω(stenographer.Calls()).Should(ContainElement(call("AnnounceCapturedOutput", afterSummary.CapturedOutput)))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("When the parallel-suites have all started", func() {
|
||||
BeforeEach(func() {
|
||||
beginSuite()
|
||||
stenographer.Reset()
|
||||
})
|
||||
|
||||
Context("When a spec completes", func() {
|
||||
BeforeEach(func() {
|
||||
aggregator.BeforeSuiteDidRun(beforeSummary)
|
||||
aggregator.SpecDidComplete(specSummary)
|
||||
aggregator.AfterSuiteDidRun(afterSummary)
|
||||
Eventually(func() interface{} {
|
||||
return stenographer.Calls()
|
||||
}).Should(HaveLen(5))
|
||||
})
|
||||
|
||||
It("should announce the captured output of the BeforeSuite", func() {
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceCapturedOutput", beforeSummary.CapturedOutput)))
|
||||
})
|
||||
|
||||
It("should announce that the spec will run (when in verbose mode)", func() {
|
||||
Ω(stenographer.Calls()[1]).Should(Equal(call("AnnounceSpecWillRun", specSummary)))
|
||||
})
|
||||
|
||||
It("should announce the captured stdout of the spec", func() {
|
||||
Ω(stenographer.Calls()[2]).Should(Equal(call("AnnounceCapturedOutput", specSummary.CapturedOutput)))
|
||||
})
|
||||
|
||||
It("should announce completion", func() {
|
||||
Ω(stenographer.Calls()[3]).Should(Equal(call("AnnounceSuccesfulSpec", specSummary)))
|
||||
})
|
||||
|
||||
It("should announce the captured output of the AfterSuite", func() {
|
||||
Ω(stenographer.Calls()[4]).Should(Equal(call("AnnounceCapturedOutput", afterSummary.CapturedOutput)))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Announcing the end of the suite", func() {
|
||||
BeforeEach(func() {
|
||||
beginSuite()
|
||||
stenographer.Reset()
|
||||
})
|
||||
|
||||
Context("When one of the parallel-suites ends", func() {
|
||||
BeforeEach(func() {
|
||||
aggregator.SpecSuiteDidEnd(suiteSummary2)
|
||||
})
|
||||
|
||||
It("should be silent", func() {
|
||||
Consistently(func() interface{} { return stenographer.Calls() }).Should(BeEmpty())
|
||||
})
|
||||
|
||||
It("should not notify the channel", func() {
|
||||
Ω(result).Should(BeEmpty())
|
||||
})
|
||||
})
|
||||
|
||||
Context("once all of the parallel-suites end", func() {
|
||||
BeforeEach(func() {
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
|
||||
suiteSummary1.SuiteSucceeded = true
|
||||
suiteSummary1.NumberOfPassedSpecs = 15
|
||||
suiteSummary1.NumberOfFailedSpecs = 0
|
||||
suiteSummary1.NumberOfFlakedSpecs = 3
|
||||
suiteSummary2.SuiteSucceeded = false
|
||||
suiteSummary2.NumberOfPassedSpecs = 5
|
||||
suiteSummary2.NumberOfFailedSpecs = 3
|
||||
suiteSummary2.NumberOfFlakedSpecs = 4
|
||||
|
||||
aggregator.SpecSuiteDidEnd(suiteSummary2)
|
||||
aggregator.SpecSuiteDidEnd(suiteSummary1)
|
||||
Eventually(func() interface{} {
|
||||
return stenographer.Calls()
|
||||
}).Should(HaveLen(2))
|
||||
})
|
||||
|
||||
It("should announce the end of the suite", func() {
|
||||
compositeSummary := stenographer.Calls()[1].Args[0].(*types.SuiteSummary)
|
||||
|
||||
Ω(compositeSummary.SuiteSucceeded).Should(BeFalse())
|
||||
Ω(compositeSummary.NumberOfSpecsThatWillBeRun).Should(Equal(23))
|
||||
Ω(compositeSummary.NumberOfTotalSpecs).Should(Equal(30))
|
||||
Ω(compositeSummary.NumberOfPassedSpecs).Should(Equal(20))
|
||||
Ω(compositeSummary.NumberOfFailedSpecs).Should(Equal(3))
|
||||
Ω(compositeSummary.NumberOfPendingSpecs).Should(Equal(3))
|
||||
Ω(compositeSummary.NumberOfSkippedSpecs).Should(Equal(4))
|
||||
Ω(compositeSummary.NumberOfFlakedSpecs).Should(Equal(7))
|
||||
Ω(compositeSummary.RunTime.Seconds()).Should(BeNumerically(">", 0.2))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when all the parallel-suites pass", func() {
|
||||
BeforeEach(func() {
|
||||
suiteSummary1.SuiteSucceeded = true
|
||||
suiteSummary2.SuiteSucceeded = true
|
||||
|
||||
aggregator.SpecSuiteDidEnd(suiteSummary2)
|
||||
aggregator.SpecSuiteDidEnd(suiteSummary1)
|
||||
Eventually(func() interface{} {
|
||||
return stenographer.Calls()
|
||||
}).Should(HaveLen(2))
|
||||
})
|
||||
|
||||
It("should report success", func() {
|
||||
compositeSummary := stenographer.Calls()[1].Args[0].(*types.SuiteSummary)
|
||||
|
||||
Ω(compositeSummary.SuiteSucceeded).Should(BeTrue())
|
||||
})
|
||||
|
||||
It("should notify the channel that it succeded", func(done Done) {
|
||||
Ω(<-result).Should(BeTrue())
|
||||
close(done)
|
||||
})
|
||||
})
|
||||
|
||||
Context("when one of the parallel-suites fails", func() {
|
||||
BeforeEach(func() {
|
||||
suiteSummary1.SuiteSucceeded = true
|
||||
suiteSummary2.SuiteSucceeded = false
|
||||
|
||||
aggregator.SpecSuiteDidEnd(suiteSummary2)
|
||||
aggregator.SpecSuiteDidEnd(suiteSummary1)
|
||||
Eventually(func() interface{} {
|
||||
return stenographer.Calls()
|
||||
}).Should(HaveLen(2))
|
||||
})
|
||||
|
||||
It("should report failure", func() {
|
||||
compositeSummary := stenographer.Calls()[1].Args[0].(*types.SuiteSummary)
|
||||
|
||||
Ω(compositeSummary.SuiteSucceeded).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should notify the channel that it failed", func(done Done) {
|
||||
Ω(<-result).Should(BeFalse())
|
||||
close(done)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
17
vendor/github.com/onsi/ginkgo/internal/remote/fake_output_interceptor_test.go
generated
vendored
17
vendor/github.com/onsi/ginkgo/internal/remote/fake_output_interceptor_test.go
generated
vendored
|
|
@ -1,17 +0,0 @@
|
|||
package remote_test
|
||||
|
||||
type fakeOutputInterceptor struct {
|
||||
DidStartInterceptingOutput bool
|
||||
DidStopInterceptingOutput bool
|
||||
InterceptedOutput string
|
||||
}
|
||||
|
||||
func (interceptor *fakeOutputInterceptor) StartInterceptingOutput() error {
|
||||
interceptor.DidStartInterceptingOutput = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (interceptor *fakeOutputInterceptor) StopInterceptingAndReturnOutput() (string, error) {
|
||||
interceptor.DidStopInterceptingOutput = true
|
||||
return interceptor.InterceptedOutput, nil
|
||||
}
|
||||
33
vendor/github.com/onsi/ginkgo/internal/remote/fake_poster_test.go
generated
vendored
33
vendor/github.com/onsi/ginkgo/internal/remote/fake_poster_test.go
generated
vendored
|
|
@ -1,33 +0,0 @@
|
|||
package remote_test
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type post struct {
|
||||
url string
|
||||
bodyType string
|
||||
bodyContent []byte
|
||||
}
|
||||
|
||||
type fakePoster struct {
|
||||
posts []post
|
||||
}
|
||||
|
||||
func newFakePoster() *fakePoster {
|
||||
return &fakePoster{
|
||||
posts: make([]post, 0),
|
||||
}
|
||||
}
|
||||
|
||||
func (poster *fakePoster) Post(url string, bodyType string, body io.Reader) (resp *http.Response, err error) {
|
||||
bodyContent, _ := ioutil.ReadAll(body)
|
||||
poster.posts = append(poster.posts, post{
|
||||
url: url,
|
||||
bodyType: bodyType,
|
||||
bodyContent: bodyContent,
|
||||
})
|
||||
return nil, nil
|
||||
}
|
||||
180
vendor/github.com/onsi/ginkgo/internal/remote/forwarding_reporter_test.go
generated
vendored
180
vendor/github.com/onsi/ginkgo/internal/remote/forwarding_reporter_test.go
generated
vendored
|
|
@ -1,180 +0,0 @@
|
|||
package remote_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
. "github.com/onsi/ginkgo"
|
||||
"github.com/onsi/ginkgo/config"
|
||||
. "github.com/onsi/ginkgo/internal/remote"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("ForwardingReporter", func() {
|
||||
var (
|
||||
reporter *ForwardingReporter
|
||||
interceptor *fakeOutputInterceptor
|
||||
poster *fakePoster
|
||||
suiteSummary *types.SuiteSummary
|
||||
specSummary *types.SpecSummary
|
||||
setupSummary *types.SetupSummary
|
||||
serverHost string
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
serverHost = "http://127.0.0.1:7788"
|
||||
|
||||
poster = newFakePoster()
|
||||
|
||||
interceptor = &fakeOutputInterceptor{
|
||||
InterceptedOutput: "The intercepted output!",
|
||||
}
|
||||
|
||||
reporter = NewForwardingReporter(serverHost, poster, interceptor)
|
||||
|
||||
suiteSummary = &types.SuiteSummary{
|
||||
SuiteDescription: "My Test Suite",
|
||||
}
|
||||
|
||||
setupSummary = &types.SetupSummary{
|
||||
State: types.SpecStatePassed,
|
||||
}
|
||||
|
||||
specSummary = &types.SpecSummary{
|
||||
ComponentTexts: []string{"My", "Spec"},
|
||||
State: types.SpecStatePassed,
|
||||
}
|
||||
})
|
||||
|
||||
Context("When a suite begins", func() {
|
||||
BeforeEach(func() {
|
||||
reporter.SpecSuiteWillBegin(config.GinkgoConfig, suiteSummary)
|
||||
})
|
||||
|
||||
It("should start intercepting output", func() {
|
||||
Ω(interceptor.DidStartInterceptingOutput).Should(BeTrue())
|
||||
})
|
||||
|
||||
It("should POST the SuiteSummary and Ginkgo Config to the Ginkgo server", func() {
|
||||
Ω(poster.posts).Should(HaveLen(1))
|
||||
Ω(poster.posts[0].url).Should(Equal("http://127.0.0.1:7788/SpecSuiteWillBegin"))
|
||||
Ω(poster.posts[0].bodyType).Should(Equal("application/json"))
|
||||
|
||||
var sentData struct {
|
||||
SentConfig config.GinkgoConfigType `json:"config"`
|
||||
SentSuiteSummary *types.SuiteSummary `json:"suite-summary"`
|
||||
}
|
||||
|
||||
err := json.Unmarshal(poster.posts[0].bodyContent, &sentData)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
|
||||
Ω(sentData.SentConfig).Should(Equal(config.GinkgoConfig))
|
||||
Ω(sentData.SentSuiteSummary).Should(Equal(suiteSummary))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a BeforeSuite completes", func() {
|
||||
BeforeEach(func() {
|
||||
reporter.BeforeSuiteDidRun(setupSummary)
|
||||
})
|
||||
|
||||
It("should stop, then start intercepting output", func() {
|
||||
Ω(interceptor.DidStopInterceptingOutput).Should(BeTrue())
|
||||
Ω(interceptor.DidStartInterceptingOutput).Should(BeTrue())
|
||||
})
|
||||
|
||||
It("should POST the SetupSummary to the Ginkgo server", func() {
|
||||
Ω(poster.posts).Should(HaveLen(1))
|
||||
Ω(poster.posts[0].url).Should(Equal("http://127.0.0.1:7788/BeforeSuiteDidRun"))
|
||||
Ω(poster.posts[0].bodyType).Should(Equal("application/json"))
|
||||
|
||||
var summary *types.SetupSummary
|
||||
err := json.Unmarshal(poster.posts[0].bodyContent, &summary)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
setupSummary.CapturedOutput = interceptor.InterceptedOutput
|
||||
Ω(summary).Should(Equal(setupSummary))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when an AfterSuite completes", func() {
|
||||
BeforeEach(func() {
|
||||
reporter.AfterSuiteDidRun(setupSummary)
|
||||
})
|
||||
|
||||
It("should stop, then start intercepting output", func() {
|
||||
Ω(interceptor.DidStopInterceptingOutput).Should(BeTrue())
|
||||
Ω(interceptor.DidStartInterceptingOutput).Should(BeTrue())
|
||||
})
|
||||
|
||||
It("should POST the SetupSummary to the Ginkgo server", func() {
|
||||
Ω(poster.posts).Should(HaveLen(1))
|
||||
Ω(poster.posts[0].url).Should(Equal("http://127.0.0.1:7788/AfterSuiteDidRun"))
|
||||
Ω(poster.posts[0].bodyType).Should(Equal("application/json"))
|
||||
|
||||
var summary *types.SetupSummary
|
||||
err := json.Unmarshal(poster.posts[0].bodyContent, &summary)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
setupSummary.CapturedOutput = interceptor.InterceptedOutput
|
||||
Ω(summary).Should(Equal(setupSummary))
|
||||
})
|
||||
})
|
||||
|
||||
Context("When a spec will run", func() {
|
||||
BeforeEach(func() {
|
||||
reporter.SpecWillRun(specSummary)
|
||||
})
|
||||
|
||||
It("should POST the SpecSummary to the Ginkgo server", func() {
|
||||
Ω(poster.posts).Should(HaveLen(1))
|
||||
Ω(poster.posts[0].url).Should(Equal("http://127.0.0.1:7788/SpecWillRun"))
|
||||
Ω(poster.posts[0].bodyType).Should(Equal("application/json"))
|
||||
|
||||
var summary *types.SpecSummary
|
||||
err := json.Unmarshal(poster.posts[0].bodyContent, &summary)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(summary).Should(Equal(specSummary))
|
||||
})
|
||||
|
||||
Context("When a spec completes", func() {
|
||||
BeforeEach(func() {
|
||||
specSummary.State = types.SpecStatePanicked
|
||||
reporter.SpecDidComplete(specSummary)
|
||||
})
|
||||
|
||||
It("should POST the SpecSummary to the Ginkgo server and include any intercepted output", func() {
|
||||
Ω(poster.posts).Should(HaveLen(2))
|
||||
Ω(poster.posts[1].url).Should(Equal("http://127.0.0.1:7788/SpecDidComplete"))
|
||||
Ω(poster.posts[1].bodyType).Should(Equal("application/json"))
|
||||
|
||||
var summary *types.SpecSummary
|
||||
err := json.Unmarshal(poster.posts[1].bodyContent, &summary)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
specSummary.CapturedOutput = interceptor.InterceptedOutput
|
||||
Ω(summary).Should(Equal(specSummary))
|
||||
})
|
||||
|
||||
It("should stop, then start intercepting output", func() {
|
||||
Ω(interceptor.DidStopInterceptingOutput).Should(BeTrue())
|
||||
Ω(interceptor.DidStartInterceptingOutput).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("When a suite ends", func() {
|
||||
BeforeEach(func() {
|
||||
reporter.SpecSuiteDidEnd(suiteSummary)
|
||||
})
|
||||
|
||||
It("should POST the SuiteSummary to the Ginkgo server", func() {
|
||||
Ω(poster.posts).Should(HaveLen(1))
|
||||
Ω(poster.posts[0].url).Should(Equal("http://127.0.0.1:7788/SpecSuiteDidEnd"))
|
||||
Ω(poster.posts[0].bodyType).Should(Equal("application/json"))
|
||||
|
||||
var summary *types.SuiteSummary
|
||||
|
||||
err := json.Unmarshal(poster.posts[0].bodyContent, &summary)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
|
||||
Ω(summary).Should(Equal(suiteSummary))
|
||||
})
|
||||
})
|
||||
})
|
||||
13
vendor/github.com/onsi/ginkgo/internal/remote/remote_suite_test.go
generated
vendored
13
vendor/github.com/onsi/ginkgo/internal/remote/remote_suite_test.go
generated
vendored
|
|
@ -1,13 +0,0 @@
|
|||
package remote_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRemote(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Remote Spec Forwarding Suite")
|
||||
}
|
||||
2
vendor/github.com/onsi/ginkgo/internal/remote/server.go
generated
vendored
2
vendor/github.com/onsi/ginkgo/internal/remote/server.go
generated
vendored
|
|
@ -45,7 +45,7 @@ func NewServer(parallelTotal int) (*Server, error) {
|
|||
listener: listener,
|
||||
lock: &sync.Mutex{},
|
||||
alives: make([]func() bool, parallelTotal),
|
||||
beforeSuiteData: types.RemoteBeforeSuiteData{nil, types.RemoteBeforeSuiteStatePending},
|
||||
beforeSuiteData: types.RemoteBeforeSuiteData{Data: nil, State: types.RemoteBeforeSuiteStatePending},
|
||||
parallelTotal: parallelTotal,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
269
vendor/github.com/onsi/ginkgo/internal/remote/server_test.go
generated
vendored
269
vendor/github.com/onsi/ginkgo/internal/remote/server_test.go
generated
vendored
|
|
@ -1,269 +0,0 @@
|
|||
package remote_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/internal/remote"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/onsi/ginkgo/config"
|
||||
"github.com/onsi/ginkgo/reporters"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var _ = Describe("Server", func() {
|
||||
var (
|
||||
server *Server
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
var err error
|
||||
server, err = NewServer(3)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
|
||||
server.Start()
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
server.Close()
|
||||
})
|
||||
|
||||
Describe("Streaming endpoints", func() {
|
||||
var (
|
||||
reporterA, reporterB *reporters.FakeReporter
|
||||
forwardingReporter *ForwardingReporter
|
||||
|
||||
suiteSummary *types.SuiteSummary
|
||||
setupSummary *types.SetupSummary
|
||||
specSummary *types.SpecSummary
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
reporterA = reporters.NewFakeReporter()
|
||||
reporterB = reporters.NewFakeReporter()
|
||||
|
||||
server.RegisterReporters(reporterA, reporterB)
|
||||
|
||||
forwardingReporter = NewForwardingReporter(server.Address(), &http.Client{}, &fakeOutputInterceptor{})
|
||||
|
||||
suiteSummary = &types.SuiteSummary{
|
||||
SuiteDescription: "My Test Suite",
|
||||
}
|
||||
|
||||
setupSummary = &types.SetupSummary{
|
||||
State: types.SpecStatePassed,
|
||||
}
|
||||
|
||||
specSummary = &types.SpecSummary{
|
||||
ComponentTexts: []string{"My", "Spec"},
|
||||
State: types.SpecStatePassed,
|
||||
}
|
||||
})
|
||||
|
||||
It("should make its address available", func() {
|
||||
Ω(server.Address()).Should(MatchRegexp(`http://127.0.0.1:\d{2,}`))
|
||||
})
|
||||
|
||||
Describe("/SpecSuiteWillBegin", func() {
|
||||
It("should decode and forward the Ginkgo config and suite summary", func(done Done) {
|
||||
forwardingReporter.SpecSuiteWillBegin(config.GinkgoConfig, suiteSummary)
|
||||
Ω(reporterA.Config).Should(Equal(config.GinkgoConfig))
|
||||
Ω(reporterB.Config).Should(Equal(config.GinkgoConfig))
|
||||
Ω(reporterA.BeginSummary).Should(Equal(suiteSummary))
|
||||
Ω(reporterB.BeginSummary).Should(Equal(suiteSummary))
|
||||
close(done)
|
||||
})
|
||||
})
|
||||
|
||||
Describe("/BeforeSuiteDidRun", func() {
|
||||
It("should decode and forward the setup summary", func() {
|
||||
forwardingReporter.BeforeSuiteDidRun(setupSummary)
|
||||
Ω(reporterA.BeforeSuiteSummary).Should(Equal(setupSummary))
|
||||
Ω(reporterB.BeforeSuiteSummary).Should(Equal(setupSummary))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("/AfterSuiteDidRun", func() {
|
||||
It("should decode and forward the setup summary", func() {
|
||||
forwardingReporter.AfterSuiteDidRun(setupSummary)
|
||||
Ω(reporterA.AfterSuiteSummary).Should(Equal(setupSummary))
|
||||
Ω(reporterB.AfterSuiteSummary).Should(Equal(setupSummary))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("/SpecWillRun", func() {
|
||||
It("should decode and forward the spec summary", func(done Done) {
|
||||
forwardingReporter.SpecWillRun(specSummary)
|
||||
Ω(reporterA.SpecWillRunSummaries[0]).Should(Equal(specSummary))
|
||||
Ω(reporterB.SpecWillRunSummaries[0]).Should(Equal(specSummary))
|
||||
close(done)
|
||||
})
|
||||
})
|
||||
|
||||
Describe("/SpecDidComplete", func() {
|
||||
It("should decode and forward the spec summary", func(done Done) {
|
||||
forwardingReporter.SpecDidComplete(specSummary)
|
||||
Ω(reporterA.SpecSummaries[0]).Should(Equal(specSummary))
|
||||
Ω(reporterB.SpecSummaries[0]).Should(Equal(specSummary))
|
||||
close(done)
|
||||
})
|
||||
})
|
||||
|
||||
Describe("/SpecSuiteDidEnd", func() {
|
||||
It("should decode and forward the suite summary", func(done Done) {
|
||||
forwardingReporter.SpecSuiteDidEnd(suiteSummary)
|
||||
Ω(reporterA.EndSummary).Should(Equal(suiteSummary))
|
||||
Ω(reporterB.EndSummary).Should(Equal(suiteSummary))
|
||||
close(done)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Synchronization endpoints", func() {
|
||||
Describe("GETting and POSTing BeforeSuiteState", func() {
|
||||
getBeforeSuite := func() types.RemoteBeforeSuiteData {
|
||||
resp, err := http.Get(server.Address() + "/BeforeSuiteState")
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(resp.StatusCode).Should(Equal(http.StatusOK))
|
||||
|
||||
r := types.RemoteBeforeSuiteData{}
|
||||
decoder := json.NewDecoder(resp.Body)
|
||||
err = decoder.Decode(&r)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
postBeforeSuite := func(r types.RemoteBeforeSuiteData) {
|
||||
resp, err := http.Post(server.Address()+"/BeforeSuiteState", "application/json", bytes.NewReader(r.ToJSON()))
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(resp.StatusCode).Should(Equal(http.StatusOK))
|
||||
}
|
||||
|
||||
Context("when the first node's Alive has not been registered yet", func() {
|
||||
It("should return pending", func() {
|
||||
state := getBeforeSuite()
|
||||
Ω(state).Should(Equal(types.RemoteBeforeSuiteData{nil, types.RemoteBeforeSuiteStatePending}))
|
||||
|
||||
state = getBeforeSuite()
|
||||
Ω(state).Should(Equal(types.RemoteBeforeSuiteData{nil, types.RemoteBeforeSuiteStatePending}))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the first node is Alive but has not responded yet", func() {
|
||||
BeforeEach(func() {
|
||||
server.RegisterAlive(1, func() bool {
|
||||
return true
|
||||
})
|
||||
})
|
||||
|
||||
It("should return pending", func() {
|
||||
state := getBeforeSuite()
|
||||
Ω(state).Should(Equal(types.RemoteBeforeSuiteData{nil, types.RemoteBeforeSuiteStatePending}))
|
||||
|
||||
state = getBeforeSuite()
|
||||
Ω(state).Should(Equal(types.RemoteBeforeSuiteData{nil, types.RemoteBeforeSuiteStatePending}))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the first node has responded", func() {
|
||||
var state types.RemoteBeforeSuiteData
|
||||
BeforeEach(func() {
|
||||
server.RegisterAlive(1, func() bool {
|
||||
return false
|
||||
})
|
||||
|
||||
state = types.RemoteBeforeSuiteData{
|
||||
Data: []byte("my data"),
|
||||
State: types.RemoteBeforeSuiteStatePassed,
|
||||
}
|
||||
postBeforeSuite(state)
|
||||
})
|
||||
|
||||
It("should return the passed in state", func() {
|
||||
returnedState := getBeforeSuite()
|
||||
Ω(returnedState).Should(Equal(state))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the first node is no longer Alive and has not responded yet", func() {
|
||||
BeforeEach(func() {
|
||||
server.RegisterAlive(1, func() bool {
|
||||
return false
|
||||
})
|
||||
})
|
||||
|
||||
It("should return disappeared", func() {
|
||||
state := getBeforeSuite()
|
||||
Ω(state).Should(Equal(types.RemoteBeforeSuiteData{nil, types.RemoteBeforeSuiteStateDisappeared}))
|
||||
|
||||
state = getBeforeSuite()
|
||||
Ω(state).Should(Equal(types.RemoteBeforeSuiteData{nil, types.RemoteBeforeSuiteStateDisappeared}))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("GETting RemoteAfterSuiteData", func() {
|
||||
getRemoteAfterSuiteData := func() bool {
|
||||
resp, err := http.Get(server.Address() + "/RemoteAfterSuiteData")
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
Ω(resp.StatusCode).Should(Equal(http.StatusOK))
|
||||
|
||||
a := types.RemoteAfterSuiteData{}
|
||||
decoder := json.NewDecoder(resp.Body)
|
||||
err = decoder.Decode(&a)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
|
||||
return a.CanRun
|
||||
}
|
||||
|
||||
Context("when there are unregistered nodes", func() {
|
||||
BeforeEach(func() {
|
||||
server.RegisterAlive(2, func() bool {
|
||||
return false
|
||||
})
|
||||
})
|
||||
|
||||
It("should return false", func() {
|
||||
Ω(getRemoteAfterSuiteData()).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when all none-node-1 nodes are still running", func() {
|
||||
BeforeEach(func() {
|
||||
server.RegisterAlive(2, func() bool {
|
||||
return true
|
||||
})
|
||||
|
||||
server.RegisterAlive(3, func() bool {
|
||||
return false
|
||||
})
|
||||
})
|
||||
|
||||
It("should return false", func() {
|
||||
Ω(getRemoteAfterSuiteData()).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when all none-1 nodes are done", func() {
|
||||
BeforeEach(func() {
|
||||
server.RegisterAlive(2, func() bool {
|
||||
return false
|
||||
})
|
||||
|
||||
server.RegisterAlive(3, func() bool {
|
||||
return false
|
||||
})
|
||||
})
|
||||
|
||||
It("should return true", func() {
|
||||
Ω(getRemoteAfterSuiteData()).Should(BeTrue())
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
2
vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_linux_arm64.go
generated
vendored
2
vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_linux_arm64.go
generated
vendored
|
|
@ -8,4 +8,4 @@ import "syscall"
|
|||
// use the nearly identical syscall.Dup3 instead
|
||||
func syscallDup(oldfd int, newfd int) (err error) {
|
||||
return syscall.Dup3(oldfd, newfd, 0)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_solaris.go
generated
vendored
2
vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_solaris.go
generated
vendored
|
|
@ -6,4 +6,4 @@ import "golang.org/x/sys/unix"
|
|||
|
||||
func syscallDup(oldfd int, newfd int) (err error) {
|
||||
return unix.Dup2(oldfd, newfd)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_unix.go
generated
vendored
2
vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_unix.go
generated
vendored
|
|
@ -8,4 +8,4 @@ import "syscall"
|
|||
|
||||
func syscallDup(oldfd int, newfd int) (err error) {
|
||||
return syscall.Dup2(oldfd, newfd)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
71
vendor/github.com/onsi/ginkgo/internal/spec/spec.go
generated
vendored
71
vendor/github.com/onsi/ginkgo/internal/spec/spec.go
generated
vendored
|
|
@ -5,6 +5,8 @@ import (
|
|||
"io"
|
||||
"time"
|
||||
|
||||
"sync"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/containernode"
|
||||
"github.com/onsi/ginkgo/internal/leafnodes"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
|
|
@ -19,8 +21,11 @@ type Spec struct {
|
|||
|
||||
state types.SpecState
|
||||
runTime time.Duration
|
||||
startTime time.Time
|
||||
failure types.SpecFailure
|
||||
previousFailures bool
|
||||
|
||||
stateMutex *sync.Mutex
|
||||
}
|
||||
|
||||
func New(subject leafnodes.SubjectNode, containers []*containernode.ContainerNode, announceProgress bool) *Spec {
|
||||
|
|
@ -29,6 +34,7 @@ func New(subject leafnodes.SubjectNode, containers []*containernode.ContainerNod
|
|||
containers: containers,
|
||||
focused: subject.Flag() == types.FlagTypeFocused,
|
||||
announceProgress: announceProgress,
|
||||
stateMutex: &sync.Mutex{},
|
||||
}
|
||||
|
||||
spec.processFlag(subject.Flag())
|
||||
|
|
@ -43,32 +49,32 @@ func (spec *Spec) processFlag(flag types.FlagType) {
|
|||
if flag == types.FlagTypeFocused {
|
||||
spec.focused = true
|
||||
} else if flag == types.FlagTypePending {
|
||||
spec.state = types.SpecStatePending
|
||||
spec.setState(types.SpecStatePending)
|
||||
}
|
||||
}
|
||||
|
||||
func (spec *Spec) Skip() {
|
||||
spec.state = types.SpecStateSkipped
|
||||
spec.setState(types.SpecStateSkipped)
|
||||
}
|
||||
|
||||
func (spec *Spec) Failed() bool {
|
||||
return spec.state == types.SpecStateFailed || spec.state == types.SpecStatePanicked || spec.state == types.SpecStateTimedOut
|
||||
return spec.getState() == types.SpecStateFailed || spec.getState() == types.SpecStatePanicked || spec.getState() == types.SpecStateTimedOut
|
||||
}
|
||||
|
||||
func (spec *Spec) Passed() bool {
|
||||
return spec.state == types.SpecStatePassed
|
||||
return spec.getState() == types.SpecStatePassed
|
||||
}
|
||||
|
||||
func (spec *Spec) Flaked() bool {
|
||||
return spec.state == types.SpecStatePassed && spec.previousFailures
|
||||
return spec.getState() == types.SpecStatePassed && spec.previousFailures
|
||||
}
|
||||
|
||||
func (spec *Spec) Pending() bool {
|
||||
return spec.state == types.SpecStatePending
|
||||
return spec.getState() == types.SpecStatePending
|
||||
}
|
||||
|
||||
func (spec *Spec) Skipped() bool {
|
||||
return spec.state == types.SpecStateSkipped
|
||||
return spec.getState() == types.SpecStateSkipped
|
||||
}
|
||||
|
||||
func (spec *Spec) Focused() bool {
|
||||
|
|
@ -91,13 +97,18 @@ func (spec *Spec) Summary(suiteID string) *types.SpecSummary {
|
|||
componentTexts[len(spec.containers)] = spec.subject.Text()
|
||||
componentCodeLocations[len(spec.containers)] = spec.subject.CodeLocation()
|
||||
|
||||
runTime := spec.runTime
|
||||
if runTime == 0 && !spec.startTime.IsZero() {
|
||||
runTime = time.Since(spec.startTime)
|
||||
}
|
||||
|
||||
return &types.SpecSummary{
|
||||
IsMeasurement: spec.IsMeasurement(),
|
||||
NumberOfSamples: spec.subject.Samples(),
|
||||
ComponentTexts: componentTexts,
|
||||
ComponentCodeLocations: componentCodeLocations,
|
||||
State: spec.state,
|
||||
RunTime: spec.runTime,
|
||||
State: spec.getState(),
|
||||
RunTime: runTime,
|
||||
Failure: spec.failure,
|
||||
Measurements: spec.measurementsReport(),
|
||||
SuiteID: suiteID,
|
||||
|
|
@ -114,26 +125,38 @@ func (spec *Spec) ConcatenatedString() string {
|
|||
}
|
||||
|
||||
func (spec *Spec) Run(writer io.Writer) {
|
||||
if spec.state == types.SpecStateFailed {
|
||||
if spec.getState() == types.SpecStateFailed {
|
||||
spec.previousFailures = true
|
||||
}
|
||||
|
||||
startTime := time.Now()
|
||||
spec.startTime = time.Now()
|
||||
defer func() {
|
||||
spec.runTime = time.Since(startTime)
|
||||
spec.runTime = time.Since(spec.startTime)
|
||||
}()
|
||||
|
||||
for sample := 0; sample < spec.subject.Samples(); sample++ {
|
||||
spec.runSample(sample, writer)
|
||||
|
||||
if spec.state != types.SpecStatePassed {
|
||||
if spec.getState() != types.SpecStatePassed {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (spec *Spec) getState() types.SpecState {
|
||||
spec.stateMutex.Lock()
|
||||
defer spec.stateMutex.Unlock()
|
||||
return spec.state
|
||||
}
|
||||
|
||||
func (spec *Spec) setState(state types.SpecState) {
|
||||
spec.stateMutex.Lock()
|
||||
defer spec.stateMutex.Unlock()
|
||||
spec.state = state
|
||||
}
|
||||
|
||||
func (spec *Spec) runSample(sample int, writer io.Writer) {
|
||||
spec.state = types.SpecStatePassed
|
||||
spec.setState(types.SpecStatePassed)
|
||||
spec.failure = types.SpecFailure{}
|
||||
innerMostContainerIndexToUnwind := -1
|
||||
|
||||
|
|
@ -143,8 +166,8 @@ func (spec *Spec) runSample(sample int, writer io.Writer) {
|
|||
for _, afterEach := range container.SetupNodesOfType(types.SpecComponentTypeAfterEach) {
|
||||
spec.announceSetupNode(writer, "AfterEach", container, afterEach)
|
||||
afterEachState, afterEachFailure := afterEach.Run()
|
||||
if afterEachState != types.SpecStatePassed && spec.state == types.SpecStatePassed {
|
||||
spec.state = afterEachState
|
||||
if afterEachState != types.SpecStatePassed && spec.getState() == types.SpecStatePassed {
|
||||
spec.setState(afterEachState)
|
||||
spec.failure = afterEachFailure
|
||||
}
|
||||
}
|
||||
|
|
@ -155,8 +178,10 @@ func (spec *Spec) runSample(sample int, writer io.Writer) {
|
|||
innerMostContainerIndexToUnwind = i
|
||||
for _, beforeEach := range container.SetupNodesOfType(types.SpecComponentTypeBeforeEach) {
|
||||
spec.announceSetupNode(writer, "BeforeEach", container, beforeEach)
|
||||
spec.state, spec.failure = beforeEach.Run()
|
||||
if spec.state != types.SpecStatePassed {
|
||||
s, f := beforeEach.Run()
|
||||
spec.failure = f
|
||||
spec.setState(s)
|
||||
if spec.getState() != types.SpecStatePassed {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
@ -165,15 +190,19 @@ func (spec *Spec) runSample(sample int, writer io.Writer) {
|
|||
for _, container := range spec.containers {
|
||||
for _, justBeforeEach := range container.SetupNodesOfType(types.SpecComponentTypeJustBeforeEach) {
|
||||
spec.announceSetupNode(writer, "JustBeforeEach", container, justBeforeEach)
|
||||
spec.state, spec.failure = justBeforeEach.Run()
|
||||
if spec.state != types.SpecStatePassed {
|
||||
s, f := justBeforeEach.Run()
|
||||
spec.failure = f
|
||||
spec.setState(s)
|
||||
if spec.getState() != types.SpecStatePassed {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
spec.announceSubject(writer, spec.subject)
|
||||
spec.state, spec.failure = spec.subject.Run()
|
||||
s, f := spec.subject.Run()
|
||||
spec.failure = f
|
||||
spec.setState(s)
|
||||
}
|
||||
|
||||
func (spec *Spec) announceSetupNode(writer io.Writer, nodeType string, container *containernode.ContainerNode, setupNode leafnodes.BasicNode) {
|
||||
|
|
|
|||
13
vendor/github.com/onsi/ginkgo/internal/spec/spec_suite_test.go
generated
vendored
13
vendor/github.com/onsi/ginkgo/internal/spec/spec_suite_test.go
generated
vendored
|
|
@ -1,13 +0,0 @@
|
|||
package spec_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSpec(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Spec Suite")
|
||||
}
|
||||
657
vendor/github.com/onsi/ginkgo/internal/spec/spec_test.go
generated
vendored
657
vendor/github.com/onsi/ginkgo/internal/spec/spec_test.go
generated
vendored
|
|
@ -1,657 +0,0 @@
|
|||
package spec_test
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/onsi/gomega/gbytes"
|
||||
|
||||
. "github.com/onsi/ginkgo/internal/spec"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
"github.com/onsi/ginkgo/internal/containernode"
|
||||
Failer "github.com/onsi/ginkgo/internal/failer"
|
||||
"github.com/onsi/ginkgo/internal/leafnodes"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
)
|
||||
|
||||
var noneFlag = types.FlagTypeNone
|
||||
var focusedFlag = types.FlagTypeFocused
|
||||
var pendingFlag = types.FlagTypePending
|
||||
|
||||
var _ = Describe("Spec", func() {
|
||||
var (
|
||||
failer *Failer.Failer
|
||||
codeLocation types.CodeLocation
|
||||
nodesThatRan []string
|
||||
spec *Spec
|
||||
buffer *gbytes.Buffer
|
||||
)
|
||||
|
||||
newBody := func(text string, fail bool) func() {
|
||||
return func() {
|
||||
nodesThatRan = append(nodesThatRan, text)
|
||||
if fail {
|
||||
failer.Fail(text, codeLocation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newIt := func(text string, flag types.FlagType, fail bool) *leafnodes.ItNode {
|
||||
return leafnodes.NewItNode(text, newBody(text, fail), flag, codeLocation, 0, failer, 0)
|
||||
}
|
||||
|
||||
newItWithBody := func(text string, body interface{}) *leafnodes.ItNode {
|
||||
return leafnodes.NewItNode(text, body, noneFlag, codeLocation, 0, failer, 0)
|
||||
}
|
||||
|
||||
newMeasure := func(text string, flag types.FlagType, fail bool, samples int) *leafnodes.MeasureNode {
|
||||
return leafnodes.NewMeasureNode(text, func(Benchmarker) {
|
||||
nodesThatRan = append(nodesThatRan, text)
|
||||
if fail {
|
||||
failer.Fail(text, codeLocation)
|
||||
}
|
||||
}, flag, codeLocation, samples, failer, 0)
|
||||
}
|
||||
|
||||
newBef := func(text string, fail bool) leafnodes.BasicNode {
|
||||
return leafnodes.NewBeforeEachNode(newBody(text, fail), codeLocation, 0, failer, 0)
|
||||
}
|
||||
|
||||
newAft := func(text string, fail bool) leafnodes.BasicNode {
|
||||
return leafnodes.NewAfterEachNode(newBody(text, fail), codeLocation, 0, failer, 0)
|
||||
}
|
||||
|
||||
newJusBef := func(text string, fail bool) leafnodes.BasicNode {
|
||||
return leafnodes.NewJustBeforeEachNode(newBody(text, fail), codeLocation, 0, failer, 0)
|
||||
}
|
||||
|
||||
newContainer := func(text string, flag types.FlagType, setupNodes ...leafnodes.BasicNode) *containernode.ContainerNode {
|
||||
c := containernode.New(text, flag, codeLocation)
|
||||
for _, node := range setupNodes {
|
||||
c.PushSetupNode(node)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
containers := func(containers ...*containernode.ContainerNode) []*containernode.ContainerNode {
|
||||
return containers
|
||||
}
|
||||
|
||||
BeforeEach(func() {
|
||||
buffer = gbytes.NewBuffer()
|
||||
failer = Failer.New()
|
||||
codeLocation = codelocation.New(0)
|
||||
nodesThatRan = []string{}
|
||||
})
|
||||
|
||||
Describe("marking specs focused and pending", func() {
|
||||
It("should satisfy various caes", func() {
|
||||
cases := []struct {
|
||||
ContainerFlags []types.FlagType
|
||||
SubjectFlag types.FlagType
|
||||
Pending bool
|
||||
Focused bool
|
||||
}{
|
||||
{[]types.FlagType{}, noneFlag, false, false},
|
||||
{[]types.FlagType{}, focusedFlag, false, true},
|
||||
{[]types.FlagType{}, pendingFlag, true, false},
|
||||
{[]types.FlagType{noneFlag}, noneFlag, false, false},
|
||||
{[]types.FlagType{focusedFlag}, noneFlag, false, true},
|
||||
{[]types.FlagType{pendingFlag}, noneFlag, true, false},
|
||||
{[]types.FlagType{noneFlag}, focusedFlag, false, true},
|
||||
{[]types.FlagType{focusedFlag}, focusedFlag, false, true},
|
||||
{[]types.FlagType{pendingFlag}, focusedFlag, true, true},
|
||||
{[]types.FlagType{noneFlag}, pendingFlag, true, false},
|
||||
{[]types.FlagType{focusedFlag}, pendingFlag, true, true},
|
||||
{[]types.FlagType{pendingFlag}, pendingFlag, true, false},
|
||||
{[]types.FlagType{focusedFlag, noneFlag}, noneFlag, false, true},
|
||||
{[]types.FlagType{noneFlag, focusedFlag}, noneFlag, false, true},
|
||||
{[]types.FlagType{pendingFlag, noneFlag}, noneFlag, true, false},
|
||||
{[]types.FlagType{noneFlag, pendingFlag}, noneFlag, true, false},
|
||||
{[]types.FlagType{focusedFlag, pendingFlag}, noneFlag, true, true},
|
||||
}
|
||||
|
||||
for i, c := range cases {
|
||||
subject := newIt("it node", c.SubjectFlag, false)
|
||||
containers := []*containernode.ContainerNode{}
|
||||
for _, flag := range c.ContainerFlags {
|
||||
containers = append(containers, newContainer("container", flag))
|
||||
}
|
||||
|
||||
spec := New(subject, containers, false)
|
||||
Ω(spec.Pending()).Should(Equal(c.Pending), "Case %d: %#v", i, c)
|
||||
Ω(spec.Focused()).Should(Equal(c.Focused), "Case %d: %#v", i, c)
|
||||
|
||||
if c.Pending {
|
||||
Ω(spec.Summary("").State).Should(Equal(types.SpecStatePending))
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Skip", func() {
|
||||
It("should be skipped", func() {
|
||||
spec := New(newIt("it node", noneFlag, false), containers(newContainer("container", noneFlag)), false)
|
||||
Ω(spec.Skipped()).Should(BeFalse())
|
||||
spec.Skip()
|
||||
Ω(spec.Skipped()).Should(BeTrue())
|
||||
Ω(spec.Summary("").State).Should(Equal(types.SpecStateSkipped))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("IsMeasurement", func() {
|
||||
It("should be true if the subject is a measurement node", func() {
|
||||
spec := New(newIt("it node", noneFlag, false), containers(newContainer("container", noneFlag)), false)
|
||||
Ω(spec.IsMeasurement()).Should(BeFalse())
|
||||
Ω(spec.Summary("").IsMeasurement).Should(BeFalse())
|
||||
Ω(spec.Summary("").NumberOfSamples).Should(Equal(1))
|
||||
|
||||
spec = New(newMeasure("measure node", noneFlag, false, 10), containers(newContainer("container", noneFlag)), false)
|
||||
Ω(spec.IsMeasurement()).Should(BeTrue())
|
||||
Ω(spec.Summary("").IsMeasurement).Should(BeTrue())
|
||||
Ω(spec.Summary("").NumberOfSamples).Should(Equal(10))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Passed", func() {
|
||||
It("should pass when the subject passed", func() {
|
||||
spec := New(newIt("it node", noneFlag, false), containers(), false)
|
||||
spec.Run(buffer)
|
||||
|
||||
Ω(spec.Passed()).Should(BeTrue())
|
||||
Ω(spec.Failed()).Should(BeFalse())
|
||||
Ω(spec.Summary("").State).Should(Equal(types.SpecStatePassed))
|
||||
Ω(spec.Summary("").Failure).Should(BeZero())
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Flaked", func() {
|
||||
It("should work if Run is called twice and gets different results", func() {
|
||||
i := 0
|
||||
spec := New(newItWithBody("flaky it", func() {
|
||||
i++
|
||||
if i == 1 {
|
||||
failer.Fail("oops", codeLocation)
|
||||
}
|
||||
}), containers(), false)
|
||||
spec.Run(buffer)
|
||||
Ω(spec.Passed()).Should(BeFalse())
|
||||
Ω(spec.Failed()).Should(BeTrue())
|
||||
Ω(spec.Flaked()).Should(BeFalse())
|
||||
Ω(spec.Summary("").State).Should(Equal(types.SpecStateFailed))
|
||||
Ω(spec.Summary("").Failure.Message).Should(Equal("oops"))
|
||||
spec.Run(buffer)
|
||||
Ω(spec.Passed()).Should(BeTrue())
|
||||
Ω(spec.Failed()).Should(BeFalse())
|
||||
Ω(spec.Flaked()).Should(BeTrue())
|
||||
Ω(spec.Summary("").State).Should(Equal(types.SpecStatePassed))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Failed", func() {
|
||||
It("should be failed if the failure was panic", func() {
|
||||
spec := New(newItWithBody("panicky it", func() {
|
||||
panic("bam")
|
||||
}), containers(), false)
|
||||
spec.Run(buffer)
|
||||
Ω(spec.Passed()).Should(BeFalse())
|
||||
Ω(spec.Failed()).Should(BeTrue())
|
||||
Ω(spec.Summary("").State).Should(Equal(types.SpecStatePanicked))
|
||||
Ω(spec.Summary("").Failure.Message).Should(Equal("Test Panicked"))
|
||||
Ω(spec.Summary("").Failure.ForwardedPanic).Should(Equal("bam"))
|
||||
})
|
||||
|
||||
It("should be failed if the failure was a timeout", func() {
|
||||
spec := New(newItWithBody("sleepy it", func(done Done) {}), containers(), false)
|
||||
spec.Run(buffer)
|
||||
Ω(spec.Passed()).Should(BeFalse())
|
||||
Ω(spec.Failed()).Should(BeTrue())
|
||||
Ω(spec.Summary("").State).Should(Equal(types.SpecStateTimedOut))
|
||||
Ω(spec.Summary("").Failure.Message).Should(Equal("Timed out"))
|
||||
})
|
||||
|
||||
It("should be failed if the failure was... a failure", func() {
|
||||
spec := New(newItWithBody("failing it", func() {
|
||||
failer.Fail("bam", codeLocation)
|
||||
}), containers(), false)
|
||||
spec.Run(buffer)
|
||||
Ω(spec.Passed()).Should(BeFalse())
|
||||
Ω(spec.Failed()).Should(BeTrue())
|
||||
Ω(spec.Summary("").State).Should(Equal(types.SpecStateFailed))
|
||||
Ω(spec.Summary("").Failure.Message).Should(Equal("bam"))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Concatenated string", func() {
|
||||
It("should concatenate the texts of the containers and the subject", func() {
|
||||
spec := New(
|
||||
newIt("it node", noneFlag, false),
|
||||
containers(
|
||||
newContainer("outer container", noneFlag),
|
||||
newContainer("inner container", noneFlag),
|
||||
),
|
||||
false,
|
||||
)
|
||||
|
||||
Ω(spec.ConcatenatedString()).Should(Equal("outer container inner container it node"))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("running it specs", func() {
|
||||
Context("with just an it", func() {
|
||||
Context("that succeeds", func() {
|
||||
It("should run the it and report on its success", func() {
|
||||
spec := New(newIt("it node", noneFlag, false), containers(), false)
|
||||
spec.Run(buffer)
|
||||
Ω(spec.Passed()).Should(BeTrue())
|
||||
Ω(spec.Failed()).Should(BeFalse())
|
||||
Ω(nodesThatRan).Should(Equal([]string{"it node"}))
|
||||
})
|
||||
})
|
||||
|
||||
Context("that fails", func() {
|
||||
It("should run the it and report on its success", func() {
|
||||
spec := New(newIt("it node", noneFlag, true), containers(), false)
|
||||
spec.Run(buffer)
|
||||
Ω(spec.Passed()).Should(BeFalse())
|
||||
Ω(spec.Failed()).Should(BeTrue())
|
||||
Ω(spec.Summary("").Failure.Message).Should(Equal("it node"))
|
||||
Ω(nodesThatRan).Should(Equal([]string{"it node"}))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("with a full set of setup nodes", func() {
|
||||
var failingNodes map[string]bool
|
||||
|
||||
BeforeEach(func() {
|
||||
failingNodes = map[string]bool{}
|
||||
})
|
||||
|
||||
JustBeforeEach(func() {
|
||||
spec = New(
|
||||
newIt("it node", noneFlag, failingNodes["it node"]),
|
||||
containers(
|
||||
newContainer("outer container", noneFlag,
|
||||
newBef("outer bef A", failingNodes["outer bef A"]),
|
||||
newBef("outer bef B", failingNodes["outer bef B"]),
|
||||
newJusBef("outer jusbef A", failingNodes["outer jusbef A"]),
|
||||
newJusBef("outer jusbef B", failingNodes["outer jusbef B"]),
|
||||
newAft("outer aft A", failingNodes["outer aft A"]),
|
||||
newAft("outer aft B", failingNodes["outer aft B"]),
|
||||
),
|
||||
newContainer("inner container", noneFlag,
|
||||
newBef("inner bef A", failingNodes["inner bef A"]),
|
||||
newBef("inner bef B", failingNodes["inner bef B"]),
|
||||
newJusBef("inner jusbef A", failingNodes["inner jusbef A"]),
|
||||
newJusBef("inner jusbef B", failingNodes["inner jusbef B"]),
|
||||
newAft("inner aft A", failingNodes["inner aft A"]),
|
||||
newAft("inner aft B", failingNodes["inner aft B"]),
|
||||
),
|
||||
),
|
||||
false,
|
||||
)
|
||||
spec.Run(buffer)
|
||||
})
|
||||
|
||||
Context("that all pass", func() {
|
||||
It("should walk through the nodes in the correct order", func() {
|
||||
Ω(spec.Passed()).Should(BeTrue())
|
||||
Ω(spec.Failed()).Should(BeFalse())
|
||||
Ω(nodesThatRan).Should(Equal([]string{
|
||||
"outer bef A",
|
||||
"outer bef B",
|
||||
"inner bef A",
|
||||
"inner bef B",
|
||||
"outer jusbef A",
|
||||
"outer jusbef B",
|
||||
"inner jusbef A",
|
||||
"inner jusbef B",
|
||||
"it node",
|
||||
"inner aft A",
|
||||
"inner aft B",
|
||||
"outer aft A",
|
||||
"outer aft B",
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the subject fails", func() {
|
||||
BeforeEach(func() {
|
||||
failingNodes["it node"] = true
|
||||
})
|
||||
|
||||
It("should run the afters", func() {
|
||||
Ω(spec.Passed()).Should(BeFalse())
|
||||
Ω(spec.Failed()).Should(BeTrue())
|
||||
Ω(nodesThatRan).Should(Equal([]string{
|
||||
"outer bef A",
|
||||
"outer bef B",
|
||||
"inner bef A",
|
||||
"inner bef B",
|
||||
"outer jusbef A",
|
||||
"outer jusbef B",
|
||||
"inner jusbef A",
|
||||
"inner jusbef B",
|
||||
"it node",
|
||||
"inner aft A",
|
||||
"inner aft B",
|
||||
"outer aft A",
|
||||
"outer aft B",
|
||||
}))
|
||||
Ω(spec.Summary("").Failure.Message).Should(Equal("it node"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when an inner before fails", func() {
|
||||
BeforeEach(func() {
|
||||
failingNodes["inner bef A"] = true
|
||||
})
|
||||
|
||||
It("should not run any other befores, but it should run the subsequent afters", func() {
|
||||
Ω(spec.Passed()).Should(BeFalse())
|
||||
Ω(spec.Failed()).Should(BeTrue())
|
||||
Ω(nodesThatRan).Should(Equal([]string{
|
||||
"outer bef A",
|
||||
"outer bef B",
|
||||
"inner bef A",
|
||||
"inner aft A",
|
||||
"inner aft B",
|
||||
"outer aft A",
|
||||
"outer aft B",
|
||||
}))
|
||||
Ω(spec.Summary("").Failure.Message).Should(Equal("inner bef A"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when an outer before fails", func() {
|
||||
BeforeEach(func() {
|
||||
failingNodes["outer bef B"] = true
|
||||
})
|
||||
|
||||
It("should not run any other befores, but it should run the subsequent afters", func() {
|
||||
Ω(spec.Passed()).Should(BeFalse())
|
||||
Ω(spec.Failed()).Should(BeTrue())
|
||||
Ω(nodesThatRan).Should(Equal([]string{
|
||||
"outer bef A",
|
||||
"outer bef B",
|
||||
"outer aft A",
|
||||
"outer aft B",
|
||||
}))
|
||||
Ω(spec.Summary("").Failure.Message).Should(Equal("outer bef B"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when an after fails", func() {
|
||||
BeforeEach(func() {
|
||||
failingNodes["inner aft B"] = true
|
||||
})
|
||||
|
||||
It("should run all other afters, but mark the test as failed", func() {
|
||||
Ω(spec.Passed()).Should(BeFalse())
|
||||
Ω(spec.Failed()).Should(BeTrue())
|
||||
Ω(nodesThatRan).Should(Equal([]string{
|
||||
"outer bef A",
|
||||
"outer bef B",
|
||||
"inner bef A",
|
||||
"inner bef B",
|
||||
"outer jusbef A",
|
||||
"outer jusbef B",
|
||||
"inner jusbef A",
|
||||
"inner jusbef B",
|
||||
"it node",
|
||||
"inner aft A",
|
||||
"inner aft B",
|
||||
"outer aft A",
|
||||
"outer aft B",
|
||||
}))
|
||||
Ω(spec.Summary("").Failure.Message).Should(Equal("inner aft B"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a just before each fails", func() {
|
||||
BeforeEach(func() {
|
||||
failingNodes["outer jusbef B"] = true
|
||||
})
|
||||
|
||||
It("should run the afters, but not the subject", func() {
|
||||
Ω(spec.Passed()).Should(BeFalse())
|
||||
Ω(spec.Failed()).Should(BeTrue())
|
||||
Ω(nodesThatRan).Should(Equal([]string{
|
||||
"outer bef A",
|
||||
"outer bef B",
|
||||
"inner bef A",
|
||||
"inner bef B",
|
||||
"outer jusbef A",
|
||||
"outer jusbef B",
|
||||
"inner aft A",
|
||||
"inner aft B",
|
||||
"outer aft A",
|
||||
"outer aft B",
|
||||
}))
|
||||
Ω(spec.Summary("").Failure.Message).Should(Equal("outer jusbef B"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when an after fails after an earlier node has failed", func() {
|
||||
BeforeEach(func() {
|
||||
failingNodes["it node"] = true
|
||||
failingNodes["inner aft B"] = true
|
||||
})
|
||||
|
||||
It("should record the earlier failure", func() {
|
||||
Ω(spec.Passed()).Should(BeFalse())
|
||||
Ω(spec.Failed()).Should(BeTrue())
|
||||
Ω(nodesThatRan).Should(Equal([]string{
|
||||
"outer bef A",
|
||||
"outer bef B",
|
||||
"inner bef A",
|
||||
"inner bef B",
|
||||
"outer jusbef A",
|
||||
"outer jusbef B",
|
||||
"inner jusbef A",
|
||||
"inner jusbef B",
|
||||
"it node",
|
||||
"inner aft A",
|
||||
"inner aft B",
|
||||
"outer aft A",
|
||||
"outer aft B",
|
||||
}))
|
||||
Ω(spec.Summary("").Failure.Message).Should(Equal("it node"))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("running measurement specs", func() {
|
||||
Context("when the measurement succeeds", func() {
|
||||
It("should run N samples", func() {
|
||||
spec = New(
|
||||
newMeasure("measure node", noneFlag, false, 3),
|
||||
containers(
|
||||
newContainer("container", noneFlag,
|
||||
newBef("bef A", false),
|
||||
newJusBef("jusbef A", false),
|
||||
newAft("aft A", false),
|
||||
),
|
||||
),
|
||||
false,
|
||||
)
|
||||
spec.Run(buffer)
|
||||
|
||||
Ω(spec.Passed()).Should(BeTrue())
|
||||
Ω(spec.Failed()).Should(BeFalse())
|
||||
Ω(nodesThatRan).Should(Equal([]string{
|
||||
"bef A",
|
||||
"jusbef A",
|
||||
"measure node",
|
||||
"aft A",
|
||||
"bef A",
|
||||
"jusbef A",
|
||||
"measure node",
|
||||
"aft A",
|
||||
"bef A",
|
||||
"jusbef A",
|
||||
"measure node",
|
||||
"aft A",
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the measurement fails", func() {
|
||||
It("should bail after the failure occurs", func() {
|
||||
spec = New(
|
||||
newMeasure("measure node", noneFlag, true, 3),
|
||||
containers(
|
||||
newContainer("container", noneFlag,
|
||||
newBef("bef A", false),
|
||||
newJusBef("jusbef A", false),
|
||||
newAft("aft A", false),
|
||||
),
|
||||
),
|
||||
false,
|
||||
)
|
||||
spec.Run(buffer)
|
||||
|
||||
Ω(spec.Passed()).Should(BeFalse())
|
||||
Ω(spec.Failed()).Should(BeTrue())
|
||||
Ω(nodesThatRan).Should(Equal([]string{
|
||||
"bef A",
|
||||
"jusbef A",
|
||||
"measure node",
|
||||
"aft A",
|
||||
}))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Summary", func() {
|
||||
var (
|
||||
subjectCodeLocation types.CodeLocation
|
||||
outerContainerCodeLocation types.CodeLocation
|
||||
innerContainerCodeLocation types.CodeLocation
|
||||
summary *types.SpecSummary
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
subjectCodeLocation = codelocation.New(0)
|
||||
outerContainerCodeLocation = codelocation.New(0)
|
||||
innerContainerCodeLocation = codelocation.New(0)
|
||||
|
||||
spec = New(
|
||||
leafnodes.NewItNode("it node", func() {
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}, noneFlag, subjectCodeLocation, 0, failer, 0),
|
||||
containers(
|
||||
containernode.New("outer container", noneFlag, outerContainerCodeLocation),
|
||||
containernode.New("inner container", noneFlag, innerContainerCodeLocation),
|
||||
),
|
||||
false,
|
||||
)
|
||||
|
||||
spec.Run(buffer)
|
||||
Ω(spec.Passed()).Should(BeTrue())
|
||||
summary = spec.Summary("suite id")
|
||||
})
|
||||
|
||||
It("should have the suite id", func() {
|
||||
Ω(summary.SuiteID).Should(Equal("suite id"))
|
||||
})
|
||||
|
||||
It("should have the component texts and code locations", func() {
|
||||
Ω(summary.ComponentTexts).Should(Equal([]string{"outer container", "inner container", "it node"}))
|
||||
Ω(summary.ComponentCodeLocations).Should(Equal([]types.CodeLocation{outerContainerCodeLocation, innerContainerCodeLocation, subjectCodeLocation}))
|
||||
})
|
||||
|
||||
It("should have a runtime", func() {
|
||||
Ω(summary.RunTime).Should(BeNumerically(">=", 10*time.Millisecond))
|
||||
})
|
||||
|
||||
It("should not be a measurement, or have a measurement summary", func() {
|
||||
Ω(summary.IsMeasurement).Should(BeFalse())
|
||||
Ω(summary.Measurements).Should(BeEmpty())
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Summaries for measurements", func() {
|
||||
var summary *types.SpecSummary
|
||||
|
||||
BeforeEach(func() {
|
||||
spec = New(leafnodes.NewMeasureNode("measure node", func(b Benchmarker) {
|
||||
b.RecordValue("a value", 7, "some info")
|
||||
b.RecordValueWithPrecision("another value", 8, "ns", 5, "more info")
|
||||
}, noneFlag, codeLocation, 4, failer, 0), containers(), false)
|
||||
spec.Run(buffer)
|
||||
Ω(spec.Passed()).Should(BeTrue())
|
||||
summary = spec.Summary("suite id")
|
||||
})
|
||||
|
||||
It("should include the number of samples", func() {
|
||||
Ω(summary.NumberOfSamples).Should(Equal(4))
|
||||
})
|
||||
|
||||
It("should be a measurement", func() {
|
||||
Ω(summary.IsMeasurement).Should(BeTrue())
|
||||
})
|
||||
|
||||
It("should have the measurements report", func() {
|
||||
Ω(summary.Measurements).Should(HaveKey("a value"))
|
||||
report := summary.Measurements["a value"]
|
||||
Ω(report.Name).Should(Equal("a value"))
|
||||
Ω(report.Info).Should(Equal("some info"))
|
||||
Ω(report.Results).Should(Equal([]float64{7, 7, 7, 7}))
|
||||
|
||||
Ω(summary.Measurements).Should(HaveKey("another value"))
|
||||
report = summary.Measurements["another value"]
|
||||
Ω(report.Name).Should(Equal("another value"))
|
||||
Ω(report.Info).Should(Equal("more info"))
|
||||
Ω(report.Results).Should(Equal([]float64{8, 8, 8, 8}))
|
||||
Ω(report.Units).Should(Equal("ns"))
|
||||
Ω(report.Precision).Should(Equal(5))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("When told to emit progress", func() {
|
||||
It("should emit progress to the writer as it runs Befores, JustBefores, Afters, and Its", func() {
|
||||
spec = New(
|
||||
newIt("it node", noneFlag, false),
|
||||
containers(
|
||||
newContainer("outer container", noneFlag,
|
||||
newBef("outer bef A", false),
|
||||
newJusBef("outer jusbef A", false),
|
||||
newAft("outer aft A", false),
|
||||
),
|
||||
newContainer("inner container", noneFlag,
|
||||
newBef("inner bef A", false),
|
||||
newJusBef("inner jusbef A", false),
|
||||
newAft("inner aft A", false),
|
||||
),
|
||||
),
|
||||
true,
|
||||
)
|
||||
spec.Run(buffer)
|
||||
|
||||
Ω(buffer).Should(gbytes.Say(`\[BeforeEach\] outer container`))
|
||||
Ω(buffer).Should(gbytes.Say(`\[BeforeEach\] inner container`))
|
||||
Ω(buffer).Should(gbytes.Say(`\[JustBeforeEach\] outer container`))
|
||||
Ω(buffer).Should(gbytes.Say(`\[JustBeforeEach\] inner container`))
|
||||
Ω(buffer).Should(gbytes.Say(`\[It\] it node`))
|
||||
Ω(buffer).Should(gbytes.Say(`\[AfterEach\] inner container`))
|
||||
Ω(buffer).Should(gbytes.Say(`\[AfterEach\] outer container`))
|
||||
})
|
||||
|
||||
It("should emit progress to the writer as it runs Befores, JustBefores, Afters, and Measures", func() {
|
||||
spec = New(
|
||||
newMeasure("measure node", noneFlag, false, 2),
|
||||
containers(),
|
||||
true,
|
||||
)
|
||||
spec.Run(buffer)
|
||||
|
||||
Ω(buffer).Should(gbytes.Say(`\[Measure\] measure node`))
|
||||
Ω(buffer).Should(gbytes.Say(`\[Measure\] measure node`))
|
||||
})
|
||||
})
|
||||
})
|
||||
287
vendor/github.com/onsi/ginkgo/internal/spec/specs_test.go
generated
vendored
287
vendor/github.com/onsi/ginkgo/internal/spec/specs_test.go
generated
vendored
|
|
@ -1,287 +0,0 @@
|
|||
package spec_test
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/internal/spec"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
"github.com/onsi/ginkgo/internal/containernode"
|
||||
"github.com/onsi/ginkgo/internal/leafnodes"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
)
|
||||
|
||||
var _ = Describe("Specs", func() {
|
||||
var specs *Specs
|
||||
|
||||
newSpec := func(text string, flag types.FlagType) *Spec {
|
||||
subject := leafnodes.NewItNode(text, func() {}, flag, codelocation.New(0), 0, nil, 0)
|
||||
return New(subject, []*containernode.ContainerNode{}, false)
|
||||
}
|
||||
|
||||
newMeasureSpec := func(text string, flag types.FlagType) *Spec {
|
||||
subject := leafnodes.NewMeasureNode(text, func(Benchmarker) {}, flag, codelocation.New(0), 0, nil, 0)
|
||||
return New(subject, []*containernode.ContainerNode{}, false)
|
||||
}
|
||||
|
||||
newSpecs := func(args ...interface{}) *Specs {
|
||||
specs := []*Spec{}
|
||||
for index := 0; index < len(args)-1; index += 2 {
|
||||
specs = append(specs, newSpec(args[index].(string), args[index+1].(types.FlagType)))
|
||||
}
|
||||
return NewSpecs(specs)
|
||||
}
|
||||
|
||||
specTexts := func(specs *Specs) []string {
|
||||
texts := []string{}
|
||||
for _, spec := range specs.Specs() {
|
||||
texts = append(texts, spec.ConcatenatedString())
|
||||
}
|
||||
return texts
|
||||
}
|
||||
|
||||
willRunTexts := func(specs *Specs) []string {
|
||||
texts := []string{}
|
||||
for _, spec := range specs.Specs() {
|
||||
if !(spec.Skipped() || spec.Pending()) {
|
||||
texts = append(texts, spec.ConcatenatedString())
|
||||
}
|
||||
}
|
||||
return texts
|
||||
}
|
||||
|
||||
skippedTexts := func(specs *Specs) []string {
|
||||
texts := []string{}
|
||||
for _, spec := range specs.Specs() {
|
||||
if spec.Skipped() {
|
||||
texts = append(texts, spec.ConcatenatedString())
|
||||
}
|
||||
}
|
||||
return texts
|
||||
}
|
||||
|
||||
pendingTexts := func(specs *Specs) []string {
|
||||
texts := []string{}
|
||||
for _, spec := range specs.Specs() {
|
||||
if spec.Pending() {
|
||||
texts = append(texts, spec.ConcatenatedString())
|
||||
}
|
||||
}
|
||||
return texts
|
||||
}
|
||||
|
||||
Describe("Shuffling specs", func() {
|
||||
It("should shuffle the specs using the passed in randomizer", func() {
|
||||
specs17 := newSpecs("C", noneFlag, "A", noneFlag, "B", noneFlag)
|
||||
specs17.Shuffle(rand.New(rand.NewSource(17)))
|
||||
texts17 := specTexts(specs17)
|
||||
|
||||
specs17Again := newSpecs("C", noneFlag, "A", noneFlag, "B", noneFlag)
|
||||
specs17Again.Shuffle(rand.New(rand.NewSource(17)))
|
||||
texts17Again := specTexts(specs17Again)
|
||||
|
||||
specs15 := newSpecs("C", noneFlag, "A", noneFlag, "B", noneFlag)
|
||||
specs15.Shuffle(rand.New(rand.NewSource(15)))
|
||||
texts15 := specTexts(specs15)
|
||||
|
||||
specsUnshuffled := newSpecs("C", noneFlag, "A", noneFlag, "B", noneFlag)
|
||||
textsUnshuffled := specTexts(specsUnshuffled)
|
||||
|
||||
Ω(textsUnshuffled).Should(Equal([]string{"C", "A", "B"}))
|
||||
|
||||
Ω(texts17).Should(Equal(texts17Again))
|
||||
Ω(texts17).ShouldNot(Equal(texts15))
|
||||
Ω(texts17).ShouldNot(Equal(textsUnshuffled))
|
||||
Ω(texts15).ShouldNot(Equal(textsUnshuffled))
|
||||
|
||||
Ω(texts17).Should(HaveLen(3))
|
||||
Ω(texts17).Should(ContainElement("A"))
|
||||
Ω(texts17).Should(ContainElement("B"))
|
||||
Ω(texts17).Should(ContainElement("C"))
|
||||
|
||||
Ω(texts15).Should(HaveLen(3))
|
||||
Ω(texts15).Should(ContainElement("A"))
|
||||
Ω(texts15).Should(ContainElement("B"))
|
||||
Ω(texts15).Should(ContainElement("C"))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("with no programmatic focus", func() {
|
||||
BeforeEach(func() {
|
||||
specs = newSpecs("A1", noneFlag, "A2", noneFlag, "B1", noneFlag, "B2", pendingFlag)
|
||||
specs.ApplyFocus("", "", "")
|
||||
})
|
||||
|
||||
It("should not report as having programmatic specs", func() {
|
||||
Ω(specs.HasProgrammaticFocus()).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Applying focus/skip", func() {
|
||||
var description, focusString, skipString string
|
||||
|
||||
BeforeEach(func() {
|
||||
description, focusString, skipString = "", "", ""
|
||||
})
|
||||
|
||||
JustBeforeEach(func() {
|
||||
specs = newSpecs("A1", focusedFlag, "A2", noneFlag, "B1", focusedFlag, "B2", pendingFlag)
|
||||
specs.ApplyFocus(description, focusString, skipString)
|
||||
})
|
||||
|
||||
Context("with neither a focus string nor a skip string", func() {
|
||||
It("should apply the programmatic focus", func() {
|
||||
Ω(willRunTexts(specs)).Should(Equal([]string{"A1", "B1"}))
|
||||
Ω(skippedTexts(specs)).Should(Equal([]string{"A2", "B2"}))
|
||||
Ω(pendingTexts(specs)).Should(BeEmpty())
|
||||
})
|
||||
|
||||
It("should report as having programmatic specs", func() {
|
||||
Ω(specs.HasProgrammaticFocus()).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
Context("with a focus regexp", func() {
|
||||
BeforeEach(func() {
|
||||
focusString = "A"
|
||||
})
|
||||
|
||||
It("should override the programmatic focus", func() {
|
||||
Ω(willRunTexts(specs)).Should(Equal([]string{"A1", "A2"}))
|
||||
Ω(skippedTexts(specs)).Should(Equal([]string{"B1", "B2"}))
|
||||
Ω(pendingTexts(specs)).Should(BeEmpty())
|
||||
})
|
||||
|
||||
It("should not report as having programmatic specs", func() {
|
||||
Ω(specs.HasProgrammaticFocus()).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
|
||||
Context("with a focus regexp", func() {
|
||||
BeforeEach(func() {
|
||||
focusString = "B"
|
||||
})
|
||||
|
||||
It("should not override any pendings", func() {
|
||||
Ω(willRunTexts(specs)).Should(Equal([]string{"B1"}))
|
||||
Ω(skippedTexts(specs)).Should(Equal([]string{"A1", "A2"}))
|
||||
Ω(pendingTexts(specs)).Should(Equal([]string{"B2"}))
|
||||
})
|
||||
})
|
||||
|
||||
Context("with a description", func() {
|
||||
BeforeEach(func() {
|
||||
description = "C"
|
||||
focusString = "C"
|
||||
})
|
||||
|
||||
It("should include the description in the focus determination", func() {
|
||||
Ω(willRunTexts(specs)).Should(Equal([]string{"A1", "A2", "B1"}))
|
||||
Ω(skippedTexts(specs)).Should(BeEmpty())
|
||||
Ω(pendingTexts(specs)).Should(Equal([]string{"B2"}))
|
||||
})
|
||||
})
|
||||
|
||||
Context("with a description", func() {
|
||||
BeforeEach(func() {
|
||||
description = "C"
|
||||
skipString = "C"
|
||||
})
|
||||
|
||||
It("should include the description in the focus determination", func() {
|
||||
Ω(willRunTexts(specs)).Should(BeEmpty())
|
||||
Ω(skippedTexts(specs)).Should(Equal([]string{"A1", "A2", "B1", "B2"}))
|
||||
Ω(pendingTexts(specs)).Should(BeEmpty())
|
||||
})
|
||||
})
|
||||
|
||||
Context("with a skip regexp", func() {
|
||||
BeforeEach(func() {
|
||||
skipString = "A"
|
||||
})
|
||||
|
||||
It("should override the programmatic focus", func() {
|
||||
Ω(willRunTexts(specs)).Should(Equal([]string{"B1"}))
|
||||
Ω(skippedTexts(specs)).Should(Equal([]string{"A1", "A2"}))
|
||||
Ω(pendingTexts(specs)).Should(Equal([]string{"B2"}))
|
||||
})
|
||||
|
||||
It("should not report as having programmatic specs", func() {
|
||||
Ω(specs.HasProgrammaticFocus()).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
|
||||
Context("with both a focus and a skip regexp", func() {
|
||||
BeforeEach(func() {
|
||||
focusString = "1"
|
||||
skipString = "B"
|
||||
})
|
||||
|
||||
It("should AND the two", func() {
|
||||
Ω(willRunTexts(specs)).Should(Equal([]string{"A1"}))
|
||||
Ω(skippedTexts(specs)).Should(Equal([]string{"A2", "B1", "B2"}))
|
||||
Ω(pendingTexts(specs)).Should(BeEmpty())
|
||||
})
|
||||
|
||||
It("should not report as having programmatic specs", func() {
|
||||
Ω(specs.HasProgrammaticFocus()).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("With a focused spec within a pending context and a pending spec within a focused context", func() {
|
||||
BeforeEach(func() {
|
||||
pendingInFocused := New(
|
||||
leafnodes.NewItNode("PendingInFocused", func() {}, pendingFlag, codelocation.New(0), 0, nil, 0),
|
||||
[]*containernode.ContainerNode{
|
||||
containernode.New("", focusedFlag, codelocation.New(0)),
|
||||
}, false)
|
||||
|
||||
focusedInPending := New(
|
||||
leafnodes.NewItNode("FocusedInPending", func() {}, focusedFlag, codelocation.New(0), 0, nil, 0),
|
||||
[]*containernode.ContainerNode{
|
||||
containernode.New("", pendingFlag, codelocation.New(0)),
|
||||
}, false)
|
||||
|
||||
specs = NewSpecs([]*Spec{
|
||||
newSpec("A", noneFlag),
|
||||
newSpec("B", noneFlag),
|
||||
pendingInFocused,
|
||||
focusedInPending,
|
||||
})
|
||||
specs.ApplyFocus("", "", "")
|
||||
})
|
||||
|
||||
It("should not have a programmatic focus and should run all tests", func() {
|
||||
Ω(willRunTexts(specs)).Should(Equal([]string{"A", "B"}))
|
||||
Ω(skippedTexts(specs)).Should(BeEmpty())
|
||||
Ω(pendingTexts(specs)).Should(ConsistOf(ContainSubstring("PendingInFocused"), ContainSubstring("FocusedInPending")))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("skipping measurements", func() {
|
||||
BeforeEach(func() {
|
||||
specs = NewSpecs([]*Spec{
|
||||
newSpec("A", noneFlag),
|
||||
newSpec("B", noneFlag),
|
||||
newSpec("C", pendingFlag),
|
||||
newMeasureSpec("measurementA", noneFlag),
|
||||
newMeasureSpec("measurementB", pendingFlag),
|
||||
})
|
||||
})
|
||||
|
||||
It("should skip measurements", func() {
|
||||
Ω(willRunTexts(specs)).Should(Equal([]string{"A", "B", "measurementA"}))
|
||||
Ω(skippedTexts(specs)).Should(BeEmpty())
|
||||
Ω(pendingTexts(specs)).Should(Equal([]string{"C", "measurementB"}))
|
||||
|
||||
specs.SkipMeasurements()
|
||||
|
||||
Ω(willRunTexts(specs)).Should(Equal([]string{"A", "B"}))
|
||||
Ω(skippedTexts(specs)).Should(Equal([]string{"measurementA", "measurementB"}))
|
||||
Ω(pendingTexts(specs)).Should(Equal([]string{"C"}))
|
||||
})
|
||||
})
|
||||
})
|
||||
149
vendor/github.com/onsi/ginkgo/internal/spec_iterator/index_computer_test.go
generated
vendored
149
vendor/github.com/onsi/ginkgo/internal/spec_iterator/index_computer_test.go
generated
vendored
|
|
@ -1,149 +0,0 @@
|
|||
package spec_iterator_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/internal/spec_iterator"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("ParallelizedIndexRange", func() {
|
||||
var startIndex, count int
|
||||
|
||||
It("should return the correct index range for 4 tests on 2 nodes", func() {
|
||||
startIndex, count = ParallelizedIndexRange(4, 2, 1)
|
||||
Ω(startIndex).Should(Equal(0))
|
||||
Ω(count).Should(Equal(2))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(4, 2, 2)
|
||||
Ω(startIndex).Should(Equal(2))
|
||||
Ω(count).Should(Equal(2))
|
||||
})
|
||||
|
||||
It("should return the correct index range for 5 tests on 2 nodes", func() {
|
||||
startIndex, count = ParallelizedIndexRange(5, 2, 1)
|
||||
Ω(startIndex).Should(Equal(0))
|
||||
Ω(count).Should(Equal(3))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(5, 2, 2)
|
||||
Ω(startIndex).Should(Equal(3))
|
||||
Ω(count).Should(Equal(2))
|
||||
})
|
||||
|
||||
It("should return the correct index range for 5 tests on 3 nodes", func() {
|
||||
startIndex, count = ParallelizedIndexRange(5, 3, 1)
|
||||
Ω(startIndex).Should(Equal(0))
|
||||
Ω(count).Should(Equal(2))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(5, 3, 2)
|
||||
Ω(startIndex).Should(Equal(2))
|
||||
Ω(count).Should(Equal(2))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(5, 3, 3)
|
||||
Ω(startIndex).Should(Equal(4))
|
||||
Ω(count).Should(Equal(1))
|
||||
})
|
||||
|
||||
It("should return the correct index range for 5 tests on 4 nodes", func() {
|
||||
startIndex, count = ParallelizedIndexRange(5, 4, 1)
|
||||
Ω(startIndex).Should(Equal(0))
|
||||
Ω(count).Should(Equal(2))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(5, 4, 2)
|
||||
Ω(startIndex).Should(Equal(2))
|
||||
Ω(count).Should(Equal(1))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(5, 4, 3)
|
||||
Ω(startIndex).Should(Equal(3))
|
||||
Ω(count).Should(Equal(1))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(5, 4, 4)
|
||||
Ω(startIndex).Should(Equal(4))
|
||||
Ω(count).Should(Equal(1))
|
||||
})
|
||||
|
||||
It("should return the correct index range for 5 tests on 5 nodes", func() {
|
||||
startIndex, count = ParallelizedIndexRange(5, 5, 1)
|
||||
Ω(startIndex).Should(Equal(0))
|
||||
Ω(count).Should(Equal(1))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(5, 5, 2)
|
||||
Ω(startIndex).Should(Equal(1))
|
||||
Ω(count).Should(Equal(1))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(5, 5, 3)
|
||||
Ω(startIndex).Should(Equal(2))
|
||||
Ω(count).Should(Equal(1))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(5, 5, 4)
|
||||
Ω(startIndex).Should(Equal(3))
|
||||
Ω(count).Should(Equal(1))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(5, 5, 5)
|
||||
Ω(startIndex).Should(Equal(4))
|
||||
Ω(count).Should(Equal(1))
|
||||
})
|
||||
|
||||
It("should return the correct index range for 5 tests on 6 nodes", func() {
|
||||
startIndex, count = ParallelizedIndexRange(5, 6, 1)
|
||||
Ω(startIndex).Should(Equal(0))
|
||||
Ω(count).Should(Equal(1))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(5, 6, 2)
|
||||
Ω(startIndex).Should(Equal(1))
|
||||
Ω(count).Should(Equal(1))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(5, 6, 3)
|
||||
Ω(startIndex).Should(Equal(2))
|
||||
Ω(count).Should(Equal(1))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(5, 6, 4)
|
||||
Ω(startIndex).Should(Equal(3))
|
||||
Ω(count).Should(Equal(1))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(5, 6, 5)
|
||||
Ω(startIndex).Should(Equal(4))
|
||||
Ω(count).Should(Equal(1))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(5, 6, 6)
|
||||
Ω(count).Should(Equal(0))
|
||||
})
|
||||
|
||||
It("should return the correct index range for 5 tests on 7 nodes", func() {
|
||||
startIndex, count = ParallelizedIndexRange(5, 7, 6)
|
||||
Ω(count).Should(Equal(0))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(5, 7, 7)
|
||||
Ω(count).Should(Equal(0))
|
||||
})
|
||||
|
||||
It("should return the correct index range for 11 tests on 7 nodes", func() {
|
||||
startIndex, count = ParallelizedIndexRange(11, 7, 1)
|
||||
Ω(startIndex).Should(Equal(0))
|
||||
Ω(count).Should(Equal(2))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(11, 7, 2)
|
||||
Ω(startIndex).Should(Equal(2))
|
||||
Ω(count).Should(Equal(2))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(11, 7, 3)
|
||||
Ω(startIndex).Should(Equal(4))
|
||||
Ω(count).Should(Equal(2))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(11, 7, 4)
|
||||
Ω(startIndex).Should(Equal(6))
|
||||
Ω(count).Should(Equal(2))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(11, 7, 5)
|
||||
Ω(startIndex).Should(Equal(8))
|
||||
Ω(count).Should(Equal(1))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(11, 7, 6)
|
||||
Ω(startIndex).Should(Equal(9))
|
||||
Ω(count).Should(Equal(1))
|
||||
|
||||
startIndex, count = ParallelizedIndexRange(11, 7, 7)
|
||||
Ω(startIndex).Should(Equal(10))
|
||||
Ω(count).Should(Equal(1))
|
||||
})
|
||||
|
||||
})
|
||||
3
vendor/github.com/onsi/ginkgo/internal/spec_iterator/parallel_spec_iterator.go
generated
vendored
3
vendor/github.com/onsi/ginkgo/internal/spec_iterator/parallel_spec_iterator.go
generated
vendored
|
|
@ -2,7 +2,6 @@ package spec_iterator
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
|
|
@ -31,7 +30,7 @@ func (s *ParallelIterator) Next() (*spec.Spec, error) {
|
|||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, errors.New(fmt.Sprintf("unexpected status code %d", resp.StatusCode))
|
||||
return nil, fmt.Errorf("unexpected status code %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
var counter Counter
|
||||
|
|
|
|||
112
vendor/github.com/onsi/ginkgo/internal/spec_iterator/parallel_spec_iterator_test.go
generated
vendored
112
vendor/github.com/onsi/ginkgo/internal/spec_iterator/parallel_spec_iterator_test.go
generated
vendored
|
|
@ -1,112 +0,0 @@
|
|||
package spec_iterator_test
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
. "github.com/onsi/ginkgo/internal/spec_iterator"
|
||||
"github.com/onsi/gomega/ghttp"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
"github.com/onsi/ginkgo/internal/containernode"
|
||||
"github.com/onsi/ginkgo/internal/leafnodes"
|
||||
"github.com/onsi/ginkgo/internal/spec"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("ParallelSpecIterator", func() {
|
||||
var specs []*spec.Spec
|
||||
var iterator *ParallelIterator
|
||||
var server *ghttp.Server
|
||||
|
||||
newSpec := func(text string, flag types.FlagType) *spec.Spec {
|
||||
subject := leafnodes.NewItNode(text, func() {}, flag, codelocation.New(0), 0, nil, 0)
|
||||
return spec.New(subject, []*containernode.ContainerNode{}, false)
|
||||
}
|
||||
|
||||
BeforeEach(func() {
|
||||
specs = []*spec.Spec{
|
||||
newSpec("A", types.FlagTypePending),
|
||||
newSpec("B", types.FlagTypeNone),
|
||||
newSpec("C", types.FlagTypeNone),
|
||||
newSpec("D", types.FlagTypeNone),
|
||||
}
|
||||
specs[3].Skip()
|
||||
|
||||
server = ghttp.NewServer()
|
||||
|
||||
iterator = NewParallelIterator(specs, "http://"+server.Addr())
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
server.Close()
|
||||
})
|
||||
|
||||
It("should report the total number of specs", func() {
|
||||
Ω(iterator.NumberOfSpecsPriorToIteration()).Should(Equal(4))
|
||||
})
|
||||
|
||||
It("should not report the number to be processed", func() {
|
||||
n, known := iterator.NumberOfSpecsToProcessIfKnown()
|
||||
Ω(n).Should(Equal(-1))
|
||||
Ω(known).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should not report the number that will be run", func() {
|
||||
n, known := iterator.NumberOfSpecsThatWillBeRunIfKnown()
|
||||
Ω(n).Should(Equal(-1))
|
||||
Ω(known).Should(BeFalse())
|
||||
})
|
||||
|
||||
Describe("iterating", func() {
|
||||
Describe("when the server returns well-formed responses", func() {
|
||||
BeforeEach(func() {
|
||||
server.AppendHandlers(
|
||||
ghttp.RespondWithJSONEncoded(http.StatusOK, Counter{0}),
|
||||
ghttp.RespondWithJSONEncoded(http.StatusOK, Counter{1}),
|
||||
ghttp.RespondWithJSONEncoded(http.StatusOK, Counter{3}),
|
||||
ghttp.RespondWithJSONEncoded(http.StatusOK, Counter{4}),
|
||||
)
|
||||
})
|
||||
|
||||
It("should return the specs in question", func() {
|
||||
Ω(iterator.Next()).Should(Equal(specs[0]))
|
||||
Ω(iterator.Next()).Should(Equal(specs[1]))
|
||||
Ω(iterator.Next()).Should(Equal(specs[3]))
|
||||
spec, err := iterator.Next()
|
||||
Ω(spec).Should(BeNil())
|
||||
Ω(err).Should(MatchError(ErrClosed))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("when the server 404s", func() {
|
||||
BeforeEach(func() {
|
||||
server.AppendHandlers(
|
||||
ghttp.RespondWith(http.StatusNotFound, ""),
|
||||
)
|
||||
})
|
||||
|
||||
It("should return an error", func() {
|
||||
spec, err := iterator.Next()
|
||||
Ω(spec).Should(BeNil())
|
||||
Ω(err).Should(MatchError("unexpected status code 404"))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("when the server returns gibberish", func() {
|
||||
BeforeEach(func() {
|
||||
server.AppendHandlers(
|
||||
ghttp.RespondWith(http.StatusOK, "ß"),
|
||||
)
|
||||
})
|
||||
|
||||
It("should error", func() {
|
||||
spec, err := iterator.Next()
|
||||
Ω(spec).Should(BeNil())
|
||||
Ω(err).ShouldNot(BeNil())
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
64
vendor/github.com/onsi/ginkgo/internal/spec_iterator/serial_spec_iterator_test.go
generated
vendored
64
vendor/github.com/onsi/ginkgo/internal/spec_iterator/serial_spec_iterator_test.go
generated
vendored
|
|
@ -1,64 +0,0 @@
|
|||
package spec_iterator_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo/internal/spec_iterator"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
"github.com/onsi/ginkgo/internal/containernode"
|
||||
"github.com/onsi/ginkgo/internal/leafnodes"
|
||||
"github.com/onsi/ginkgo/internal/spec"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("SerialSpecIterator", func() {
|
||||
var specs []*spec.Spec
|
||||
var iterator *SerialIterator
|
||||
|
||||
newSpec := func(text string, flag types.FlagType) *spec.Spec {
|
||||
subject := leafnodes.NewItNode(text, func() {}, flag, codelocation.New(0), 0, nil, 0)
|
||||
return spec.New(subject, []*containernode.ContainerNode{}, false)
|
||||
}
|
||||
|
||||
BeforeEach(func() {
|
||||
specs = []*spec.Spec{
|
||||
newSpec("A", types.FlagTypePending),
|
||||
newSpec("B", types.FlagTypeNone),
|
||||
newSpec("C", types.FlagTypeNone),
|
||||
newSpec("D", types.FlagTypeNone),
|
||||
}
|
||||
specs[3].Skip()
|
||||
|
||||
iterator = NewSerialIterator(specs)
|
||||
})
|
||||
|
||||
It("should report the total number of specs", func() {
|
||||
Ω(iterator.NumberOfSpecsPriorToIteration()).Should(Equal(4))
|
||||
})
|
||||
|
||||
It("should report the number to be processed", func() {
|
||||
n, known := iterator.NumberOfSpecsToProcessIfKnown()
|
||||
Ω(n).Should(Equal(4))
|
||||
Ω(known).Should(BeTrue())
|
||||
})
|
||||
|
||||
It("should report the number that will be run", func() {
|
||||
n, known := iterator.NumberOfSpecsThatWillBeRunIfKnown()
|
||||
Ω(n).Should(Equal(2))
|
||||
Ω(known).Should(BeTrue())
|
||||
})
|
||||
|
||||
Describe("iterating", func() {
|
||||
It("should return the specs in order", func() {
|
||||
Ω(iterator.Next()).Should(Equal(specs[0]))
|
||||
Ω(iterator.Next()).Should(Equal(specs[1]))
|
||||
Ω(iterator.Next()).Should(Equal(specs[2]))
|
||||
Ω(iterator.Next()).Should(Equal(specs[3]))
|
||||
spec, err := iterator.Next()
|
||||
Ω(spec).Should(BeNil())
|
||||
Ω(err).Should(MatchError(ErrClosed))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
package spec_iterator_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo/internal/spec_iterator"
|
||||
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
"github.com/onsi/ginkgo/internal/containernode"
|
||||
"github.com/onsi/ginkgo/internal/leafnodes"
|
||||
"github.com/onsi/ginkgo/internal/spec"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("ShardedParallelSpecIterator", func() {
|
||||
var specs []*spec.Spec
|
||||
var iterator *ShardedParallelIterator
|
||||
|
||||
newSpec := func(text string, flag types.FlagType) *spec.Spec {
|
||||
subject := leafnodes.NewItNode(text, func() {}, flag, codelocation.New(0), 0, nil, 0)
|
||||
return spec.New(subject, []*containernode.ContainerNode{}, false)
|
||||
}
|
||||
|
||||
BeforeEach(func() {
|
||||
specs = []*spec.Spec{
|
||||
newSpec("A", types.FlagTypePending),
|
||||
newSpec("B", types.FlagTypeNone),
|
||||
newSpec("C", types.FlagTypeNone),
|
||||
newSpec("D", types.FlagTypeNone),
|
||||
}
|
||||
specs[3].Skip()
|
||||
|
||||
iterator = NewShardedParallelIterator(specs, 2, 1)
|
||||
})
|
||||
|
||||
It("should report the total number of specs", func() {
|
||||
Ω(iterator.NumberOfSpecsPriorToIteration()).Should(Equal(4))
|
||||
})
|
||||
|
||||
It("should report the number to be processed", func() {
|
||||
n, known := iterator.NumberOfSpecsToProcessIfKnown()
|
||||
Ω(n).Should(Equal(2))
|
||||
Ω(known).Should(BeTrue())
|
||||
})
|
||||
|
||||
It("should report the number that will be run", func() {
|
||||
n, known := iterator.NumberOfSpecsThatWillBeRunIfKnown()
|
||||
Ω(n).Should(Equal(1))
|
||||
Ω(known).Should(BeTrue())
|
||||
})
|
||||
|
||||
Describe("iterating", func() {
|
||||
It("should return the specs in order", func() {
|
||||
Ω(iterator.Next()).Should(Equal(specs[0]))
|
||||
Ω(iterator.Next()).Should(Equal(specs[1]))
|
||||
spec, err := iterator.Next()
|
||||
Ω(spec).Should(BeNil())
|
||||
Ω(err).Should(MatchError(ErrClosed))
|
||||
})
|
||||
})
|
||||
})
|
||||
13
vendor/github.com/onsi/ginkgo/internal/spec_iterator/spec_iterator_suite_test.go
generated
vendored
13
vendor/github.com/onsi/ginkgo/internal/spec_iterator/spec_iterator_suite_test.go
generated
vendored
|
|
@ -1,13 +0,0 @@
|
|||
package spec_iterator_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSpecIterator(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "SpecIterator Suite")
|
||||
}
|
||||
7
vendor/github.com/onsi/ginkgo/internal/specrunner/spec_runner.go
generated
vendored
7
vendor/github.com/onsi/ginkgo/internal/specrunner/spec_runner.go
generated
vendored
|
|
@ -56,7 +56,9 @@ func (runner *SpecRunner) Run() bool {
|
|||
}
|
||||
|
||||
runner.reportSuiteWillBegin()
|
||||
go runner.registerForInterrupts()
|
||||
signalRegistered := make(chan struct{})
|
||||
go runner.registerForInterrupts(signalRegistered)
|
||||
<-signalRegistered
|
||||
|
||||
suitePassed := runner.runBeforeSuite()
|
||||
|
||||
|
|
@ -213,9 +215,10 @@ func (runner *SpecRunner) CurrentSpecSummary() (*types.SpecSummary, bool) {
|
|||
return runner.runningSpec.Summary(runner.suiteID), true
|
||||
}
|
||||
|
||||
func (runner *SpecRunner) registerForInterrupts() {
|
||||
func (runner *SpecRunner) registerForInterrupts(signalRegistered chan struct{}) {
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||
close(signalRegistered)
|
||||
|
||||
<-c
|
||||
signal.Stop(c)
|
||||
|
|
|
|||
13
vendor/github.com/onsi/ginkgo/internal/specrunner/spec_runner_suite_test.go
generated
vendored
13
vendor/github.com/onsi/ginkgo/internal/specrunner/spec_runner_suite_test.go
generated
vendored
|
|
@ -1,13 +0,0 @@
|
|||
package specrunner_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSpecRunner(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Spec Runner Suite")
|
||||
}
|
||||
779
vendor/github.com/onsi/ginkgo/internal/specrunner/spec_runner_test.go
generated
vendored
779
vendor/github.com/onsi/ginkgo/internal/specrunner/spec_runner_test.go
generated
vendored
|
|
@ -1,779 +0,0 @@
|
|||
package specrunner_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
"github.com/onsi/ginkgo/internal/spec_iterator"
|
||||
. "github.com/onsi/ginkgo/internal/specrunner"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/onsi/ginkgo/config"
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
"github.com/onsi/ginkgo/internal/containernode"
|
||||
Failer "github.com/onsi/ginkgo/internal/failer"
|
||||
"github.com/onsi/ginkgo/internal/leafnodes"
|
||||
"github.com/onsi/ginkgo/internal/spec"
|
||||
Writer "github.com/onsi/ginkgo/internal/writer"
|
||||
"github.com/onsi/ginkgo/reporters"
|
||||
)
|
||||
|
||||
var noneFlag = types.FlagTypeNone
|
||||
var focusedFlag = types.FlagTypeFocused
|
||||
var pendingFlag = types.FlagTypePending
|
||||
|
||||
var _ = Describe("Spec Runner", func() {
|
||||
var (
|
||||
reporter1 *reporters.FakeReporter
|
||||
reporter2 *reporters.FakeReporter
|
||||
failer *Failer.Failer
|
||||
writer *Writer.FakeGinkgoWriter
|
||||
|
||||
thingsThatRan []string
|
||||
|
||||
runner *SpecRunner
|
||||
)
|
||||
|
||||
newBefSuite := func(text string, fail bool) leafnodes.SuiteNode {
|
||||
return leafnodes.NewBeforeSuiteNode(func() {
|
||||
writer.AddEvent(text)
|
||||
thingsThatRan = append(thingsThatRan, text)
|
||||
if fail {
|
||||
failer.Fail(text, codelocation.New(0))
|
||||
}
|
||||
}, codelocation.New(0), 0, failer)
|
||||
}
|
||||
|
||||
newAftSuite := func(text string, fail bool) leafnodes.SuiteNode {
|
||||
return leafnodes.NewAfterSuiteNode(func() {
|
||||
writer.AddEvent(text)
|
||||
thingsThatRan = append(thingsThatRan, text)
|
||||
if fail {
|
||||
failer.Fail(text, codelocation.New(0))
|
||||
}
|
||||
}, codelocation.New(0), 0, failer)
|
||||
}
|
||||
|
||||
newSpec := func(text string, flag types.FlagType, fail bool) *spec.Spec {
|
||||
subject := leafnodes.NewItNode(text, func() {
|
||||
writer.AddEvent(text)
|
||||
thingsThatRan = append(thingsThatRan, text)
|
||||
if fail {
|
||||
failer.Fail(text, codelocation.New(0))
|
||||
}
|
||||
}, flag, codelocation.New(0), 0, failer, 0)
|
||||
|
||||
return spec.New(subject, []*containernode.ContainerNode{}, false)
|
||||
}
|
||||
|
||||
newFlakySpec := func(text string, flag types.FlagType, failures int) *spec.Spec {
|
||||
runs := 0
|
||||
subject := leafnodes.NewItNode(text, func() {
|
||||
writer.AddEvent(text)
|
||||
thingsThatRan = append(thingsThatRan, text)
|
||||
runs++
|
||||
if runs < failures {
|
||||
failer.Fail(text, codelocation.New(0))
|
||||
}
|
||||
}, flag, codelocation.New(0), 0, failer, 0)
|
||||
|
||||
return spec.New(subject, []*containernode.ContainerNode{}, false)
|
||||
}
|
||||
|
||||
newSpecWithBody := func(text string, body interface{}) *spec.Spec {
|
||||
subject := leafnodes.NewItNode(text, body, noneFlag, codelocation.New(0), 0, failer, 0)
|
||||
|
||||
return spec.New(subject, []*containernode.ContainerNode{}, false)
|
||||
}
|
||||
|
||||
newRunner := func(config config.GinkgoConfigType, beforeSuiteNode leafnodes.SuiteNode, afterSuiteNode leafnodes.SuiteNode, specs ...*spec.Spec) *SpecRunner {
|
||||
iterator := spec_iterator.NewSerialIterator(specs)
|
||||
return New("description", beforeSuiteNode, iterator, afterSuiteNode, []reporters.Reporter{reporter1, reporter2}, writer, config)
|
||||
}
|
||||
|
||||
BeforeEach(func() {
|
||||
reporter1 = reporters.NewFakeReporter()
|
||||
reporter2 = reporters.NewFakeReporter()
|
||||
writer = Writer.NewFake()
|
||||
failer = Failer.New()
|
||||
|
||||
thingsThatRan = []string{}
|
||||
})
|
||||
|
||||
Describe("Running and Reporting", func() {
|
||||
var specA, pendingSpec, anotherPendingSpec, failedSpec, specB, skippedSpec *spec.Spec
|
||||
var willRunCalls, didCompleteCalls []string
|
||||
var conf config.GinkgoConfigType
|
||||
|
||||
JustBeforeEach(func() {
|
||||
willRunCalls = []string{}
|
||||
didCompleteCalls = []string{}
|
||||
specA = newSpec("spec A", noneFlag, false)
|
||||
pendingSpec = newSpec("pending spec", pendingFlag, false)
|
||||
anotherPendingSpec = newSpec("another pending spec", pendingFlag, false)
|
||||
failedSpec = newSpec("failed spec", noneFlag, true)
|
||||
specB = newSpec("spec B", noneFlag, false)
|
||||
skippedSpec = newSpec("skipped spec", noneFlag, false)
|
||||
skippedSpec.Skip()
|
||||
|
||||
reporter1.SpecWillRunStub = func(specSummary *types.SpecSummary) {
|
||||
willRunCalls = append(willRunCalls, "Reporter1")
|
||||
}
|
||||
reporter2.SpecWillRunStub = func(specSummary *types.SpecSummary) {
|
||||
willRunCalls = append(willRunCalls, "Reporter2")
|
||||
}
|
||||
|
||||
reporter1.SpecDidCompleteStub = func(specSummary *types.SpecSummary) {
|
||||
didCompleteCalls = append(didCompleteCalls, "Reporter1")
|
||||
}
|
||||
reporter2.SpecDidCompleteStub = func(specSummary *types.SpecSummary) {
|
||||
didCompleteCalls = append(didCompleteCalls, "Reporter2")
|
||||
}
|
||||
|
||||
runner = newRunner(conf, newBefSuite("BefSuite", false), newAftSuite("AftSuite", false), specA, pendingSpec, anotherPendingSpec, failedSpec, specB, skippedSpec)
|
||||
runner.Run()
|
||||
})
|
||||
|
||||
BeforeEach(func() {
|
||||
conf = config.GinkgoConfigType{RandomSeed: 17}
|
||||
})
|
||||
|
||||
It("should skip skipped/pending tests", func() {
|
||||
Ω(thingsThatRan).Should(Equal([]string{"BefSuite", "spec A", "failed spec", "spec B", "AftSuite"}))
|
||||
})
|
||||
|
||||
It("should report to any attached reporters", func() {
|
||||
Ω(reporter1.Config).Should(Equal(reporter2.Config))
|
||||
Ω(reporter1.BeforeSuiteSummary).Should(Equal(reporter2.BeforeSuiteSummary))
|
||||
Ω(reporter1.BeginSummary).Should(Equal(reporter2.BeginSummary))
|
||||
Ω(reporter1.SpecWillRunSummaries).Should(Equal(reporter2.SpecWillRunSummaries))
|
||||
Ω(reporter1.SpecSummaries).Should(Equal(reporter2.SpecSummaries))
|
||||
Ω(reporter1.AfterSuiteSummary).Should(Equal(reporter2.AfterSuiteSummary))
|
||||
Ω(reporter1.EndSummary).Should(Equal(reporter2.EndSummary))
|
||||
})
|
||||
|
||||
It("should report that a spec did end in reverse order", func() {
|
||||
Ω(willRunCalls[0:4]).Should(Equal([]string{"Reporter1", "Reporter2", "Reporter1", "Reporter2"}))
|
||||
Ω(didCompleteCalls[0:4]).Should(Equal([]string{"Reporter2", "Reporter1", "Reporter2", "Reporter1"}))
|
||||
})
|
||||
|
||||
It("should report the passed in config", func() {
|
||||
Ω(reporter1.Config.RandomSeed).Should(BeNumerically("==", 17))
|
||||
})
|
||||
|
||||
It("should report the beginning of the suite", func() {
|
||||
Ω(reporter1.BeginSummary.SuiteDescription).Should(Equal("description"))
|
||||
Ω(reporter1.BeginSummary.SuiteID).Should(MatchRegexp("[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}"))
|
||||
Ω(reporter1.BeginSummary.NumberOfSpecsBeforeParallelization).Should(Equal(6))
|
||||
Ω(reporter1.BeginSummary.NumberOfTotalSpecs).Should(Equal(6))
|
||||
Ω(reporter1.BeginSummary.NumberOfSpecsThatWillBeRun).Should(Equal(3))
|
||||
Ω(reporter1.BeginSummary.NumberOfPendingSpecs).Should(Equal(-1))
|
||||
Ω(reporter1.BeginSummary.NumberOfSkippedSpecs).Should(Equal(-1))
|
||||
})
|
||||
|
||||
It("should report the end of the suite", func() {
|
||||
Ω(reporter1.EndSummary.SuiteDescription).Should(Equal("description"))
|
||||
Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeFalse())
|
||||
Ω(reporter1.EndSummary.SuiteID).Should(MatchRegexp("[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}"))
|
||||
Ω(reporter1.EndSummary.NumberOfSpecsBeforeParallelization).Should(Equal(6))
|
||||
Ω(reporter1.EndSummary.NumberOfTotalSpecs).Should(Equal(6))
|
||||
Ω(reporter1.EndSummary.NumberOfSpecsThatWillBeRun).Should(Equal(3))
|
||||
Ω(reporter1.EndSummary.NumberOfPendingSpecs).Should(Equal(2))
|
||||
Ω(reporter1.EndSummary.NumberOfSkippedSpecs).Should(Equal(1))
|
||||
Ω(reporter1.EndSummary.NumberOfPassedSpecs).Should(Equal(2))
|
||||
Ω(reporter1.EndSummary.NumberOfFailedSpecs).Should(Equal(1))
|
||||
})
|
||||
|
||||
Context("when told to perform a dry run", func() {
|
||||
BeforeEach(func() {
|
||||
conf.DryRun = true
|
||||
})
|
||||
|
||||
It("should report to the reporters", func() {
|
||||
Ω(reporter1.Config).Should(Equal(reporter2.Config))
|
||||
Ω(reporter1.BeforeSuiteSummary).Should(Equal(reporter2.BeforeSuiteSummary))
|
||||
Ω(reporter1.BeginSummary).Should(Equal(reporter2.BeginSummary))
|
||||
Ω(reporter1.SpecWillRunSummaries).Should(Equal(reporter2.SpecWillRunSummaries))
|
||||
Ω(reporter1.SpecSummaries).Should(Equal(reporter2.SpecSummaries))
|
||||
Ω(reporter1.AfterSuiteSummary).Should(Equal(reporter2.AfterSuiteSummary))
|
||||
Ω(reporter1.EndSummary).Should(Equal(reporter2.EndSummary))
|
||||
})
|
||||
|
||||
It("should not actually run anything", func() {
|
||||
Ω(thingsThatRan).Should(BeEmpty())
|
||||
})
|
||||
|
||||
It("report before and after suites as passed", func() {
|
||||
Ω(reporter1.BeforeSuiteSummary.State).Should(Equal(types.SpecStatePassed))
|
||||
Ω(reporter1.AfterSuiteSummary.State).Should(Equal(types.SpecStatePassed))
|
||||
})
|
||||
|
||||
It("should report specs as passed", func() {
|
||||
summaries := reporter1.SpecSummaries
|
||||
Ω(summaries).Should(HaveLen(6))
|
||||
Ω(summaries[0].ComponentTexts).Should(ContainElement("spec A"))
|
||||
Ω(summaries[0].State).Should(Equal(types.SpecStatePassed))
|
||||
Ω(summaries[1].ComponentTexts).Should(ContainElement("pending spec"))
|
||||
Ω(summaries[1].State).Should(Equal(types.SpecStatePending))
|
||||
Ω(summaries[2].ComponentTexts).Should(ContainElement("another pending spec"))
|
||||
Ω(summaries[2].State).Should(Equal(types.SpecStatePending))
|
||||
Ω(summaries[3].ComponentTexts).Should(ContainElement("failed spec"))
|
||||
Ω(summaries[3].State).Should(Equal(types.SpecStatePassed))
|
||||
Ω(summaries[4].ComponentTexts).Should(ContainElement("spec B"))
|
||||
Ω(summaries[4].State).Should(Equal(types.SpecStatePassed))
|
||||
Ω(summaries[5].ComponentTexts).Should(ContainElement("skipped spec"))
|
||||
Ω(summaries[5].State).Should(Equal(types.SpecStateSkipped))
|
||||
})
|
||||
|
||||
It("should report the end of the suite", func() {
|
||||
Ω(reporter1.EndSummary.SuiteDescription).Should(Equal("description"))
|
||||
Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeTrue())
|
||||
Ω(reporter1.EndSummary.SuiteID).Should(MatchRegexp("[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}"))
|
||||
Ω(reporter1.EndSummary.NumberOfSpecsBeforeParallelization).Should(Equal(6))
|
||||
Ω(reporter1.EndSummary.NumberOfTotalSpecs).Should(Equal(6))
|
||||
Ω(reporter1.EndSummary.NumberOfSpecsThatWillBeRun).Should(Equal(3))
|
||||
Ω(reporter1.EndSummary.NumberOfPendingSpecs).Should(Equal(2))
|
||||
Ω(reporter1.EndSummary.NumberOfSkippedSpecs).Should(Equal(1))
|
||||
Ω(reporter1.EndSummary.NumberOfPassedSpecs).Should(Equal(0))
|
||||
Ω(reporter1.EndSummary.NumberOfFailedSpecs).Should(Equal(0))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("reporting on specs", func() {
|
||||
var proceed chan bool
|
||||
var ready chan bool
|
||||
var finished chan bool
|
||||
BeforeEach(func() {
|
||||
ready = make(chan bool)
|
||||
proceed = make(chan bool)
|
||||
finished = make(chan bool)
|
||||
skippedSpec := newSpec("SKIP", noneFlag, false)
|
||||
skippedSpec.Skip()
|
||||
|
||||
runner = newRunner(
|
||||
config.GinkgoConfigType{},
|
||||
newBefSuite("BefSuite", false),
|
||||
newAftSuite("AftSuite", false),
|
||||
skippedSpec,
|
||||
newSpec("PENDING", pendingFlag, false),
|
||||
newSpecWithBody("RUN", func() {
|
||||
close(ready)
|
||||
<-proceed
|
||||
}),
|
||||
)
|
||||
go func() {
|
||||
runner.Run()
|
||||
close(finished)
|
||||
}()
|
||||
})
|
||||
|
||||
It("should report about pending/skipped specs", func() {
|
||||
<-ready
|
||||
Ω(reporter1.SpecWillRunSummaries).Should(HaveLen(3))
|
||||
|
||||
Ω(reporter1.SpecWillRunSummaries[0].ComponentTexts[0]).Should(Equal("SKIP"))
|
||||
Ω(reporter1.SpecWillRunSummaries[1].ComponentTexts[0]).Should(Equal("PENDING"))
|
||||
Ω(reporter1.SpecWillRunSummaries[2].ComponentTexts[0]).Should(Equal("RUN"))
|
||||
|
||||
Ω(reporter1.SpecSummaries[0].ComponentTexts[0]).Should(Equal("SKIP"))
|
||||
Ω(reporter1.SpecSummaries[1].ComponentTexts[0]).Should(Equal("PENDING"))
|
||||
Ω(reporter1.SpecSummaries).Should(HaveLen(2))
|
||||
|
||||
close(proceed)
|
||||
<-finished
|
||||
|
||||
Ω(reporter1.SpecSummaries).Should(HaveLen(3))
|
||||
Ω(reporter1.SpecSummaries[2].ComponentTexts[0]).Should(Equal("RUN"))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Running and Reporting when there's flakes", func() {
|
||||
var specA, pendingSpec, flakySpec, failedSpec, specB, skippedSpec *spec.Spec
|
||||
var willRunCalls, didCompleteCalls []string
|
||||
var conf config.GinkgoConfigType
|
||||
var failedSpecFlag = noneFlag
|
||||
|
||||
JustBeforeEach(func() {
|
||||
willRunCalls = []string{}
|
||||
didCompleteCalls = []string{}
|
||||
specA = newSpec("spec A", noneFlag, false)
|
||||
pendingSpec = newSpec("pending spec", pendingFlag, false)
|
||||
flakySpec = newFlakySpec("flaky spec", noneFlag, 3)
|
||||
failedSpec = newSpec("failed spec", failedSpecFlag, true)
|
||||
specB = newSpec("spec B", noneFlag, false)
|
||||
skippedSpec = newSpec("skipped spec", noneFlag, false)
|
||||
skippedSpec.Skip()
|
||||
|
||||
reporter1.SpecWillRunStub = func(specSummary *types.SpecSummary) {
|
||||
willRunCalls = append(willRunCalls, "Reporter1")
|
||||
}
|
||||
reporter2.SpecWillRunStub = func(specSummary *types.SpecSummary) {
|
||||
willRunCalls = append(willRunCalls, "Reporter2")
|
||||
}
|
||||
|
||||
reporter1.SpecDidCompleteStub = func(specSummary *types.SpecSummary) {
|
||||
didCompleteCalls = append(didCompleteCalls, "Reporter1")
|
||||
}
|
||||
reporter2.SpecDidCompleteStub = func(specSummary *types.SpecSummary) {
|
||||
didCompleteCalls = append(didCompleteCalls, "Reporter2")
|
||||
}
|
||||
|
||||
runner = newRunner(conf, newBefSuite("BefSuite", false), newAftSuite("AftSuite", false), specA, pendingSpec, flakySpec, failedSpec, specB, skippedSpec)
|
||||
runner.Run()
|
||||
})
|
||||
|
||||
BeforeEach(func() {
|
||||
failedSpecFlag = noneFlag
|
||||
conf = config.GinkgoConfigType{
|
||||
RandomSeed: 17,
|
||||
FlakeAttempts: 5,
|
||||
}
|
||||
})
|
||||
|
||||
It("should skip skipped/pending tests", func() {
|
||||
Ω(thingsThatRan).Should(Equal([]string{"BefSuite", "spec A", "flaky spec", "flaky spec", "flaky spec", "failed spec", "failed spec", "failed spec", "failed spec", "failed spec", "spec B", "AftSuite"}))
|
||||
})
|
||||
|
||||
It("should report to any attached reporters", func() {
|
||||
Ω(reporter1.Config).Should(Equal(reporter2.Config))
|
||||
Ω(reporter1.BeforeSuiteSummary).Should(Equal(reporter2.BeforeSuiteSummary))
|
||||
Ω(reporter1.BeginSummary).Should(Equal(reporter2.BeginSummary))
|
||||
Ω(reporter1.SpecWillRunSummaries).Should(Equal(reporter2.SpecWillRunSummaries))
|
||||
Ω(reporter1.SpecSummaries).Should(Equal(reporter2.SpecSummaries))
|
||||
Ω(reporter1.AfterSuiteSummary).Should(Equal(reporter2.AfterSuiteSummary))
|
||||
Ω(reporter1.EndSummary).Should(Equal(reporter2.EndSummary))
|
||||
})
|
||||
|
||||
It("should report that a spec did end in reverse order", func() {
|
||||
Ω(willRunCalls[0:4]).Should(Equal([]string{"Reporter1", "Reporter2", "Reporter1", "Reporter2"}))
|
||||
Ω(didCompleteCalls[0:4]).Should(Equal([]string{"Reporter2", "Reporter1", "Reporter2", "Reporter1"}))
|
||||
})
|
||||
|
||||
It("should report the passed in config", func() {
|
||||
Ω(reporter1.Config.RandomSeed).Should(BeNumerically("==", 17))
|
||||
})
|
||||
|
||||
It("should report the beginning of the suite", func() {
|
||||
Ω(reporter1.BeginSummary.SuiteDescription).Should(Equal("description"))
|
||||
Ω(reporter1.BeginSummary.SuiteID).Should(MatchRegexp("[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}"))
|
||||
Ω(reporter1.BeginSummary.NumberOfSpecsBeforeParallelization).Should(Equal(6))
|
||||
Ω(reporter1.BeginSummary.NumberOfTotalSpecs).Should(Equal(6))
|
||||
Ω(reporter1.BeginSummary.NumberOfSpecsThatWillBeRun).Should(Equal(4))
|
||||
Ω(reporter1.BeginSummary.NumberOfPendingSpecs).Should(Equal(-1))
|
||||
Ω(reporter1.BeginSummary.NumberOfSkippedSpecs).Should(Equal(-1))
|
||||
})
|
||||
|
||||
It("should report the end of the suite", func() {
|
||||
Ω(reporter1.EndSummary.SuiteDescription).Should(Equal("description"))
|
||||
Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeFalse())
|
||||
Ω(reporter1.EndSummary.SuiteID).Should(MatchRegexp("[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}"))
|
||||
Ω(reporter1.EndSummary.NumberOfSpecsBeforeParallelization).Should(Equal(6))
|
||||
Ω(reporter1.EndSummary.NumberOfTotalSpecs).Should(Equal(6))
|
||||
Ω(reporter1.EndSummary.NumberOfSpecsThatWillBeRun).Should(Equal(4))
|
||||
Ω(reporter1.EndSummary.NumberOfPendingSpecs).Should(Equal(1))
|
||||
Ω(reporter1.EndSummary.NumberOfSkippedSpecs).Should(Equal(1))
|
||||
Ω(reporter1.EndSummary.NumberOfPassedSpecs).Should(Equal(3))
|
||||
Ω(reporter1.EndSummary.NumberOfFailedSpecs).Should(Equal(1))
|
||||
Ω(reporter1.EndSummary.NumberOfFlakedSpecs).Should(Equal(1))
|
||||
})
|
||||
|
||||
Context("when nothing fails", func() {
|
||||
BeforeEach(func() {
|
||||
failedSpecFlag = pendingFlag
|
||||
})
|
||||
|
||||
It("the suite should pass even with flakes", func() {
|
||||
Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeTrue())
|
||||
Ω(reporter1.EndSummary.NumberOfFlakedSpecs).Should(Equal(1))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when told to perform a dry run", func() {
|
||||
BeforeEach(func() {
|
||||
conf.DryRun = true
|
||||
})
|
||||
|
||||
It("should report to the reporters", func() {
|
||||
Ω(reporter1.Config).Should(Equal(reporter2.Config))
|
||||
Ω(reporter1.BeforeSuiteSummary).Should(Equal(reporter2.BeforeSuiteSummary))
|
||||
Ω(reporter1.BeginSummary).Should(Equal(reporter2.BeginSummary))
|
||||
Ω(reporter1.SpecWillRunSummaries).Should(Equal(reporter2.SpecWillRunSummaries))
|
||||
Ω(reporter1.SpecSummaries).Should(Equal(reporter2.SpecSummaries))
|
||||
Ω(reporter1.AfterSuiteSummary).Should(Equal(reporter2.AfterSuiteSummary))
|
||||
Ω(reporter1.EndSummary).Should(Equal(reporter2.EndSummary))
|
||||
})
|
||||
|
||||
It("should not actually run anything", func() {
|
||||
Ω(thingsThatRan).Should(BeEmpty())
|
||||
})
|
||||
|
||||
It("report before and after suites as passed", func() {
|
||||
Ω(reporter1.BeforeSuiteSummary.State).Should(Equal(types.SpecStatePassed))
|
||||
Ω(reporter1.AfterSuiteSummary.State).Should(Equal(types.SpecStatePassed))
|
||||
})
|
||||
|
||||
It("should report specs as passed", func() {
|
||||
summaries := reporter1.SpecSummaries
|
||||
Ω(summaries).Should(HaveLen(6))
|
||||
Ω(summaries[0].ComponentTexts).Should(ContainElement("spec A"))
|
||||
Ω(summaries[0].State).Should(Equal(types.SpecStatePassed))
|
||||
Ω(summaries[1].ComponentTexts).Should(ContainElement("pending spec"))
|
||||
Ω(summaries[1].State).Should(Equal(types.SpecStatePending))
|
||||
Ω(summaries[2].ComponentTexts).Should(ContainElement("flaky spec"))
|
||||
Ω(summaries[2].State).Should(Equal(types.SpecStatePassed))
|
||||
Ω(summaries[3].ComponentTexts).Should(ContainElement("failed spec"))
|
||||
Ω(summaries[3].State).Should(Equal(types.SpecStatePassed))
|
||||
Ω(summaries[4].ComponentTexts).Should(ContainElement("spec B"))
|
||||
Ω(summaries[4].State).Should(Equal(types.SpecStatePassed))
|
||||
Ω(summaries[5].ComponentTexts).Should(ContainElement("skipped spec"))
|
||||
Ω(summaries[5].State).Should(Equal(types.SpecStateSkipped))
|
||||
})
|
||||
|
||||
It("should report the end of the suite", func() {
|
||||
Ω(reporter1.EndSummary.SuiteDescription).Should(Equal("description"))
|
||||
Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeTrue())
|
||||
Ω(reporter1.EndSummary.SuiteID).Should(MatchRegexp("[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}"))
|
||||
Ω(reporter1.EndSummary.NumberOfSpecsBeforeParallelization).Should(Equal(6))
|
||||
Ω(reporter1.EndSummary.NumberOfTotalSpecs).Should(Equal(6))
|
||||
Ω(reporter1.EndSummary.NumberOfSpecsThatWillBeRun).Should(Equal(4))
|
||||
Ω(reporter1.EndSummary.NumberOfPendingSpecs).Should(Equal(1))
|
||||
Ω(reporter1.EndSummary.NumberOfSkippedSpecs).Should(Equal(1))
|
||||
Ω(reporter1.EndSummary.NumberOfPassedSpecs).Should(Equal(0))
|
||||
Ω(reporter1.EndSummary.NumberOfFailedSpecs).Should(Equal(0))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Running BeforeSuite & AfterSuite", func() {
|
||||
var success bool
|
||||
var befSuite leafnodes.SuiteNode
|
||||
var aftSuite leafnodes.SuiteNode
|
||||
Context("with a nil BeforeSuite & AfterSuite", func() {
|
||||
BeforeEach(func() {
|
||||
runner = newRunner(
|
||||
config.GinkgoConfigType{},
|
||||
nil,
|
||||
nil,
|
||||
newSpec("A", noneFlag, false),
|
||||
newSpec("B", noneFlag, false),
|
||||
)
|
||||
success = runner.Run()
|
||||
})
|
||||
|
||||
It("should not report about the BeforeSuite", func() {
|
||||
Ω(reporter1.BeforeSuiteSummary).Should(BeNil())
|
||||
})
|
||||
|
||||
It("should not report about the AfterSuite", func() {
|
||||
Ω(reporter1.AfterSuiteSummary).Should(BeNil())
|
||||
})
|
||||
|
||||
It("should run the specs", func() {
|
||||
Ω(thingsThatRan).Should(Equal([]string{"A", "B"}))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the BeforeSuite & AfterSuite pass", func() {
|
||||
BeforeEach(func() {
|
||||
befSuite = newBefSuite("BefSuite", false)
|
||||
aftSuite = newBefSuite("AftSuite", false)
|
||||
runner = newRunner(
|
||||
config.GinkgoConfigType{},
|
||||
befSuite,
|
||||
aftSuite,
|
||||
newSpec("A", noneFlag, false),
|
||||
newSpec("B", noneFlag, false),
|
||||
)
|
||||
success = runner.Run()
|
||||
})
|
||||
|
||||
It("should run the BeforeSuite, the AfterSuite and the specs", func() {
|
||||
Ω(thingsThatRan).Should(Equal([]string{"BefSuite", "A", "B", "AftSuite"}))
|
||||
})
|
||||
|
||||
It("should report about the BeforeSuite", func() {
|
||||
Ω(reporter1.BeforeSuiteSummary).Should(Equal(befSuite.Summary()))
|
||||
})
|
||||
|
||||
It("should report about the AfterSuite", func() {
|
||||
Ω(reporter1.AfterSuiteSummary).Should(Equal(aftSuite.Summary()))
|
||||
})
|
||||
|
||||
It("should report success", func() {
|
||||
Ω(success).Should(BeTrue())
|
||||
Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeTrue())
|
||||
Ω(reporter1.EndSummary.NumberOfFailedSpecs).Should(Equal(0))
|
||||
})
|
||||
|
||||
It("should not dump the writer", func() {
|
||||
Ω(writer.EventStream).ShouldNot(ContainElement("DUMP"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the BeforeSuite fails", func() {
|
||||
BeforeEach(func() {
|
||||
befSuite = newBefSuite("BefSuite", true)
|
||||
aftSuite = newBefSuite("AftSuite", false)
|
||||
|
||||
skipped := newSpec("Skipped", noneFlag, false)
|
||||
skipped.Skip()
|
||||
|
||||
runner = newRunner(
|
||||
config.GinkgoConfigType{},
|
||||
befSuite,
|
||||
aftSuite,
|
||||
newSpec("A", noneFlag, false),
|
||||
newSpec("B", noneFlag, false),
|
||||
newSpec("Pending", pendingFlag, false),
|
||||
skipped,
|
||||
)
|
||||
success = runner.Run()
|
||||
})
|
||||
|
||||
It("should not run the specs, but it should run the AfterSuite", func() {
|
||||
Ω(thingsThatRan).Should(Equal([]string{"BefSuite", "AftSuite"}))
|
||||
})
|
||||
|
||||
It("should report about the BeforeSuite", func() {
|
||||
Ω(reporter1.BeforeSuiteSummary).Should(Equal(befSuite.Summary()))
|
||||
})
|
||||
|
||||
It("should report about the AfterSuite", func() {
|
||||
Ω(reporter1.AfterSuiteSummary).Should(Equal(aftSuite.Summary()))
|
||||
})
|
||||
|
||||
It("should report failure", func() {
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeFalse())
|
||||
Ω(reporter1.EndSummary.NumberOfFailedSpecs).Should(Equal(2))
|
||||
Ω(reporter1.EndSummary.NumberOfSpecsThatWillBeRun).Should(Equal(2))
|
||||
})
|
||||
|
||||
It("should dump the writer", func() {
|
||||
Ω(writer.EventStream).Should(ContainElement("DUMP"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when some other test fails", func() {
|
||||
BeforeEach(func() {
|
||||
aftSuite = newBefSuite("AftSuite", false)
|
||||
|
||||
runner = newRunner(
|
||||
config.GinkgoConfigType{},
|
||||
nil,
|
||||
aftSuite,
|
||||
newSpec("A", noneFlag, true),
|
||||
)
|
||||
success = runner.Run()
|
||||
})
|
||||
|
||||
It("should still run the AfterSuite", func() {
|
||||
Ω(thingsThatRan).Should(Equal([]string{"A", "AftSuite"}))
|
||||
})
|
||||
|
||||
It("should report about the AfterSuite", func() {
|
||||
Ω(reporter1.AfterSuiteSummary).Should(Equal(aftSuite.Summary()))
|
||||
})
|
||||
|
||||
It("should report failure", func() {
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeFalse())
|
||||
Ω(reporter1.EndSummary.NumberOfFailedSpecs).Should(Equal(1))
|
||||
Ω(reporter1.EndSummary.NumberOfSpecsThatWillBeRun).Should(Equal(1))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the AfterSuite fails", func() {
|
||||
BeforeEach(func() {
|
||||
befSuite = newBefSuite("BefSuite", false)
|
||||
aftSuite = newBefSuite("AftSuite", true)
|
||||
runner = newRunner(
|
||||
config.GinkgoConfigType{},
|
||||
befSuite,
|
||||
aftSuite,
|
||||
newSpec("A", noneFlag, false),
|
||||
newSpec("B", noneFlag, false),
|
||||
)
|
||||
success = runner.Run()
|
||||
})
|
||||
|
||||
It("should run everything", func() {
|
||||
Ω(thingsThatRan).Should(Equal([]string{"BefSuite", "A", "B", "AftSuite"}))
|
||||
})
|
||||
|
||||
It("should report about the BeforeSuite", func() {
|
||||
Ω(reporter1.BeforeSuiteSummary).Should(Equal(befSuite.Summary()))
|
||||
})
|
||||
|
||||
It("should report about the AfterSuite", func() {
|
||||
Ω(reporter1.AfterSuiteSummary).Should(Equal(aftSuite.Summary()))
|
||||
})
|
||||
|
||||
It("should report failure", func() {
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeFalse())
|
||||
Ω(reporter1.EndSummary.NumberOfFailedSpecs).Should(Equal(0))
|
||||
})
|
||||
|
||||
It("should dump the writer", func() {
|
||||
Ω(writer.EventStream).Should(ContainElement("DUMP"))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("When instructed to fail fast", func() {
|
||||
BeforeEach(func() {
|
||||
conf := config.GinkgoConfigType{
|
||||
FailFast: true,
|
||||
}
|
||||
runner = newRunner(conf, nil, newAftSuite("after-suite", false), newSpec("passing", noneFlag, false), newSpec("failing", noneFlag, true), newSpec("dont-see", noneFlag, true), newSpec("dont-see", noneFlag, true))
|
||||
})
|
||||
|
||||
It("should return false, report failure, and not run anything past the failing test", func() {
|
||||
Ω(runner.Run()).Should(BeFalse())
|
||||
Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeFalse())
|
||||
Ω(thingsThatRan).Should(Equal([]string{"passing", "failing", "after-suite"}))
|
||||
})
|
||||
|
||||
It("should announce the subsequent specs as skipped", func() {
|
||||
runner.Run()
|
||||
Ω(reporter1.SpecSummaries).Should(HaveLen(4))
|
||||
Ω(reporter1.SpecSummaries[2].State).Should(Equal(types.SpecStateSkipped))
|
||||
Ω(reporter1.SpecSummaries[3].State).Should(Equal(types.SpecStateSkipped))
|
||||
})
|
||||
|
||||
It("should mark all subsequent specs as skipped", func() {
|
||||
runner.Run()
|
||||
Ω(reporter1.EndSummary.NumberOfSkippedSpecs).Should(Equal(2))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Marking failure and success", func() {
|
||||
Context("when all tests pass", func() {
|
||||
BeforeEach(func() {
|
||||
runner = newRunner(config.GinkgoConfigType{}, nil, nil, newSpec("passing", noneFlag, false), newSpec("pending", pendingFlag, false))
|
||||
})
|
||||
|
||||
It("should return true and report success", func() {
|
||||
Ω(runner.Run()).Should(BeTrue())
|
||||
Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a test fails", func() {
|
||||
BeforeEach(func() {
|
||||
runner = newRunner(config.GinkgoConfigType{}, nil, nil, newSpec("failing", noneFlag, true), newSpec("pending", pendingFlag, false))
|
||||
})
|
||||
|
||||
It("should return false and report failure", func() {
|
||||
Ω(runner.Run()).Should(BeFalse())
|
||||
Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when there is a pending test, but pendings count as failures", func() {
|
||||
BeforeEach(func() {
|
||||
runner = newRunner(config.GinkgoConfigType{FailOnPending: true}, nil, nil, newSpec("passing", noneFlag, false), newSpec("pending", pendingFlag, false))
|
||||
})
|
||||
|
||||
It("should return false and report failure", func() {
|
||||
Ω(runner.Run()).Should(BeFalse())
|
||||
Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Managing the writer", func() {
|
||||
BeforeEach(func() {
|
||||
runner = newRunner(
|
||||
config.GinkgoConfigType{},
|
||||
nil,
|
||||
nil,
|
||||
newSpec("A", noneFlag, false),
|
||||
newSpec("B", noneFlag, true),
|
||||
newSpec("C", noneFlag, false),
|
||||
)
|
||||
reporter1.SpecWillRunStub = func(specSummary *types.SpecSummary) {
|
||||
writer.AddEvent("R1.WillRun")
|
||||
}
|
||||
reporter2.SpecWillRunStub = func(specSummary *types.SpecSummary) {
|
||||
writer.AddEvent("R2.WillRun")
|
||||
}
|
||||
reporter1.SpecDidCompleteStub = func(specSummary *types.SpecSummary) {
|
||||
writer.AddEvent("R1.DidComplete")
|
||||
}
|
||||
reporter2.SpecDidCompleteStub = func(specSummary *types.SpecSummary) {
|
||||
writer.AddEvent("R2.DidComplete")
|
||||
}
|
||||
runner.Run()
|
||||
})
|
||||
|
||||
It("should truncate between tests, but only dump if a test fails", func() {
|
||||
Ω(writer.EventStream).Should(Equal([]string{
|
||||
"TRUNCATE",
|
||||
"R1.WillRun",
|
||||
"R2.WillRun",
|
||||
"A",
|
||||
"R2.DidComplete",
|
||||
"R1.DidComplete",
|
||||
"TRUNCATE",
|
||||
"R1.WillRun",
|
||||
"R2.WillRun",
|
||||
"B",
|
||||
"BYTES",
|
||||
"R2.DidComplete",
|
||||
"DUMP",
|
||||
"R1.DidComplete",
|
||||
"TRUNCATE",
|
||||
"R1.WillRun",
|
||||
"R2.WillRun",
|
||||
"C",
|
||||
"R2.DidComplete",
|
||||
"R1.DidComplete",
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("CurrentSpecSummary", func() {
|
||||
It("should return the spec summary for the currently running spec", func() {
|
||||
var summary *types.SpecSummary
|
||||
runner = newRunner(
|
||||
config.GinkgoConfigType{},
|
||||
nil,
|
||||
nil,
|
||||
newSpec("A", noneFlag, false),
|
||||
newSpecWithBody("B", func() {
|
||||
var ok bool
|
||||
summary, ok = runner.CurrentSpecSummary()
|
||||
Ω(ok).Should(BeTrue())
|
||||
}),
|
||||
newSpec("C", noneFlag, false),
|
||||
)
|
||||
runner.Run()
|
||||
|
||||
Ω(summary.ComponentTexts).Should(Equal([]string{"B"}))
|
||||
|
||||
summary, ok := runner.CurrentSpecSummary()
|
||||
Ω(summary).Should(BeNil())
|
||||
Ω(ok).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
|
||||
Describe("generating a suite id", func() {
|
||||
It("should generate an id randomly", func() {
|
||||
runnerA := newRunner(config.GinkgoConfigType{}, nil, nil)
|
||||
runnerA.Run()
|
||||
IDA := reporter1.BeginSummary.SuiteID
|
||||
|
||||
runnerB := newRunner(config.GinkgoConfigType{}, nil, nil)
|
||||
runnerB.Run()
|
||||
IDB := reporter1.BeginSummary.SuiteID
|
||||
|
||||
IDRegexp := "[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}"
|
||||
Ω(IDA).Should(MatchRegexp(IDRegexp))
|
||||
Ω(IDB).Should(MatchRegexp(IDRegexp))
|
||||
|
||||
Ω(IDA).ShouldNot(Equal(IDB))
|
||||
})
|
||||
})
|
||||
})
|
||||
10
vendor/github.com/onsi/ginkgo/internal/suite/suite.go
generated
vendored
10
vendor/github.com/onsi/ginkgo/internal/suite/suite.go
generated
vendored
|
|
@ -149,35 +149,35 @@ func (suite *Suite) PushContainerNode(text string, body func(), flag types.FlagT
|
|||
|
||||
func (suite *Suite) PushItNode(text string, body interface{}, flag types.FlagType, codeLocation types.CodeLocation, timeout time.Duration) {
|
||||
if suite.running {
|
||||
suite.failer.Fail("You may only call It from within a Describe or Context", codeLocation)
|
||||
suite.failer.Fail("You may only call It from within a Describe, Context or When", codeLocation)
|
||||
}
|
||||
suite.currentContainer.PushSubjectNode(leafnodes.NewItNode(text, body, flag, codeLocation, timeout, suite.failer, suite.containerIndex))
|
||||
}
|
||||
|
||||
func (suite *Suite) PushMeasureNode(text string, body interface{}, flag types.FlagType, codeLocation types.CodeLocation, samples int) {
|
||||
if suite.running {
|
||||
suite.failer.Fail("You may only call Measure from within a Describe or Context", codeLocation)
|
||||
suite.failer.Fail("You may only call Measure from within a Describe, Context or When", codeLocation)
|
||||
}
|
||||
suite.currentContainer.PushSubjectNode(leafnodes.NewMeasureNode(text, body, flag, codeLocation, samples, suite.failer, suite.containerIndex))
|
||||
}
|
||||
|
||||
func (suite *Suite) PushBeforeEachNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration) {
|
||||
if suite.running {
|
||||
suite.failer.Fail("You may only call BeforeEach from within a Describe or Context", codeLocation)
|
||||
suite.failer.Fail("You may only call BeforeEach from within a Describe, Context or When", codeLocation)
|
||||
}
|
||||
suite.currentContainer.PushSetupNode(leafnodes.NewBeforeEachNode(body, codeLocation, timeout, suite.failer, suite.containerIndex))
|
||||
}
|
||||
|
||||
func (suite *Suite) PushJustBeforeEachNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration) {
|
||||
if suite.running {
|
||||
suite.failer.Fail("You may only call JustBeforeEach from within a Describe or Context", codeLocation)
|
||||
suite.failer.Fail("You may only call JustBeforeEach from within a Describe, Context or When", codeLocation)
|
||||
}
|
||||
suite.currentContainer.PushSetupNode(leafnodes.NewJustBeforeEachNode(body, codeLocation, timeout, suite.failer, suite.containerIndex))
|
||||
}
|
||||
|
||||
func (suite *Suite) PushAfterEachNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration) {
|
||||
if suite.running {
|
||||
suite.failer.Fail("You may only call AfterEach from within a Describe or Context", codeLocation)
|
||||
suite.failer.Fail("You may only call AfterEach from within a Describe, Context or When", codeLocation)
|
||||
}
|
||||
suite.currentContainer.PushSetupNode(leafnodes.NewAfterEachNode(body, codeLocation, timeout, suite.failer, suite.containerIndex))
|
||||
}
|
||||
|
|
|
|||
35
vendor/github.com/onsi/ginkgo/internal/suite/suite_suite_test.go
generated
vendored
35
vendor/github.com/onsi/ginkgo/internal/suite/suite_suite_test.go
generated
vendored
|
|
@ -1,35 +0,0 @@
|
|||
package suite_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Suite")
|
||||
}
|
||||
|
||||
var numBeforeSuiteRuns = 0
|
||||
var numAfterSuiteRuns = 0
|
||||
|
||||
var _ = BeforeSuite(func() {
|
||||
numBeforeSuiteRuns++
|
||||
})
|
||||
|
||||
var _ = AfterSuite(func() {
|
||||
numAfterSuiteRuns++
|
||||
Ω(numBeforeSuiteRuns).Should(Equal(1))
|
||||
Ω(numAfterSuiteRuns).Should(Equal(1))
|
||||
})
|
||||
|
||||
//Fakes
|
||||
type fakeTestingT struct {
|
||||
didFail bool
|
||||
}
|
||||
|
||||
func (fakeT *fakeTestingT) Fail() {
|
||||
fakeT.didFail = true
|
||||
}
|
||||
371
vendor/github.com/onsi/ginkgo/internal/suite/suite_test.go
generated
vendored
371
vendor/github.com/onsi/ginkgo/internal/suite/suite_test.go
generated
vendored
|
|
@ -1,371 +0,0 @@
|
|||
package suite_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/internal/suite"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo/config"
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
Failer "github.com/onsi/ginkgo/internal/failer"
|
||||
Writer "github.com/onsi/ginkgo/internal/writer"
|
||||
"github.com/onsi/ginkgo/reporters"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
)
|
||||
|
||||
var _ = Describe("Suite", func() {
|
||||
var (
|
||||
specSuite *Suite
|
||||
fakeT *fakeTestingT
|
||||
fakeR *reporters.FakeReporter
|
||||
writer *Writer.FakeGinkgoWriter
|
||||
failer *Failer.Failer
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
writer = Writer.NewFake()
|
||||
fakeT = &fakeTestingT{}
|
||||
fakeR = reporters.NewFakeReporter()
|
||||
failer = Failer.New()
|
||||
specSuite = New(failer)
|
||||
})
|
||||
|
||||
Describe("running a suite", func() {
|
||||
var (
|
||||
runOrder []string
|
||||
randomizeAllSpecs bool
|
||||
randomSeed int64
|
||||
focusString string
|
||||
parallelNode int
|
||||
parallelTotal int
|
||||
runResult bool
|
||||
hasProgrammaticFocus bool
|
||||
)
|
||||
|
||||
var f = func(runText string) func() {
|
||||
return func() {
|
||||
runOrder = append(runOrder, runText)
|
||||
}
|
||||
}
|
||||
|
||||
BeforeEach(func() {
|
||||
randomizeAllSpecs = false
|
||||
randomSeed = 11
|
||||
parallelNode = 1
|
||||
parallelTotal = 1
|
||||
focusString = ""
|
||||
|
||||
runOrder = make([]string, 0)
|
||||
specSuite.SetBeforeSuiteNode(f("BeforeSuite"), codelocation.New(0), 0)
|
||||
specSuite.PushBeforeEachNode(f("top BE"), codelocation.New(0), 0)
|
||||
specSuite.PushJustBeforeEachNode(f("top JBE"), codelocation.New(0), 0)
|
||||
specSuite.PushAfterEachNode(f("top AE"), codelocation.New(0), 0)
|
||||
|
||||
specSuite.PushContainerNode("container", func() {
|
||||
specSuite.PushBeforeEachNode(f("BE"), codelocation.New(0), 0)
|
||||
specSuite.PushJustBeforeEachNode(f("JBE"), codelocation.New(0), 0)
|
||||
specSuite.PushAfterEachNode(f("AE"), codelocation.New(0), 0)
|
||||
specSuite.PushItNode("it", f("IT"), types.FlagTypeNone, codelocation.New(0), 0)
|
||||
|
||||
specSuite.PushContainerNode("inner container", func() {
|
||||
specSuite.PushItNode("inner it", f("inner IT"), types.FlagTypeNone, codelocation.New(0), 0)
|
||||
}, types.FlagTypeNone, codelocation.New(0))
|
||||
}, types.FlagTypeNone, codelocation.New(0))
|
||||
|
||||
specSuite.PushContainerNode("container 2", func() {
|
||||
specSuite.PushBeforeEachNode(f("BE 2"), codelocation.New(0), 0)
|
||||
specSuite.PushItNode("it 2", f("IT 2"), types.FlagTypeNone, codelocation.New(0), 0)
|
||||
}, types.FlagTypeNone, codelocation.New(0))
|
||||
|
||||
specSuite.PushItNode("top level it", f("top IT"), types.FlagTypeNone, codelocation.New(0), 0)
|
||||
|
||||
specSuite.SetAfterSuiteNode(f("AfterSuite"), codelocation.New(0), 0)
|
||||
})
|
||||
|
||||
JustBeforeEach(func() {
|
||||
runResult, hasProgrammaticFocus = specSuite.Run(fakeT, "suite description", []reporters.Reporter{fakeR}, writer, config.GinkgoConfigType{
|
||||
RandomSeed: randomSeed,
|
||||
RandomizeAllSpecs: randomizeAllSpecs,
|
||||
FocusString: focusString,
|
||||
ParallelNode: parallelNode,
|
||||
ParallelTotal: parallelTotal,
|
||||
})
|
||||
})
|
||||
|
||||
It("provides the config and suite description to the reporter", func() {
|
||||
Ω(fakeR.Config.RandomSeed).Should(Equal(int64(randomSeed)))
|
||||
Ω(fakeR.Config.RandomizeAllSpecs).Should(Equal(randomizeAllSpecs))
|
||||
Ω(fakeR.BeginSummary.SuiteDescription).Should(Equal("suite description"))
|
||||
})
|
||||
|
||||
It("reports that the BeforeSuite node ran", func() {
|
||||
Ω(fakeR.BeforeSuiteSummary).ShouldNot(BeNil())
|
||||
})
|
||||
|
||||
It("reports that the AfterSuite node ran", func() {
|
||||
Ω(fakeR.AfterSuiteSummary).ShouldNot(BeNil())
|
||||
})
|
||||
|
||||
It("provides information about the current test", func() {
|
||||
description := CurrentGinkgoTestDescription()
|
||||
Ω(description.ComponentTexts).Should(Equal([]string{"Suite", "running a suite", "provides information about the current test"}))
|
||||
Ω(description.FullTestText).Should(Equal("Suite running a suite provides information about the current test"))
|
||||
Ω(description.TestText).Should(Equal("provides information about the current test"))
|
||||
Ω(description.IsMeasurement).Should(BeFalse())
|
||||
Ω(description.FileName).Should(ContainSubstring("suite_test.go"))
|
||||
Ω(description.LineNumber).Should(BeNumerically(">", 50))
|
||||
Ω(description.LineNumber).Should(BeNumerically("<", 150))
|
||||
Ω(description.Failed).Should(BeFalse())
|
||||
})
|
||||
|
||||
Measure("should run measurements", func(b Benchmarker) {
|
||||
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
|
||||
runtime := b.Time("sleeping", func() {
|
||||
sleepTime := time.Duration(r.Float64() * 0.01 * float64(time.Second))
|
||||
time.Sleep(sleepTime)
|
||||
})
|
||||
Ω(runtime.Seconds()).Should(BeNumerically("<=", 1))
|
||||
Ω(runtime.Seconds()).Should(BeNumerically(">=", 0))
|
||||
|
||||
randomValue := r.Float64() * 10.0
|
||||
b.RecordValue("random value", randomValue)
|
||||
Ω(randomValue).Should(BeNumerically("<=", 10.0))
|
||||
Ω(randomValue).Should(BeNumerically(">=", 0.0))
|
||||
|
||||
b.RecordValueWithPrecision("specific value", 123.4567, "ms", 2)
|
||||
b.RecordValueWithPrecision("specific value", 234.5678, "ms", 2)
|
||||
}, 10)
|
||||
|
||||
It("creates a node hierarchy, converts it to a spec collection, and runs it", func() {
|
||||
Ω(runOrder).Should(Equal([]string{
|
||||
"BeforeSuite",
|
||||
"top BE", "BE", "top JBE", "JBE", "IT", "AE", "top AE",
|
||||
"top BE", "BE", "top JBE", "JBE", "inner IT", "AE", "top AE",
|
||||
"top BE", "BE 2", "top JBE", "IT 2", "top AE",
|
||||
"top BE", "top JBE", "top IT", "top AE",
|
||||
"AfterSuite",
|
||||
}))
|
||||
})
|
||||
|
||||
Context("when told to randomize all specs", func() {
|
||||
BeforeEach(func() {
|
||||
randomizeAllSpecs = true
|
||||
})
|
||||
|
||||
It("does", func() {
|
||||
Ω(runOrder).Should(Equal([]string{
|
||||
"BeforeSuite",
|
||||
"top BE", "top JBE", "top IT", "top AE",
|
||||
"top BE", "BE", "top JBE", "JBE", "inner IT", "AE", "top AE",
|
||||
"top BE", "BE", "top JBE", "JBE", "IT", "AE", "top AE",
|
||||
"top BE", "BE 2", "top JBE", "IT 2", "top AE",
|
||||
"AfterSuite",
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when provided with a filter", func() {
|
||||
BeforeEach(func() {
|
||||
focusString = `inner|\d`
|
||||
})
|
||||
|
||||
It("converts the filter to a regular expression and uses it to filter the running specs", func() {
|
||||
Ω(runOrder).Should(Equal([]string{
|
||||
"BeforeSuite",
|
||||
"top BE", "BE", "top JBE", "JBE", "inner IT", "AE", "top AE",
|
||||
"top BE", "BE 2", "top JBE", "IT 2", "top AE",
|
||||
"AfterSuite",
|
||||
}))
|
||||
})
|
||||
|
||||
It("should not report a programmatic focus", func() {
|
||||
Ω(hasProgrammaticFocus).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
|
||||
Context("with a programatically focused spec", func() {
|
||||
BeforeEach(func() {
|
||||
specSuite.PushItNode("focused it", f("focused it"), types.FlagTypeFocused, codelocation.New(0), 0)
|
||||
|
||||
specSuite.PushContainerNode("focused container", func() {
|
||||
specSuite.PushItNode("inner focused it", f("inner focused it"), types.FlagTypeFocused, codelocation.New(0), 0)
|
||||
specSuite.PushItNode("inner unfocused it", f("inner unfocused it"), types.FlagTypeNone, codelocation.New(0), 0)
|
||||
}, types.FlagTypeFocused, codelocation.New(0))
|
||||
|
||||
})
|
||||
|
||||
It("should only run the focused test, applying backpropagation to favor most deeply focused leaf nodes", func() {
|
||||
Ω(runOrder).Should(Equal([]string{
|
||||
"BeforeSuite",
|
||||
"top BE", "top JBE", "focused it", "top AE",
|
||||
"top BE", "top JBE", "inner focused it", "top AE",
|
||||
"AfterSuite",
|
||||
}))
|
||||
})
|
||||
|
||||
It("should report a programmatic focus", func() {
|
||||
Ω(hasProgrammaticFocus).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the specs pass", func() {
|
||||
It("doesn't report a failure", func() {
|
||||
Ω(fakeT.didFail).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should return true", func() {
|
||||
Ω(runResult).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a spec fails", func() {
|
||||
var location types.CodeLocation
|
||||
BeforeEach(func() {
|
||||
specSuite.PushItNode("top level it", func() {
|
||||
location = codelocation.New(0)
|
||||
failer.Fail("oops!", location)
|
||||
}, types.FlagTypeNone, codelocation.New(0), 0)
|
||||
})
|
||||
|
||||
It("should return false", func() {
|
||||
Ω(runResult).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("reports a failure", func() {
|
||||
Ω(fakeT.didFail).Should(BeTrue())
|
||||
})
|
||||
|
||||
It("generates the correct failure data", func() {
|
||||
Ω(fakeR.SpecSummaries[0].Failure.Message).Should(Equal("oops!"))
|
||||
Ω(fakeR.SpecSummaries[0].Failure.Location).Should(Equal(location))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when runnable nodes are nested within other runnable nodes", func() {
|
||||
Context("when an It is nested", func() {
|
||||
BeforeEach(func() {
|
||||
specSuite.PushItNode("top level it", func() {
|
||||
specSuite.PushItNode("nested it", f("oops"), types.FlagTypeNone, codelocation.New(0), 0)
|
||||
}, types.FlagTypeNone, codelocation.New(0), 0)
|
||||
})
|
||||
|
||||
It("should fail", func() {
|
||||
Ω(fakeT.didFail).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a Measure is nested", func() {
|
||||
BeforeEach(func() {
|
||||
specSuite.PushItNode("top level it", func() {
|
||||
specSuite.PushMeasureNode("nested measure", func(Benchmarker) {}, types.FlagTypeNone, codelocation.New(0), 10)
|
||||
}, types.FlagTypeNone, codelocation.New(0), 0)
|
||||
})
|
||||
|
||||
It("should fail", func() {
|
||||
Ω(fakeT.didFail).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a BeforeEach is nested", func() {
|
||||
BeforeEach(func() {
|
||||
specSuite.PushItNode("top level it", func() {
|
||||
specSuite.PushBeforeEachNode(f("nested bef"), codelocation.New(0), 0)
|
||||
}, types.FlagTypeNone, codelocation.New(0), 0)
|
||||
})
|
||||
|
||||
It("should fail", func() {
|
||||
Ω(fakeT.didFail).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a JustBeforeEach is nested", func() {
|
||||
BeforeEach(func() {
|
||||
specSuite.PushItNode("top level it", func() {
|
||||
specSuite.PushJustBeforeEachNode(f("nested jbef"), codelocation.New(0), 0)
|
||||
}, types.FlagTypeNone, codelocation.New(0), 0)
|
||||
})
|
||||
|
||||
It("should fail", func() {
|
||||
Ω(fakeT.didFail).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a AfterEach is nested", func() {
|
||||
BeforeEach(func() {
|
||||
specSuite.PushItNode("top level it", func() {
|
||||
specSuite.PushAfterEachNode(f("nested aft"), codelocation.New(0), 0)
|
||||
}, types.FlagTypeNone, codelocation.New(0), 0)
|
||||
})
|
||||
|
||||
It("should fail", func() {
|
||||
Ω(fakeT.didFail).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("BeforeSuite", func() {
|
||||
Context("when setting BeforeSuite more than once", func() {
|
||||
It("should panic", func() {
|
||||
specSuite.SetBeforeSuiteNode(func() {}, codelocation.New(0), 0)
|
||||
|
||||
Ω(func() {
|
||||
specSuite.SetBeforeSuiteNode(func() {}, codelocation.New(0), 0)
|
||||
}).Should(Panic())
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("AfterSuite", func() {
|
||||
Context("when setting AfterSuite more than once", func() {
|
||||
It("should panic", func() {
|
||||
specSuite.SetAfterSuiteNode(func() {}, codelocation.New(0), 0)
|
||||
|
||||
Ω(func() {
|
||||
specSuite.SetAfterSuiteNode(func() {}, codelocation.New(0), 0)
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("By", func() {
|
||||
It("writes to the GinkgoWriter", func() {
|
||||
originalGinkgoWriter := GinkgoWriter
|
||||
buffer := &bytes.Buffer{}
|
||||
|
||||
GinkgoWriter = buffer
|
||||
By("Saying Hello GinkgoWriter")
|
||||
GinkgoWriter = originalGinkgoWriter
|
||||
|
||||
Ω(buffer.String()).Should(ContainSubstring("STEP"))
|
||||
Ω(buffer.String()).Should(ContainSubstring(": Saying Hello GinkgoWriter\n"))
|
||||
})
|
||||
|
||||
It("calls the passed-in callback if present", func() {
|
||||
a := 0
|
||||
By("calling the callback", func() {
|
||||
a = 1
|
||||
})
|
||||
Ω(a).Should(Equal(1))
|
||||
})
|
||||
|
||||
It("panics if there is more than one callback", func() {
|
||||
Ω(func() {
|
||||
By("registering more than one callback", func() {}, func() {})
|
||||
}).Should(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Describe("GinkgoRandomSeed", func() {
|
||||
It("returns the current config's random seed", func() {
|
||||
Ω(GinkgoRandomSeed()).Should(Equal(config.GinkgoConfig.RandomSeed))
|
||||
})
|
||||
})
|
||||
})
|
||||
13
vendor/github.com/onsi/ginkgo/internal/writer/writer_suite_test.go
generated
vendored
13
vendor/github.com/onsi/ginkgo/internal/writer/writer_suite_test.go
generated
vendored
|
|
@ -1,13 +0,0 @@
|
|||
package writer_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestWriter(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Writer Suite")
|
||||
}
|
||||
75
vendor/github.com/onsi/ginkgo/internal/writer/writer_test.go
generated
vendored
75
vendor/github.com/onsi/ginkgo/internal/writer/writer_test.go
generated
vendored
|
|
@ -1,75 +0,0 @@
|
|||
package writer_test
|
||||
|
||||
import (
|
||||
"github.com/onsi/gomega/gbytes"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/internal/writer"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("Writer", func() {
|
||||
var writer *Writer
|
||||
var out *gbytes.Buffer
|
||||
|
||||
BeforeEach(func() {
|
||||
out = gbytes.NewBuffer()
|
||||
writer = New(out)
|
||||
})
|
||||
|
||||
It("should stream directly to the outbuffer by default", func() {
|
||||
writer.Write([]byte("foo"))
|
||||
Ω(out).Should(gbytes.Say("foo"))
|
||||
})
|
||||
|
||||
It("should not emit the header when asked to DumpOutWitHeader", func() {
|
||||
writer.Write([]byte("foo"))
|
||||
writer.DumpOutWithHeader("my header")
|
||||
Ω(out).ShouldNot(gbytes.Say("my header"))
|
||||
Ω(out).Should(gbytes.Say("foo"))
|
||||
})
|
||||
|
||||
Context("when told not to stream", func() {
|
||||
BeforeEach(func() {
|
||||
writer.SetStream(false)
|
||||
})
|
||||
|
||||
It("should only write to the buffer when told to DumpOut", func() {
|
||||
writer.Write([]byte("foo"))
|
||||
Ω(out).ShouldNot(gbytes.Say("foo"))
|
||||
writer.DumpOut()
|
||||
Ω(out).Should(gbytes.Say("foo"))
|
||||
})
|
||||
|
||||
It("should truncate the internal buffer when told to truncate", func() {
|
||||
writer.Write([]byte("foo"))
|
||||
writer.Truncate()
|
||||
writer.DumpOut()
|
||||
Ω(out).ShouldNot(gbytes.Say("foo"))
|
||||
|
||||
writer.Write([]byte("bar"))
|
||||
writer.DumpOut()
|
||||
Ω(out).Should(gbytes.Say("bar"))
|
||||
})
|
||||
|
||||
Describe("emitting a header", func() {
|
||||
Context("when the buffer has content", func() {
|
||||
It("should emit the header followed by the content", func() {
|
||||
writer.Write([]byte("foo"))
|
||||
writer.DumpOutWithHeader("my header")
|
||||
|
||||
Ω(out).Should(gbytes.Say("my header"))
|
||||
Ω(out).Should(gbytes.Say("foo"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the buffer has no content", func() {
|
||||
It("should not emit the header", func() {
|
||||
writer.DumpOutWithHeader("my header")
|
||||
|
||||
Ω(out).ShouldNot(gbytes.Say("my header"))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
2
vendor/github.com/onsi/ginkgo/reporters/default_reporter.go
generated
vendored
2
vendor/github.com/onsi/ginkgo/reporters/default_reporter.go
generated
vendored
|
|
@ -66,7 +66,7 @@ func (reporter *DefaultReporter) SpecDidComplete(specSummary *types.SpecSummary)
|
|||
case types.SpecStatePending:
|
||||
reporter.stenographer.AnnouncePendingSpec(specSummary, reporter.config.NoisyPendings && !reporter.config.Succinct)
|
||||
case types.SpecStateSkipped:
|
||||
reporter.stenographer.AnnounceSkippedSpec(specSummary, reporter.config.Succinct, reporter.config.FullTrace)
|
||||
reporter.stenographer.AnnounceSkippedSpec(specSummary, reporter.config.Succinct || !reporter.config.NoisySkippings, reporter.config.FullTrace)
|
||||
case types.SpecStateTimedOut:
|
||||
reporter.stenographer.AnnounceSpecTimedOut(specSummary, reporter.config.Succinct, reporter.config.FullTrace)
|
||||
case types.SpecStatePanicked:
|
||||
|
|
|
|||
414
vendor/github.com/onsi/ginkgo/reporters/default_reporter_test.go
generated
vendored
414
vendor/github.com/onsi/ginkgo/reporters/default_reporter_test.go
generated
vendored
|
|
@ -1,414 +0,0 @@
|
|||
package reporters_test
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
"github.com/onsi/ginkgo/config"
|
||||
"github.com/onsi/ginkgo/reporters"
|
||||
st "github.com/onsi/ginkgo/reporters/stenographer"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("DefaultReporter", func() {
|
||||
var (
|
||||
reporter *reporters.DefaultReporter
|
||||
reporterConfig config.DefaultReporterConfigType
|
||||
stenographer *st.FakeStenographer
|
||||
|
||||
ginkgoConfig config.GinkgoConfigType
|
||||
suite *types.SuiteSummary
|
||||
spec *types.SpecSummary
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
stenographer = st.NewFakeStenographer()
|
||||
reporterConfig = config.DefaultReporterConfigType{
|
||||
NoColor: false,
|
||||
SlowSpecThreshold: 0.1,
|
||||
NoisyPendings: false,
|
||||
Verbose: true,
|
||||
FullTrace: true,
|
||||
}
|
||||
|
||||
reporter = reporters.NewDefaultReporter(reporterConfig, stenographer)
|
||||
})
|
||||
|
||||
call := func(method string, args ...interface{}) st.FakeStenographerCall {
|
||||
return st.NewFakeStenographerCall(method, args...)
|
||||
}
|
||||
|
||||
Describe("SpecSuiteWillBegin", func() {
|
||||
BeforeEach(func() {
|
||||
suite = &types.SuiteSummary{
|
||||
SuiteDescription: "A Sweet Suite",
|
||||
NumberOfTotalSpecs: 10,
|
||||
NumberOfSpecsThatWillBeRun: 8,
|
||||
}
|
||||
|
||||
ginkgoConfig = config.GinkgoConfigType{
|
||||
RandomSeed: 1138,
|
||||
RandomizeAllSpecs: true,
|
||||
}
|
||||
})
|
||||
|
||||
Context("when a serial (non-parallel) suite begins", func() {
|
||||
BeforeEach(func() {
|
||||
ginkgoConfig.ParallelTotal = 1
|
||||
|
||||
reporter.SpecSuiteWillBegin(ginkgoConfig, suite)
|
||||
})
|
||||
|
||||
It("should announce the suite, then announce the number of specs", func() {
|
||||
Ω(stenographer.Calls()).Should(HaveLen(2))
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuite", "A Sweet Suite", ginkgoConfig.RandomSeed, true, false)))
|
||||
Ω(stenographer.Calls()[1]).Should(Equal(call("AnnounceNumberOfSpecs", 8, 10, false)))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when a parallel suite begins", func() {
|
||||
BeforeEach(func() {
|
||||
ginkgoConfig.ParallelTotal = 2
|
||||
ginkgoConfig.ParallelNode = 1
|
||||
suite.NumberOfSpecsBeforeParallelization = 20
|
||||
|
||||
reporter.SpecSuiteWillBegin(ginkgoConfig, suite)
|
||||
})
|
||||
|
||||
It("should announce the suite, announce that it's a parallel run, then announce the number of specs", func() {
|
||||
Ω(stenographer.Calls()).Should(HaveLen(2))
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuite", "A Sweet Suite", ginkgoConfig.RandomSeed, true, false)))
|
||||
Ω(stenographer.Calls()[1]).Should(Equal(call("AnnounceParallelRun", 1, 2, false)))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("BeforeSuiteDidRun", func() {
|
||||
Context("when the BeforeSuite passes", func() {
|
||||
It("should announce nothing", func() {
|
||||
reporter.BeforeSuiteDidRun(&types.SetupSummary{
|
||||
State: types.SpecStatePassed,
|
||||
})
|
||||
|
||||
Ω(stenographer.Calls()).Should(BeEmpty())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the BeforeSuite fails", func() {
|
||||
It("should announce the failure", func() {
|
||||
summary := &types.SetupSummary{
|
||||
State: types.SpecStateFailed,
|
||||
}
|
||||
reporter.BeforeSuiteDidRun(summary)
|
||||
|
||||
Ω(stenographer.Calls()).Should(HaveLen(1))
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceBeforeSuiteFailure", summary, false, true)))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("AfterSuiteDidRun", func() {
|
||||
Context("when the AfterSuite passes", func() {
|
||||
It("should announce nothing", func() {
|
||||
reporter.AfterSuiteDidRun(&types.SetupSummary{
|
||||
State: types.SpecStatePassed,
|
||||
})
|
||||
|
||||
Ω(stenographer.Calls()).Should(BeEmpty())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the AfterSuite fails", func() {
|
||||
It("should announce the failure", func() {
|
||||
summary := &types.SetupSummary{
|
||||
State: types.SpecStateFailed,
|
||||
}
|
||||
reporter.AfterSuiteDidRun(summary)
|
||||
|
||||
Ω(stenographer.Calls()).Should(HaveLen(1))
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceAfterSuiteFailure", summary, false, true)))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("SpecWillRun", func() {
|
||||
Context("When running in verbose mode", func() {
|
||||
Context("and the spec will run", func() {
|
||||
BeforeEach(func() {
|
||||
spec = &types.SpecSummary{}
|
||||
reporter.SpecWillRun(spec)
|
||||
})
|
||||
|
||||
It("should announce that the spec will run", func() {
|
||||
Ω(stenographer.Calls()).Should(HaveLen(1))
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecWillRun", spec)))
|
||||
})
|
||||
})
|
||||
|
||||
Context("and the spec will not run", func() {
|
||||
Context("because it is pending", func() {
|
||||
BeforeEach(func() {
|
||||
spec = &types.SpecSummary{
|
||||
State: types.SpecStatePending,
|
||||
}
|
||||
reporter.SpecWillRun(spec)
|
||||
})
|
||||
|
||||
It("should announce nothing", func() {
|
||||
Ω(stenographer.Calls()).Should(BeEmpty())
|
||||
})
|
||||
})
|
||||
|
||||
Context("because it is skipped", func() {
|
||||
BeforeEach(func() {
|
||||
spec = &types.SpecSummary{
|
||||
State: types.SpecStateSkipped,
|
||||
}
|
||||
reporter.SpecWillRun(spec)
|
||||
})
|
||||
|
||||
It("should announce nothing", func() {
|
||||
Ω(stenographer.Calls()).Should(BeEmpty())
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("When running in verbose & succinct mode", func() {
|
||||
BeforeEach(func() {
|
||||
reporterConfig.Succinct = true
|
||||
reporter = reporters.NewDefaultReporter(reporterConfig, stenographer)
|
||||
spec = &types.SpecSummary{}
|
||||
reporter.SpecWillRun(spec)
|
||||
})
|
||||
|
||||
It("should announce nothing", func() {
|
||||
Ω(stenographer.Calls()).Should(BeEmpty())
|
||||
})
|
||||
})
|
||||
|
||||
Context("When not running in verbose mode", func() {
|
||||
BeforeEach(func() {
|
||||
reporterConfig.Verbose = false
|
||||
reporter = reporters.NewDefaultReporter(reporterConfig, stenographer)
|
||||
spec = &types.SpecSummary{}
|
||||
reporter.SpecWillRun(spec)
|
||||
})
|
||||
|
||||
It("should announce nothing", func() {
|
||||
Ω(stenographer.Calls()).Should(BeEmpty())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("SpecDidComplete", func() {
|
||||
JustBeforeEach(func() {
|
||||
reporter.SpecDidComplete(spec)
|
||||
})
|
||||
|
||||
BeforeEach(func() {
|
||||
spec = &types.SpecSummary{}
|
||||
})
|
||||
|
||||
Context("When the spec passed", func() {
|
||||
BeforeEach(func() {
|
||||
spec.State = types.SpecStatePassed
|
||||
})
|
||||
|
||||
Context("When the spec was a measurement", func() {
|
||||
BeforeEach(func() {
|
||||
spec.IsMeasurement = true
|
||||
})
|
||||
|
||||
It("should announce the measurement", func() {
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulMeasurement", spec, false)))
|
||||
})
|
||||
})
|
||||
|
||||
Context("When the spec is slow", func() {
|
||||
BeforeEach(func() {
|
||||
spec.RunTime = time.Second
|
||||
})
|
||||
|
||||
It("should announce that it was slow", func() {
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulSlowSpec", spec, false)))
|
||||
})
|
||||
})
|
||||
|
||||
Context("Otherwise", func() {
|
||||
It("should announce the succesful spec", func() {
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulSpec", spec)))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("When the spec is pending", func() {
|
||||
BeforeEach(func() {
|
||||
spec.State = types.SpecStatePending
|
||||
})
|
||||
|
||||
It("should announce the pending spec, succinctly", func() {
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnouncePendingSpec", spec, false)))
|
||||
})
|
||||
})
|
||||
|
||||
Context("When the spec is skipped", func() {
|
||||
BeforeEach(func() {
|
||||
spec.State = types.SpecStateSkipped
|
||||
})
|
||||
|
||||
It("should announce the skipped spec", func() {
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSkippedSpec", spec, false, true)))
|
||||
})
|
||||
})
|
||||
|
||||
Context("When the spec timed out", func() {
|
||||
BeforeEach(func() {
|
||||
spec.State = types.SpecStateTimedOut
|
||||
})
|
||||
|
||||
It("should announce the timedout spec", func() {
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecTimedOut", spec, false, true)))
|
||||
})
|
||||
})
|
||||
|
||||
Context("When the spec panicked", func() {
|
||||
BeforeEach(func() {
|
||||
spec.State = types.SpecStatePanicked
|
||||
})
|
||||
|
||||
It("should announce the panicked spec", func() {
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecPanicked", spec, false, true)))
|
||||
})
|
||||
})
|
||||
|
||||
Context("When the spec failed", func() {
|
||||
BeforeEach(func() {
|
||||
spec.State = types.SpecStateFailed
|
||||
})
|
||||
|
||||
It("should announce the failed spec", func() {
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecFailed", spec, false, true)))
|
||||
})
|
||||
})
|
||||
|
||||
Context("in noisy pendings mode", func() {
|
||||
BeforeEach(func() {
|
||||
reporterConfig.Succinct = false
|
||||
reporterConfig.NoisyPendings = true
|
||||
reporter = reporters.NewDefaultReporter(reporterConfig, stenographer)
|
||||
})
|
||||
|
||||
Context("When the spec is pending", func() {
|
||||
BeforeEach(func() {
|
||||
spec.State = types.SpecStatePending
|
||||
})
|
||||
|
||||
It("should announce the pending spec, noisily", func() {
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnouncePendingSpec", spec, true)))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("in succinct mode", func() {
|
||||
BeforeEach(func() {
|
||||
reporterConfig.Succinct = true
|
||||
reporter = reporters.NewDefaultReporter(reporterConfig, stenographer)
|
||||
})
|
||||
|
||||
Context("When the spec passed", func() {
|
||||
BeforeEach(func() {
|
||||
spec.State = types.SpecStatePassed
|
||||
})
|
||||
|
||||
Context("When the spec was a measurement", func() {
|
||||
BeforeEach(func() {
|
||||
spec.IsMeasurement = true
|
||||
})
|
||||
|
||||
It("should announce the measurement", func() {
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulMeasurement", spec, true)))
|
||||
})
|
||||
})
|
||||
|
||||
Context("When the spec is slow", func() {
|
||||
BeforeEach(func() {
|
||||
spec.RunTime = time.Second
|
||||
})
|
||||
|
||||
It("should announce that it was slow", func() {
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulSlowSpec", spec, true)))
|
||||
})
|
||||
})
|
||||
|
||||
Context("Otherwise", func() {
|
||||
It("should announce the succesful spec", func() {
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulSpec", spec)))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("When the spec is pending", func() {
|
||||
BeforeEach(func() {
|
||||
spec.State = types.SpecStatePending
|
||||
})
|
||||
|
||||
It("should announce the pending spec, succinctly", func() {
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnouncePendingSpec", spec, false)))
|
||||
})
|
||||
})
|
||||
|
||||
Context("When the spec is skipped", func() {
|
||||
BeforeEach(func() {
|
||||
spec.State = types.SpecStateSkipped
|
||||
})
|
||||
|
||||
It("should announce the skipped spec", func() {
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSkippedSpec", spec, true, true)))
|
||||
})
|
||||
})
|
||||
|
||||
Context("When the spec timed out", func() {
|
||||
BeforeEach(func() {
|
||||
spec.State = types.SpecStateTimedOut
|
||||
})
|
||||
|
||||
It("should announce the timedout spec", func() {
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecTimedOut", spec, true, true)))
|
||||
})
|
||||
})
|
||||
|
||||
Context("When the spec panicked", func() {
|
||||
BeforeEach(func() {
|
||||
spec.State = types.SpecStatePanicked
|
||||
})
|
||||
|
||||
It("should announce the panicked spec", func() {
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecPanicked", spec, true, true)))
|
||||
})
|
||||
})
|
||||
|
||||
Context("When the spec failed", func() {
|
||||
BeforeEach(func() {
|
||||
spec.State = types.SpecStateFailed
|
||||
})
|
||||
|
||||
It("should announce the failed spec", func() {
|
||||
Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecFailed", spec, true, true)))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("SpecSuiteDidEnd", func() {
|
||||
BeforeEach(func() {
|
||||
suite = &types.SuiteSummary{}
|
||||
reporter.SpecSuiteDidEnd(suite)
|
||||
})
|
||||
|
||||
It("should announce the spec run's completion", func() {
|
||||
Ω(stenographer.Calls()[1]).Should(Equal(call("AnnounceSpecRunCompletion", suite, false)))
|
||||
})
|
||||
})
|
||||
})
|
||||
2
vendor/github.com/onsi/ginkgo/reporters/junit_reporter.go
generated
vendored
2
vendor/github.com/onsi/ginkgo/reporters/junit_reporter.go
generated
vendored
|
|
@ -21,6 +21,7 @@ import (
|
|||
type JUnitTestSuite struct {
|
||||
XMLName xml.Name `xml:"testsuite"`
|
||||
TestCases []JUnitTestCase `xml:"testcase"`
|
||||
Name string `xml:"name,attr"`
|
||||
Tests int `xml:"tests,attr"`
|
||||
Failures int `xml:"failures,attr"`
|
||||
Time float64 `xml:"time,attr"`
|
||||
|
|
@ -59,6 +60,7 @@ func NewJUnitReporter(filename string) *JUnitReporter {
|
|||
|
||||
func (reporter *JUnitReporter) SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary) {
|
||||
reporter.suite = JUnitTestSuite{
|
||||
Name: summary.SuiteDescription,
|
||||
TestCases: []JUnitTestCase{},
|
||||
}
|
||||
reporter.testSuiteName = summary.SuiteDescription
|
||||
|
|
|
|||
247
vendor/github.com/onsi/ginkgo/reporters/junit_reporter_test.go
generated
vendored
247
vendor/github.com/onsi/ginkgo/reporters/junit_reporter_test.go
generated
vendored
|
|
@ -1,247 +0,0 @@
|
|||
package reporters_test
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
"github.com/onsi/ginkgo/config"
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
"github.com/onsi/ginkgo/reporters"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("JUnit Reporter", func() {
|
||||
var (
|
||||
outputFile string
|
||||
reporter Reporter
|
||||
)
|
||||
|
||||
readOutputFile := func() reporters.JUnitTestSuite {
|
||||
bytes, err := ioutil.ReadFile(outputFile)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
var suite reporters.JUnitTestSuite
|
||||
err = xml.Unmarshal(bytes, &suite)
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
return suite
|
||||
}
|
||||
|
||||
BeforeEach(func() {
|
||||
f, err := ioutil.TempFile("", "output")
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
f.Close()
|
||||
outputFile = f.Name()
|
||||
|
||||
reporter = reporters.NewJUnitReporter(outputFile)
|
||||
|
||||
reporter.SpecSuiteWillBegin(config.GinkgoConfigType{}, &types.SuiteSummary{
|
||||
SuiteDescription: "My test suite",
|
||||
NumberOfSpecsThatWillBeRun: 1,
|
||||
})
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
os.RemoveAll(outputFile)
|
||||
})
|
||||
|
||||
Describe("a passing test", func() {
|
||||
BeforeEach(func() {
|
||||
beforeSuite := &types.SetupSummary{
|
||||
State: types.SpecStatePassed,
|
||||
}
|
||||
reporter.BeforeSuiteDidRun(beforeSuite)
|
||||
|
||||
afterSuite := &types.SetupSummary{
|
||||
State: types.SpecStatePassed,
|
||||
}
|
||||
reporter.AfterSuiteDidRun(afterSuite)
|
||||
|
||||
spec := &types.SpecSummary{
|
||||
ComponentTexts: []string{"[Top Level]", "A", "B", "C"},
|
||||
State: types.SpecStatePassed,
|
||||
RunTime: 5 * time.Second,
|
||||
}
|
||||
reporter.SpecWillRun(spec)
|
||||
reporter.SpecDidComplete(spec)
|
||||
|
||||
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
|
||||
NumberOfSpecsThatWillBeRun: 1,
|
||||
NumberOfFailedSpecs: 0,
|
||||
RunTime: 10 * time.Second,
|
||||
})
|
||||
})
|
||||
|
||||
It("should record the test as passing", func() {
|
||||
output := readOutputFile()
|
||||
Ω(output.Tests).Should(Equal(1))
|
||||
Ω(output.Failures).Should(Equal(0))
|
||||
Ω(output.Time).Should(Equal(10.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))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("when the BeforeSuite fails", func() {
|
||||
var beforeSuite *types.SetupSummary
|
||||
|
||||
BeforeEach(func() {
|
||||
beforeSuite = &types.SetupSummary{
|
||||
State: types.SpecStateFailed,
|
||||
RunTime: 3 * time.Second,
|
||||
Failure: types.SpecFailure{
|
||||
Message: "failed to setup",
|
||||
ComponentCodeLocation: codelocation.New(0),
|
||||
Location: codelocation.New(2),
|
||||
},
|
||||
}
|
||||
reporter.BeforeSuiteDidRun(beforeSuite)
|
||||
|
||||
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
|
||||
NumberOfSpecsThatWillBeRun: 1,
|
||||
NumberOfFailedSpecs: 1,
|
||||
RunTime: 10 * time.Second,
|
||||
})
|
||||
})
|
||||
|
||||
It("should record the test as having failed", func() {
|
||||
output := readOutputFile()
|
||||
Ω(output.Tests).Should(Equal(1))
|
||||
Ω(output.Failures).Should(Equal(1))
|
||||
Ω(output.Time).Should(Equal(10.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())
|
||||
})
|
||||
})
|
||||
|
||||
Describe("when the AfterSuite fails", func() {
|
||||
var afterSuite *types.SetupSummary
|
||||
|
||||
BeforeEach(func() {
|
||||
afterSuite = &types.SetupSummary{
|
||||
State: types.SpecStateFailed,
|
||||
RunTime: 3 * time.Second,
|
||||
Failure: types.SpecFailure{
|
||||
Message: "failed to setup",
|
||||
ComponentCodeLocation: codelocation.New(0),
|
||||
Location: codelocation.New(2),
|
||||
},
|
||||
}
|
||||
reporter.AfterSuiteDidRun(afterSuite)
|
||||
|
||||
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
|
||||
NumberOfSpecsThatWillBeRun: 1,
|
||||
NumberOfFailedSpecs: 1,
|
||||
RunTime: 10 * time.Second,
|
||||
})
|
||||
})
|
||||
|
||||
It("should record the test as having failed", func() {
|
||||
output := readOutputFile()
|
||||
Ω(output.Tests).Should(Equal(1))
|
||||
Ω(output.Failures).Should(Equal(1))
|
||||
Ω(output.Time).Should(Equal(10.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())
|
||||
})
|
||||
})
|
||||
|
||||
specStateCases := []struct {
|
||||
state types.SpecState
|
||||
message string
|
||||
}{
|
||||
{types.SpecStateFailed, "Failure"},
|
||||
{types.SpecStateTimedOut, "Timeout"},
|
||||
{types.SpecStatePanicked, "Panic"},
|
||||
}
|
||||
|
||||
for _, specStateCase := range specStateCases {
|
||||
specStateCase := specStateCase
|
||||
Describe("a failing test", func() {
|
||||
var spec *types.SpecSummary
|
||||
BeforeEach(func() {
|
||||
spec = &types.SpecSummary{
|
||||
ComponentTexts: []string{"[Top Level]", "A", "B", "C"},
|
||||
State: specStateCase.state,
|
||||
RunTime: 5 * time.Second,
|
||||
Failure: types.SpecFailure{
|
||||
ComponentCodeLocation: codelocation.New(0),
|
||||
Location: codelocation.New(2),
|
||||
Message: "I failed",
|
||||
},
|
||||
}
|
||||
reporter.SpecWillRun(spec)
|
||||
reporter.SpecDidComplete(spec)
|
||||
|
||||
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
|
||||
NumberOfSpecsThatWillBeRun: 1,
|
||||
NumberOfFailedSpecs: 1,
|
||||
RunTime: 10 * time.Second,
|
||||
})
|
||||
})
|
||||
|
||||
It("should record test as failing", func() {
|
||||
output := readOutputFile()
|
||||
Ω(output.Tests).Should(Equal(1))
|
||||
Ω(output.Failures).Should(Equal(1))
|
||||
Ω(output.Time).Should(Equal(10.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())
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
for _, specStateCase := range []types.SpecState{types.SpecStatePending, types.SpecStateSkipped} {
|
||||
specStateCase := specStateCase
|
||||
Describe("a skipped test", func() {
|
||||
var spec *types.SpecSummary
|
||||
BeforeEach(func() {
|
||||
spec = &types.SpecSummary{
|
||||
ComponentTexts: []string{"[Top Level]", "A", "B", "C"},
|
||||
State: specStateCase,
|
||||
RunTime: 5 * time.Second,
|
||||
}
|
||||
reporter.SpecWillRun(spec)
|
||||
reporter.SpecDidComplete(spec)
|
||||
|
||||
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
|
||||
NumberOfSpecsThatWillBeRun: 1,
|
||||
NumberOfFailedSpecs: 0,
|
||||
RunTime: 10 * time.Second,
|
||||
})
|
||||
})
|
||||
|
||||
It("should record test as failing", func() {
|
||||
output := readOutputFile()
|
||||
Ω(output.Tests).Should(Equal(1))
|
||||
Ω(output.Failures).Should(Equal(0))
|
||||
Ω(output.Time).Should(Equal(10.0))
|
||||
Ω(output.TestCases[0].Name).Should(Equal("A B C"))
|
||||
Ω(output.TestCases[0].Skipped).ShouldNot(BeNil())
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
13
vendor/github.com/onsi/ginkgo/reporters/reporters_suite_test.go
generated
vendored
13
vendor/github.com/onsi/ginkgo/reporters/reporters_suite_test.go
generated
vendored
|
|
@ -1,13 +0,0 @@
|
|||
package reporters_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestReporters(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Reporters Suite")
|
||||
}
|
||||
2
vendor/github.com/onsi/ginkgo/reporters/stenographer/stenographer.go
generated
vendored
2
vendor/github.com/onsi/ginkgo/reporters/stenographer/stenographer.go
generated
vendored
|
|
@ -178,7 +178,7 @@ func (s *consoleStenographer) AnnounceSpecRunCompletion(summary *types.SuiteSumm
|
|||
}
|
||||
|
||||
s.print(0,
|
||||
"%s -- %s | %s | %s | %s ",
|
||||
"%s -- %s | %s | %s | %s\n",
|
||||
status,
|
||||
s.colorize(greenColor+boldStyle, "%d Passed", summary.NumberOfPassedSpecs),
|
||||
s.colorize(redColor+boldStyle, "%d Failed", summary.NumberOfFailedSpecs)+flakes,
|
||||
|
|
|
|||
5
vendor/github.com/onsi/ginkgo/reporters/teamcity_reporter.go
generated
vendored
5
vendor/github.com/onsi/ginkgo/reporters/teamcity_reporter.go
generated
vendored
|
|
@ -10,10 +10,11 @@ package reporters
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/onsi/ginkgo/config"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/onsi/ginkgo/config"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
|||
213
vendor/github.com/onsi/ginkgo/reporters/teamcity_reporter_test.go
generated
vendored
213
vendor/github.com/onsi/ginkgo/reporters/teamcity_reporter_test.go
generated
vendored
|
|
@ -1,213 +0,0 @@
|
|||
package reporters_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
. "github.com/onsi/ginkgo"
|
||||
"github.com/onsi/ginkgo/config"
|
||||
"github.com/onsi/ginkgo/internal/codelocation"
|
||||
"github.com/onsi/ginkgo/reporters"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
. "github.com/onsi/gomega"
|
||||
"time"
|
||||
)
|
||||
|
||||
var _ = Describe("TeamCity Reporter", func() {
|
||||
var (
|
||||
buffer bytes.Buffer
|
||||
reporter Reporter
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
buffer.Truncate(0)
|
||||
reporter = reporters.NewTeamCityReporter(&buffer)
|
||||
reporter.SpecSuiteWillBegin(config.GinkgoConfigType{}, &types.SuiteSummary{
|
||||
SuiteDescription: "Foo's test suite",
|
||||
NumberOfSpecsThatWillBeRun: 1,
|
||||
})
|
||||
})
|
||||
|
||||
Describe("a passing test", func() {
|
||||
BeforeEach(func() {
|
||||
beforeSuite := &types.SetupSummary{
|
||||
State: types.SpecStatePassed,
|
||||
}
|
||||
reporter.BeforeSuiteDidRun(beforeSuite)
|
||||
|
||||
afterSuite := &types.SetupSummary{
|
||||
State: types.SpecStatePassed,
|
||||
}
|
||||
reporter.AfterSuiteDidRun(afterSuite)
|
||||
|
||||
spec := &types.SpecSummary{
|
||||
ComponentTexts: []string{"[Top Level]", "A", "B", "C"},
|
||||
State: types.SpecStatePassed,
|
||||
RunTime: 5 * time.Second,
|
||||
}
|
||||
reporter.SpecWillRun(spec)
|
||||
reporter.SpecDidComplete(spec)
|
||||
|
||||
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
|
||||
NumberOfSpecsThatWillBeRun: 1,
|
||||
NumberOfFailedSpecs: 0,
|
||||
RunTime: 10 * time.Second,
|
||||
})
|
||||
})
|
||||
|
||||
It("should record the test as passing", func() {
|
||||
actual := buffer.String()
|
||||
expected :=
|
||||
"##teamcity[testSuiteStarted name='Foo|'s test suite']" +
|
||||
"##teamcity[testStarted name='A B C']" +
|
||||
"##teamcity[testFinished name='A B C' duration='5000']" +
|
||||
"##teamcity[testSuiteFinished name='Foo|'s test suite']"
|
||||
Ω(actual).Should(Equal(expected))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("when the BeforeSuite fails", func() {
|
||||
var beforeSuite *types.SetupSummary
|
||||
|
||||
BeforeEach(func() {
|
||||
beforeSuite = &types.SetupSummary{
|
||||
State: types.SpecStateFailed,
|
||||
RunTime: 3 * time.Second,
|
||||
Failure: types.SpecFailure{
|
||||
Message: "failed to setup\n",
|
||||
ComponentCodeLocation: codelocation.New(0),
|
||||
},
|
||||
}
|
||||
reporter.BeforeSuiteDidRun(beforeSuite)
|
||||
|
||||
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
|
||||
NumberOfSpecsThatWillBeRun: 1,
|
||||
NumberOfFailedSpecs: 1,
|
||||
RunTime: 10 * time.Second,
|
||||
})
|
||||
})
|
||||
|
||||
It("should record the test as having failed", func() {
|
||||
actual := buffer.String()
|
||||
expected := fmt.Sprintf(
|
||||
"##teamcity[testSuiteStarted name='Foo|'s test suite']"+
|
||||
"##teamcity[testStarted name='BeforeSuite']"+
|
||||
"##teamcity[testFailed name='BeforeSuite' message='%s' details='failed to setup|n']"+
|
||||
"##teamcity[testFinished name='BeforeSuite' duration='3000']"+
|
||||
"##teamcity[testSuiteFinished name='Foo|'s test suite']", beforeSuite.Failure.ComponentCodeLocation.String(),
|
||||
)
|
||||
Ω(actual).Should(Equal(expected))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("when the AfterSuite fails", func() {
|
||||
var afterSuite *types.SetupSummary
|
||||
|
||||
BeforeEach(func() {
|
||||
afterSuite = &types.SetupSummary{
|
||||
State: types.SpecStateFailed,
|
||||
RunTime: 3 * time.Second,
|
||||
Failure: types.SpecFailure{
|
||||
Message: "failed to setup\n",
|
||||
ComponentCodeLocation: codelocation.New(0),
|
||||
},
|
||||
}
|
||||
reporter.AfterSuiteDidRun(afterSuite)
|
||||
|
||||
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
|
||||
NumberOfSpecsThatWillBeRun: 1,
|
||||
NumberOfFailedSpecs: 1,
|
||||
RunTime: 10 * time.Second,
|
||||
})
|
||||
})
|
||||
|
||||
It("should record the test as having failed", func() {
|
||||
actual := buffer.String()
|
||||
expected := fmt.Sprintf(
|
||||
"##teamcity[testSuiteStarted name='Foo|'s test suite']"+
|
||||
"##teamcity[testStarted name='AfterSuite']"+
|
||||
"##teamcity[testFailed name='AfterSuite' message='%s' details='failed to setup|n']"+
|
||||
"##teamcity[testFinished name='AfterSuite' duration='3000']"+
|
||||
"##teamcity[testSuiteFinished name='Foo|'s test suite']", afterSuite.Failure.ComponentCodeLocation.String(),
|
||||
)
|
||||
Ω(actual).Should(Equal(expected))
|
||||
})
|
||||
})
|
||||
specStateCases := []struct {
|
||||
state types.SpecState
|
||||
message string
|
||||
}{
|
||||
{types.SpecStateFailed, "Failure"},
|
||||
{types.SpecStateTimedOut, "Timeout"},
|
||||
{types.SpecStatePanicked, "Panic"},
|
||||
}
|
||||
|
||||
for _, specStateCase := range specStateCases {
|
||||
specStateCase := specStateCase
|
||||
Describe("a failing test", func() {
|
||||
var spec *types.SpecSummary
|
||||
BeforeEach(func() {
|
||||
spec = &types.SpecSummary{
|
||||
ComponentTexts: []string{"[Top Level]", "A", "B", "C"},
|
||||
State: specStateCase.state,
|
||||
RunTime: 5 * time.Second,
|
||||
Failure: types.SpecFailure{
|
||||
ComponentCodeLocation: codelocation.New(0),
|
||||
Message: "I failed",
|
||||
},
|
||||
}
|
||||
reporter.SpecWillRun(spec)
|
||||
reporter.SpecDidComplete(spec)
|
||||
|
||||
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
|
||||
NumberOfSpecsThatWillBeRun: 1,
|
||||
NumberOfFailedSpecs: 1,
|
||||
RunTime: 10 * time.Second,
|
||||
})
|
||||
})
|
||||
|
||||
It("should record test as failing", func() {
|
||||
actual := buffer.String()
|
||||
expected :=
|
||||
fmt.Sprintf("##teamcity[testSuiteStarted name='Foo|'s test suite']"+
|
||||
"##teamcity[testStarted name='A B C']"+
|
||||
"##teamcity[testFailed name='A B C' message='%s' details='I failed']"+
|
||||
"##teamcity[testFinished name='A B C' duration='5000']"+
|
||||
"##teamcity[testSuiteFinished name='Foo|'s test suite']", spec.Failure.ComponentCodeLocation.String())
|
||||
Ω(actual).Should(Equal(expected))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
for _, specStateCase := range []types.SpecState{types.SpecStatePending, types.SpecStateSkipped} {
|
||||
specStateCase := specStateCase
|
||||
Describe("a skipped test", func() {
|
||||
var spec *types.SpecSummary
|
||||
BeforeEach(func() {
|
||||
spec = &types.SpecSummary{
|
||||
ComponentTexts: []string{"[Top Level]", "A", "B", "C"},
|
||||
State: specStateCase,
|
||||
RunTime: 5 * time.Second,
|
||||
}
|
||||
reporter.SpecWillRun(spec)
|
||||
reporter.SpecDidComplete(spec)
|
||||
|
||||
reporter.SpecSuiteDidEnd(&types.SuiteSummary{
|
||||
NumberOfSpecsThatWillBeRun: 1,
|
||||
NumberOfFailedSpecs: 0,
|
||||
RunTime: 10 * time.Second,
|
||||
})
|
||||
})
|
||||
|
||||
It("should record test as ignored", func() {
|
||||
actual := buffer.String()
|
||||
expected :=
|
||||
"##teamcity[testSuiteStarted name='Foo|'s test suite']" +
|
||||
"##teamcity[testStarted name='A B C']" +
|
||||
"##teamcity[testIgnored name='A B C']" +
|
||||
"##teamcity[testFinished name='A B C' duration='5000']" +
|
||||
"##teamcity[testSuiteFinished name='Foo|'s test suite']"
|
||||
Ω(actual).Should(Equal(expected))
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
13
vendor/github.com/onsi/ginkgo/types/types_suite_test.go
generated
vendored
13
vendor/github.com/onsi/ginkgo/types/types_suite_test.go
generated
vendored
|
|
@ -1,13 +0,0 @@
|
|||
package types_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTypes(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Types Suite")
|
||||
}
|
||||
99
vendor/github.com/onsi/ginkgo/types/types_test.go
generated
vendored
99
vendor/github.com/onsi/ginkgo/types/types_test.go
generated
vendored
|
|
@ -1,99 +0,0 @@
|
|||
package types_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo/types"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var specStates = []SpecState{
|
||||
SpecStatePassed,
|
||||
SpecStateTimedOut,
|
||||
SpecStatePanicked,
|
||||
SpecStateFailed,
|
||||
SpecStatePending,
|
||||
SpecStateSkipped,
|
||||
}
|
||||
|
||||
func verifySpecSummary(caller func(SpecSummary) bool, trueStates ...SpecState) {
|
||||
summary := SpecSummary{}
|
||||
trueStateLookup := map[SpecState]bool{}
|
||||
for _, state := range trueStates {
|
||||
trueStateLookup[state] = true
|
||||
summary.State = state
|
||||
Ω(caller(summary)).Should(BeTrue())
|
||||
}
|
||||
|
||||
for _, state := range specStates {
|
||||
if trueStateLookup[state] {
|
||||
continue
|
||||
}
|
||||
summary.State = state
|
||||
Ω(caller(summary)).Should(BeFalse())
|
||||
}
|
||||
}
|
||||
|
||||
var _ = Describe("Types", func() {
|
||||
Describe("IsFailureState", func() {
|
||||
It("knows when it is in a failure-like state", func() {
|
||||
verifySpecSummary(func(summary SpecSummary) bool {
|
||||
return summary.State.IsFailure()
|
||||
}, SpecStateTimedOut, SpecStatePanicked, SpecStateFailed)
|
||||
})
|
||||
})
|
||||
|
||||
Describe("SpecSummary", func() {
|
||||
It("knows when it is in a failure-like state", func() {
|
||||
verifySpecSummary(func(summary SpecSummary) bool {
|
||||
return summary.HasFailureState()
|
||||
}, SpecStateTimedOut, SpecStatePanicked, SpecStateFailed)
|
||||
})
|
||||
|
||||
It("knows when it passed", func() {
|
||||
verifySpecSummary(func(summary SpecSummary) bool {
|
||||
return summary.Passed()
|
||||
}, SpecStatePassed)
|
||||
})
|
||||
|
||||
It("knows when it has failed", func() {
|
||||
verifySpecSummary(func(summary SpecSummary) bool {
|
||||
return summary.Failed()
|
||||
}, SpecStateFailed)
|
||||
})
|
||||
|
||||
It("knows when it has panicked", func() {
|
||||
verifySpecSummary(func(summary SpecSummary) bool {
|
||||
return summary.Panicked()
|
||||
}, SpecStatePanicked)
|
||||
})
|
||||
|
||||
It("knows when it has timed out", func() {
|
||||
verifySpecSummary(func(summary SpecSummary) bool {
|
||||
return summary.TimedOut()
|
||||
}, SpecStateTimedOut)
|
||||
})
|
||||
|
||||
It("knows when it is pending", func() {
|
||||
verifySpecSummary(func(summary SpecSummary) bool {
|
||||
return summary.Pending()
|
||||
}, SpecStatePending)
|
||||
})
|
||||
|
||||
It("knows when it is skipped", func() {
|
||||
verifySpecSummary(func(summary SpecSummary) bool {
|
||||
return summary.Skipped()
|
||||
}, SpecStateSkipped)
|
||||
})
|
||||
})
|
||||
|
||||
Describe("SpecMeasurement", func() {
|
||||
It("knows how to format values when the precision is 0", func() {
|
||||
Ω(SpecMeasurement{}.PrecisionFmt()).Should(Equal("%f"))
|
||||
})
|
||||
|
||||
It("knows how to format the values when the precision is 3", func() {
|
||||
Ω(SpecMeasurement{Precision: 3}.PrecisionFmt()).Should(Equal("%.3f"))
|
||||
})
|
||||
})
|
||||
})
|
||||
10
vendor/github.com/onsi/gomega/.travis.yml
generated
vendored
10
vendor/github.com/onsi/gomega/.travis.yml
generated
vendored
|
|
@ -1,12 +1,14 @@
|
|||
language: go
|
||||
go:
|
||||
- 1.6
|
||||
- 1.7
|
||||
- 1.8
|
||||
- 1.6.x
|
||||
- 1.7.x
|
||||
- 1.8.x
|
||||
- 1.9.x
|
||||
- 1.10.x
|
||||
|
||||
install:
|
||||
- go get -v ./...
|
||||
- go get github.com/onsi/ginkgo
|
||||
- go install github.com/onsi/ginkgo/ginkgo
|
||||
|
||||
script: $HOME/gopath/bin/ginkgo -r --randomizeAllSpecs --failOnPending --randomizeSuites --race
|
||||
script: $HOME/gopath/bin/ginkgo -p -r --randomizeAllSpecs --failOnPending --randomizeSuites --race && go vet
|
||||
|
|
|
|||
25
vendor/github.com/onsi/gomega/CHANGELOG.md
generated
vendored
25
vendor/github.com/onsi/gomega/CHANGELOG.md
generated
vendored
|
|
@ -1,5 +1,30 @@
|
|||
## HEAD
|
||||
|
||||
### Features
|
||||
- Make string pretty diff user configurable (#273) [eb112ce, 649b44d]
|
||||
|
||||
### Fixes
|
||||
- Use httputil.DumpRequest to pretty-print unhandled requests (#278) [a4ff0fc, b7d1a52]
|
||||
- fix typo floa32 > float32 (#272) [041ae3b, 6e33911]
|
||||
- Fix link to documentation on adding your own matchers (#270) [bb2c830, fcebc62]
|
||||
- Use setters and getters to avoid race condition (#262) [13057c3, a9c79f1]
|
||||
- Avoid sending a signal if the process is not alive (#259) [b8043e5, 4fc1762]
|
||||
- Improve message from AssignableToTypeOf when expected value is nil (#281) [9c1fb20]
|
||||
|
||||
## 1.3.0
|
||||
|
||||
Improvements:
|
||||
|
||||
- The `Equal` matcher matches byte slices more performantly.
|
||||
- Improved how `MatchError` matches error strings.
|
||||
- `MatchXML` ignores the order of xml node attributes.
|
||||
- Improve support for XUnit style golang tests. ([#254](https://github.com/onsi/gomega/issues/254))
|
||||
|
||||
Bug Fixes:
|
||||
|
||||
- Diff generation now handles multi-byte sequences correctly.
|
||||
- Multiple goroutines can now call `gexec.Build` concurrently.
|
||||
|
||||
## 1.2.0
|
||||
|
||||
Improvements:
|
||||
|
|
|
|||
5
vendor/github.com/onsi/gomega/CONTRIBUTING.md
generated
vendored
5
vendor/github.com/onsi/gomega/CONTRIBUTING.md
generated
vendored
|
|
@ -6,6 +6,9 @@ Your contributions to Gomega are essential for its long-term maintenance and imp
|
|||
- Ensure adequate test coverage:
|
||||
- Make sure to add appropriate unit tests
|
||||
- Please run all tests locally (`ginkgo -r -p`) and make sure they go green before submitting the PR
|
||||
- Please run following linter locally `go vet ./...` and make sure output does not contain any warnings
|
||||
- Update the documentation. In addition to standard `godoc` comments Gomega has extensive documentation on the `gh-pages` branch. If relevant, please submit a docs PR to that branch alongside your code PR.
|
||||
|
||||
Thanks for supporting Gomega!
|
||||
If you're a committer, check out RELEASING.md to learn how to cut a release.
|
||||
|
||||
Thanks for supporting Gomega!
|
||||
|
|
|
|||
12
vendor/github.com/onsi/gomega/RELEASING.md
generated
vendored
Normal file
12
vendor/github.com/onsi/gomega/RELEASING.md
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
A Gomega release is a tagged sha and a GitHub release. To cut a release:
|
||||
|
||||
1. Ensure CHANGELOG.md is up to date.
|
||||
- Use `git log --pretty=format:'- %s [%h]' HEAD...vX.X.X` to list all the commits since the last release
|
||||
- Categorize the changes into
|
||||
- Breaking Changes (requires a major version)
|
||||
- New Features (minor version)
|
||||
- Fixes (fix version)
|
||||
- Maintenance (which in general should not be mentioned in `CHANGELOG.md` as they have no user impact)
|
||||
2. Update GOMEGA_VERSION in `gomega_dsl.go`
|
||||
3. Push a commit with the version number as the commit message (e.g. `v1.3.0`)
|
||||
4. Create a new [GitHub release](https://help.github.com/articles/creating-releases/) with the version number as the tag (e.g. `v1.3.0`). List the key changes in the release notes.
|
||||
7
vendor/github.com/onsi/gomega/format/format.go
generated
vendored
7
vendor/github.com/onsi/gomega/format/format.go
generated
vendored
|
|
@ -30,6 +30,9 @@ Set PrintContextObjects = true to enable printing of the context internals.
|
|||
*/
|
||||
var PrintContextObjects = false
|
||||
|
||||
// TruncatedDiff choose if we should display a truncated pretty diff or not
|
||||
var TruncatedDiff = true
|
||||
|
||||
// Ctx interface defined here to keep backwards compatability with go < 1.7
|
||||
// It matches the context.Context interface
|
||||
type Ctx interface {
|
||||
|
|
@ -82,7 +85,7 @@ to equal |
|
|||
*/
|
||||
|
||||
func MessageWithDiff(actual, message, expected string) string {
|
||||
if len(actual) >= truncateThreshold && len(expected) >= truncateThreshold {
|
||||
if TruncatedDiff && len(actual) >= truncateThreshold && len(expected) >= truncateThreshold {
|
||||
diffPoint := findFirstMismatch(actual, expected)
|
||||
formattedActual := truncateAndFormat(actual, diffPoint)
|
||||
formattedExpected := truncateAndFormat(expected, diffPoint)
|
||||
|
|
@ -123,7 +126,7 @@ func findFirstMismatch(a, b string) int {
|
|||
bSlice := strings.Split(b, "")
|
||||
|
||||
for index, str := range aSlice {
|
||||
if index > len(b) - 1 {
|
||||
if index > len(bSlice)-1 {
|
||||
return index
|
||||
}
|
||||
if str != bSlice[index] {
|
||||
|
|
|
|||
13
vendor/github.com/onsi/gomega/format/format_suite_test.go
generated
vendored
13
vendor/github.com/onsi/gomega/format/format_suite_test.go
generated
vendored
|
|
@ -1,13 +0,0 @@
|
|||
package format_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFormat(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Format Suite")
|
||||
}
|
||||
590
vendor/github.com/onsi/gomega/format/format_test.go
generated
vendored
590
vendor/github.com/onsi/gomega/format/format_test.go
generated
vendored
|
|
@ -1,590 +0,0 @@
|
|||
package format_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/format"
|
||||
"github.com/onsi/gomega/types"
|
||||
)
|
||||
|
||||
//recursive struct
|
||||
|
||||
type StringAlias string
|
||||
type ByteAlias []byte
|
||||
type IntAlias int
|
||||
|
||||
type AStruct struct {
|
||||
Exported string
|
||||
}
|
||||
|
||||
type SimpleStruct struct {
|
||||
Name string
|
||||
Enumeration int
|
||||
Veritas bool
|
||||
Data []byte
|
||||
secret uint32
|
||||
}
|
||||
|
||||
type ComplexStruct struct {
|
||||
Strings []string
|
||||
SimpleThings []*SimpleStruct
|
||||
DataMaps map[int]ByteAlias
|
||||
}
|
||||
|
||||
type SecretiveStruct struct {
|
||||
boolValue bool
|
||||
intValue int
|
||||
uintValue uint
|
||||
uintptrValue uintptr
|
||||
floatValue float32
|
||||
complexValue complex64
|
||||
chanValue chan bool
|
||||
funcValue func()
|
||||
pointerValue *int
|
||||
sliceValue []string
|
||||
byteSliceValue []byte
|
||||
stringValue string
|
||||
arrValue [3]int
|
||||
byteArrValue [3]byte
|
||||
mapValue map[string]int
|
||||
structValue AStruct
|
||||
interfaceValue interface{}
|
||||
}
|
||||
|
||||
type GoStringer struct {
|
||||
}
|
||||
|
||||
func (g GoStringer) GoString() string {
|
||||
return "go-string"
|
||||
}
|
||||
|
||||
func (g GoStringer) String() string {
|
||||
return "string"
|
||||
}
|
||||
|
||||
type Stringer struct {
|
||||
}
|
||||
|
||||
func (g Stringer) String() string {
|
||||
return "string"
|
||||
}
|
||||
|
||||
type ctx struct {
|
||||
}
|
||||
|
||||
func (c *ctx) Deadline() (deadline time.Time, ok bool) {
|
||||
return time.Time{}, false
|
||||
}
|
||||
|
||||
func (c *ctx) Done() <-chan struct{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ctx) Err() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ctx) Value(key interface{}) interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ = Describe("Format", func() {
|
||||
match := func(typeRepresentation string, valueRepresentation string, args ...interface{}) types.GomegaMatcher {
|
||||
if len(args) > 0 {
|
||||
valueRepresentation = fmt.Sprintf(valueRepresentation, args...)
|
||||
}
|
||||
return Equal(fmt.Sprintf("%s<%s>: %s", Indent, typeRepresentation, valueRepresentation))
|
||||
}
|
||||
|
||||
matchRegexp := func(typeRepresentation string, valueRepresentation string, args ...interface{}) types.GomegaMatcher {
|
||||
if len(args) > 0 {
|
||||
valueRepresentation = fmt.Sprintf(valueRepresentation, args...)
|
||||
}
|
||||
return MatchRegexp(fmt.Sprintf("%s<%s>: %s", Indent, typeRepresentation, valueRepresentation))
|
||||
}
|
||||
|
||||
hashMatchingRegexp := func(entries ...string) string {
|
||||
entriesSwitch := "(" + strings.Join(entries, "|") + ")"
|
||||
arr := make([]string, len(entries))
|
||||
for i := range arr {
|
||||
arr[i] = entriesSwitch
|
||||
}
|
||||
return "{" + strings.Join(arr, ", ") + "}"
|
||||
}
|
||||
|
||||
Describe("Message", func() {
|
||||
Context("with only an actual value", func() {
|
||||
It("should print out an indented formatted representation of the value and the message", func() {
|
||||
Ω(Message(3, "to be three.")).Should(Equal("Expected\n <int>: 3\nto be three."))
|
||||
})
|
||||
})
|
||||
|
||||
Context("with an actual and an expected value", func() {
|
||||
It("should print out an indented formatted representatino of both values, and the message", func() {
|
||||
Ω(Message(3, "to equal", 4)).Should(Equal("Expected\n <int>: 3\nto equal\n <int>: 4"))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("MessageWithDiff", func() {
|
||||
It("shows the exact point where two long strings differ", func() {
|
||||
stringWithB := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
stringWithZ := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
|
||||
Ω(MessageWithDiff(stringWithB, "to equal", stringWithZ)).Should(Equal(expectedLongStringFailureMessage))
|
||||
})
|
||||
|
||||
It("truncates the start of long strings that differ only at their end", func() {
|
||||
stringWithB := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab"
|
||||
stringWithZ := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz"
|
||||
|
||||
Ω(MessageWithDiff(stringWithB, "to equal", stringWithZ)).Should(Equal(expectedTruncatedStartStringFailureMessage))
|
||||
})
|
||||
|
||||
It("truncates the start of long strings that differ only in length", func() {
|
||||
smallString := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
largeString := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
|
||||
Ω(MessageWithDiff(largeString, "to equal", smallString)).Should(Equal(expectedTruncatedStartSizeFailureMessage))
|
||||
Ω(MessageWithDiff(smallString, "to equal", largeString)).Should(Equal(expectedTruncatedStartSizeSwappedFailureMessage))
|
||||
})
|
||||
|
||||
It("truncates the end of long strings that differ only at their start", func() {
|
||||
stringWithB := "baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
stringWithZ := "zaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
|
||||
Ω(MessageWithDiff(stringWithB, "to equal", stringWithZ)).Should(Equal(expectedTruncatedEndStringFailureMessage))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("IndentString", func() {
|
||||
It("should indent the string", func() {
|
||||
Ω(IndentString("foo\n bar\nbaz", 2)).Should(Equal(" foo\n bar\n baz"))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Object", func() {
|
||||
Describe("formatting boolean values", func() {
|
||||
It("should give the type and format values correctly", func() {
|
||||
Ω(Object(true, 1)).Should(match("bool", "true"))
|
||||
Ω(Object(false, 1)).Should(match("bool", "false"))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("formatting numbers", func() {
|
||||
It("should give the type and format values correctly", func() {
|
||||
Ω(Object(int(3), 1)).Should(match("int", "3"))
|
||||
Ω(Object(int8(3), 1)).Should(match("int8", "3"))
|
||||
Ω(Object(int16(3), 1)).Should(match("int16", "3"))
|
||||
Ω(Object(int32(3), 1)).Should(match("int32", "3"))
|
||||
Ω(Object(int64(3), 1)).Should(match("int64", "3"))
|
||||
|
||||
Ω(Object(uint(3), 1)).Should(match("uint", "3"))
|
||||
Ω(Object(uint8(3), 1)).Should(match("uint8", "3"))
|
||||
Ω(Object(uint16(3), 1)).Should(match("uint16", "3"))
|
||||
Ω(Object(uint32(3), 1)).Should(match("uint32", "3"))
|
||||
Ω(Object(uint64(3), 1)).Should(match("uint64", "3"))
|
||||
})
|
||||
|
||||
It("should handle uintptr differently", func() {
|
||||
Ω(Object(uintptr(3), 1)).Should(match("uintptr", "0x3"))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("formatting channels", func() {
|
||||
It("should give the type and format values correctly", func() {
|
||||
c := make(chan<- bool, 3)
|
||||
c <- true
|
||||
c <- false
|
||||
Ω(Object(c, 1)).Should(match("chan<- bool | len:2, cap:3", "%v", c))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("formatting strings", func() {
|
||||
It("should give the type and format values correctly", func() {
|
||||
s := "a\nb\nc"
|
||||
Ω(Object(s, 1)).Should(match("string", `a
|
||||
b
|
||||
c`))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("formatting []byte slices", func() {
|
||||
Context("when the slice is made of printable bytes", func() {
|
||||
It("should present it as string", func() {
|
||||
b := []byte("a b c")
|
||||
Ω(Object(b, 1)).Should(matchRegexp(`\[\]uint8 \| len:5, cap:\d+`, `a b c`))
|
||||
})
|
||||
})
|
||||
Context("when the slice contains non-printable bytes", func() {
|
||||
It("should present it as slice", func() {
|
||||
b := []byte("a b c\n\x01\x02\x03\xff\x1bH")
|
||||
Ω(Object(b, 1)).Should(matchRegexp(`\[\]uint8 \| len:12, cap:\d+`, `\[97, 32, 98, 32, 99, 10, 1, 2, 3, 255, 27, 72\]`))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("formatting functions", func() {
|
||||
It("should give the type and format values correctly", func() {
|
||||
f := func(a string, b []int) ([]byte, error) {
|
||||
return []byte("abc"), nil
|
||||
}
|
||||
Ω(Object(f, 1)).Should(match("func(string, []int) ([]uint8, error)", "%v", f))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("formatting pointers", func() {
|
||||
It("should give the type and dereference the value to format it correctly", func() {
|
||||
a := 3
|
||||
Ω(Object(&a, 1)).Should(match(fmt.Sprintf("*int | %p", &a), "3"))
|
||||
})
|
||||
|
||||
Context("when there are pointers to pointers...", func() {
|
||||
It("should recursively deference the pointer until it gets to a value", func() {
|
||||
a := 3
|
||||
var b *int
|
||||
var c **int
|
||||
var d ***int
|
||||
b = &a
|
||||
c = &b
|
||||
d = &c
|
||||
|
||||
Ω(Object(d, 1)).Should(match(fmt.Sprintf("***int | %p", d), "3"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the pointer points to nil", func() {
|
||||
It("should say nil and not explode", func() {
|
||||
var a *AStruct
|
||||
Ω(Object(a, 1)).Should(match("*format_test.AStruct | 0x0", "nil"))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("formatting arrays", func() {
|
||||
It("should give the type and format values correctly", func() {
|
||||
w := [3]string{"Jed Bartlet", "Toby Ziegler", "CJ Cregg"}
|
||||
Ω(Object(w, 1)).Should(match("[3]string", `["Jed Bartlet", "Toby Ziegler", "CJ Cregg"]`))
|
||||
})
|
||||
|
||||
Context("with byte arrays", func() {
|
||||
It("should give the type and format values correctly", func() {
|
||||
w := [3]byte{17, 28, 19}
|
||||
Ω(Object(w, 1)).Should(match("[3]uint8", `[17, 28, 19]`))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("formatting slices", func() {
|
||||
It("should include the length and capacity in the type information", func() {
|
||||
s := make([]bool, 3, 4)
|
||||
Ω(Object(s, 1)).Should(match("[]bool | len:3, cap:4", "[false, false, false]"))
|
||||
})
|
||||
|
||||
Context("when the slice contains long entries", func() {
|
||||
It("should format the entries with newlines", func() {
|
||||
w := []string{"Josiah Edward Bartlet", "Toby Ziegler", "CJ Cregg"}
|
||||
expected := `[
|
||||
"Josiah Edward Bartlet",
|
||||
"Toby Ziegler",
|
||||
"CJ Cregg",
|
||||
]`
|
||||
Ω(Object(w, 1)).Should(match("[]string | len:3, cap:3", expected))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("formatting maps", func() {
|
||||
It("should include the length in the type information", func() {
|
||||
m := make(map[int]bool, 5)
|
||||
m[3] = true
|
||||
m[4] = false
|
||||
Ω(Object(m, 1)).Should(matchRegexp(`map\[int\]bool \| len:2`, hashMatchingRegexp("3: true", "4: false")))
|
||||
})
|
||||
|
||||
Context("when the slice contains long entries", func() {
|
||||
It("should format the entries with newlines", func() {
|
||||
m := map[string][]byte{}
|
||||
m["Josiah Edward Bartlet"] = []byte("Martin Sheen")
|
||||
m["Toby Ziegler"] = []byte("Richard Schiff")
|
||||
m["CJ Cregg"] = []byte("Allison Janney")
|
||||
expected := `{
|
||||
("Josiah Edward Bartlet": "Martin Sheen"|"Toby Ziegler": "Richard Schiff"|"CJ Cregg": "Allison Janney"),
|
||||
("Josiah Edward Bartlet": "Martin Sheen"|"Toby Ziegler": "Richard Schiff"|"CJ Cregg": "Allison Janney"),
|
||||
("Josiah Edward Bartlet": "Martin Sheen"|"Toby Ziegler": "Richard Schiff"|"CJ Cregg": "Allison Janney"),
|
||||
}`
|
||||
Ω(Object(m, 1)).Should(matchRegexp(`map\[string\]\[\]uint8 \| len:3`, expected))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("formatting structs", func() {
|
||||
It("should include the struct name and the field names", func() {
|
||||
s := SimpleStruct{
|
||||
Name: "Oswald",
|
||||
Enumeration: 17,
|
||||
Veritas: true,
|
||||
Data: []byte("datum"),
|
||||
secret: 1983,
|
||||
}
|
||||
|
||||
Ω(Object(s, 1)).Should(match("format_test.SimpleStruct", `{Name: "Oswald", Enumeration: 17, Veritas: true, Data: "datum", secret: 1983}`))
|
||||
})
|
||||
|
||||
Context("when the struct contains long entries", func() {
|
||||
It("should format the entries with new lines", func() {
|
||||
s := &SimpleStruct{
|
||||
Name: "Mithrandir Gandalf Greyhame",
|
||||
Enumeration: 2021,
|
||||
Veritas: true,
|
||||
Data: []byte("wizard"),
|
||||
secret: 3,
|
||||
}
|
||||
|
||||
Ω(Object(s, 1)).Should(match(fmt.Sprintf("*format_test.SimpleStruct | %p", s), `{
|
||||
Name: "Mithrandir Gandalf Greyhame",
|
||||
Enumeration: 2021,
|
||||
Veritas: true,
|
||||
Data: "wizard",
|
||||
secret: 3,
|
||||
}`))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("formatting nil values", func() {
|
||||
It("should print out nil", func() {
|
||||
Ω(Object(nil, 1)).Should(match("nil", "nil"))
|
||||
var typedNil *AStruct
|
||||
Ω(Object(typedNil, 1)).Should(match("*format_test.AStruct | 0x0", "nil"))
|
||||
var c chan<- bool
|
||||
Ω(Object(c, 1)).Should(match("chan<- bool | len:0, cap:0", "nil"))
|
||||
var s []string
|
||||
Ω(Object(s, 1)).Should(match("[]string | len:0, cap:0", "nil"))
|
||||
var m map[string]bool
|
||||
Ω(Object(m, 1)).Should(match("map[string]bool | len:0", "nil"))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("formatting aliased types", func() {
|
||||
It("should print out the correct alias type", func() {
|
||||
Ω(Object(StringAlias("alias"), 1)).Should(match("format_test.StringAlias", `alias`))
|
||||
Ω(Object(ByteAlias("alias"), 1)).Should(matchRegexp(`format_test\.ByteAlias \| len:5, cap:\d+`, `alias`))
|
||||
Ω(Object(IntAlias(3), 1)).Should(match("format_test.IntAlias", "3"))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("handling nested things", func() {
|
||||
It("should produce a correctly nested representation", func() {
|
||||
s := ComplexStruct{
|
||||
Strings: []string{"lots", "of", "short", "strings"},
|
||||
SimpleThings: []*SimpleStruct{
|
||||
{"short", 7, true, []byte("succinct"), 17},
|
||||
{"something longer", 427, true, []byte("designed to wrap around nicely"), 30},
|
||||
},
|
||||
DataMaps: map[int]ByteAlias{
|
||||
17: ByteAlias("some substantially longer chunks of data"),
|
||||
1138: ByteAlias("that should make things wrap"),
|
||||
},
|
||||
}
|
||||
expected := `{
|
||||
Strings: \["lots", "of", "short", "strings"\],
|
||||
SimpleThings: \[
|
||||
{Name: "short", Enumeration: 7, Veritas: true, Data: "succinct", secret: 17},
|
||||
{
|
||||
Name: "something longer",
|
||||
Enumeration: 427,
|
||||
Veritas: true,
|
||||
Data: "designed to wrap around nicely",
|
||||
secret: 30,
|
||||
},
|
||||
\],
|
||||
DataMaps: {
|
||||
(17: "some substantially longer chunks of data"|1138: "that should make things wrap"),
|
||||
(17: "some substantially longer chunks of data"|1138: "that should make things wrap"),
|
||||
},
|
||||
}`
|
||||
Ω(Object(s, 1)).Should(matchRegexp(`format_test\.ComplexStruct`, expected))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("formatting times", func() {
|
||||
It("should format time as RFC3339", func() {
|
||||
t := time.Date(2016, 10, 31, 9, 57, 23, 12345, time.UTC)
|
||||
Ω(Object(t, 1)).Should(match("time.Time", `2016-10-31T09:57:23.000012345Z`))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Handling unexported fields in structs", func() {
|
||||
It("should handle all the various types correctly", func() {
|
||||
a := int(5)
|
||||
s := SecretiveStruct{
|
||||
boolValue: true,
|
||||
intValue: 3,
|
||||
uintValue: 4,
|
||||
uintptrValue: 5,
|
||||
floatValue: 6.0,
|
||||
complexValue: complex(5.0, 3.0),
|
||||
chanValue: make(chan bool, 2),
|
||||
funcValue: func() {},
|
||||
pointerValue: &a,
|
||||
sliceValue: []string{"string", "slice"},
|
||||
byteSliceValue: []byte("bytes"),
|
||||
stringValue: "a string",
|
||||
arrValue: [3]int{11, 12, 13},
|
||||
byteArrValue: [3]byte{17, 20, 32},
|
||||
mapValue: map[string]int{"a key": 20, "b key": 30},
|
||||
structValue: AStruct{"exported"},
|
||||
interfaceValue: map[string]int{"a key": 17},
|
||||
}
|
||||
|
||||
expected := fmt.Sprintf(`{
|
||||
boolValue: true,
|
||||
intValue: 3,
|
||||
uintValue: 4,
|
||||
uintptrValue: 0x5,
|
||||
floatValue: 6,
|
||||
complexValue: \(5\+3i\),
|
||||
chanValue: %p,
|
||||
funcValue: %p,
|
||||
pointerValue: 5,
|
||||
sliceValue: \["string", "slice"\],
|
||||
byteSliceValue: "bytes",
|
||||
stringValue: "a string",
|
||||
arrValue: \[11, 12, 13\],
|
||||
byteArrValue: \[17, 20, 32\],
|
||||
mapValue: %s,
|
||||
structValue: {Exported: "exported"},
|
||||
interfaceValue: {"a key": 17},
|
||||
}`, s.chanValue, s.funcValue, hashMatchingRegexp(`"a key": 20`, `"b key": 30`))
|
||||
|
||||
Ω(Object(s, 1)).Should(matchRegexp(`format_test\.SecretiveStruct`, expected))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Handling interfaces", func() {
|
||||
It("should unpack the interface", func() {
|
||||
outerHash := map[string]interface{}{}
|
||||
innerHash := map[string]int{}
|
||||
|
||||
innerHash["inner"] = 3
|
||||
outerHash["integer"] = 2
|
||||
outerHash["map"] = innerHash
|
||||
|
||||
expected := hashMatchingRegexp(`"integer": 2`, `"map": {"inner": 3}`)
|
||||
Ω(Object(outerHash, 1)).Should(matchRegexp(`map\[string\]interface {} \| len:2`, expected))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Handling recursive things", func() {
|
||||
It("should not go crazy...", func() {
|
||||
m := map[string]interface{}{}
|
||||
m["integer"] = 2
|
||||
m["map"] = m
|
||||
Ω(Object(m, 1)).Should(ContainSubstring("..."))
|
||||
})
|
||||
|
||||
It("really should not go crazy...", func() {
|
||||
type complexKey struct {
|
||||
Value map[interface{}]int
|
||||
}
|
||||
|
||||
complexObject := complexKey{}
|
||||
complexObject.Value = make(map[interface{}]int)
|
||||
|
||||
complexObject.Value[&complexObject] = 2
|
||||
Ω(Object(complexObject, 1)).Should(ContainSubstring("..."))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("When instructed to use the Stringer representation", func() {
|
||||
BeforeEach(func() {
|
||||
UseStringerRepresentation = true
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
UseStringerRepresentation = false
|
||||
})
|
||||
|
||||
Context("when passed a GoStringer", func() {
|
||||
It("should use what GoString() returns", func() {
|
||||
Ω(Object(GoStringer{}, 1)).Should(ContainSubstring("<format_test.GoStringer>: go-string"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when passed a stringer", func() {
|
||||
It("should use what String() returns", func() {
|
||||
Ω(Object(Stringer{}, 1)).Should(ContainSubstring("<format_test.Stringer>: string"))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Printing a context.Context field", func() {
|
||||
|
||||
type structWithContext struct {
|
||||
Context Ctx
|
||||
Value string
|
||||
}
|
||||
|
||||
context := ctx{}
|
||||
objWithContext := structWithContext{Value: "some-value", Context: &context}
|
||||
|
||||
It("Suppresses the content by default", func() {
|
||||
Ω(Object(objWithContext, 1)).Should(ContainSubstring("<suppressed context>"))
|
||||
})
|
||||
|
||||
It("Doesn't supress the context if it's the object being printed", func() {
|
||||
Ω(Object(context, 1)).ShouldNot(MatchRegexp("^.*<suppressed context>$"))
|
||||
})
|
||||
|
||||
Context("PrintContextObjects is set", func() {
|
||||
BeforeEach(func() {
|
||||
PrintContextObjects = true
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
PrintContextObjects = false
|
||||
})
|
||||
|
||||
It("Prints the context", func() {
|
||||
Ω(Object(objWithContext, 1)).ShouldNot(ContainSubstring("<suppressed context>"))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
var expectedLongStringFailureMessage = strings.TrimSpace(`
|
||||
Expected
|
||||
<string>: "...aaaaabaaaaa..."
|
||||
to equal |
|
||||
<string>: "...aaaaazaaaaa..."
|
||||
`)
|
||||
var expectedTruncatedEndStringFailureMessage = strings.TrimSpace(`
|
||||
Expected
|
||||
<string>: "baaaaa..."
|
||||
to equal |
|
||||
<string>: "zaaaaa..."
|
||||
`)
|
||||
var expectedTruncatedStartStringFailureMessage = strings.TrimSpace(`
|
||||
Expected
|
||||
<string>: "...aaaaab"
|
||||
to equal |
|
||||
<string>: "...aaaaaz"
|
||||
`)
|
||||
var expectedTruncatedStartSizeFailureMessage = strings.TrimSpace(`
|
||||
Expected
|
||||
<string>: "...aaaaaa"
|
||||
to equal |
|
||||
<string>: "...aaaaa"
|
||||
`)
|
||||
var expectedTruncatedStartSizeSwappedFailureMessage = strings.TrimSpace(`
|
||||
Expected
|
||||
<string>: "...aaaa"
|
||||
to equal |
|
||||
<string>: "...aaaaa"
|
||||
`)
|
||||
65
vendor/github.com/onsi/gomega/gomega_dsl.go
generated
vendored
65
vendor/github.com/onsi/gomega/gomega_dsl.go
generated
vendored
|
|
@ -24,11 +24,12 @@ import (
|
|||
"github.com/onsi/gomega/types"
|
||||
)
|
||||
|
||||
const GOMEGA_VERSION = "1.2.0"
|
||||
const GOMEGA_VERSION = "1.4.0"
|
||||
|
||||
const nilFailHandlerPanic = `You are trying to make an assertion, but Gomega's fail handler is nil.
|
||||
If you're using Ginkgo then you probably forgot to put your assertion in an It().
|
||||
Alternatively, you may have forgotten to register a fail handler with RegisterFailHandler() or RegisterTestingT().
|
||||
Depending on your vendoring solution you may be inadvertently importing gomega and subpackages (e.g. ghhtp, gexec,...) from different locations.
|
||||
`
|
||||
|
||||
var globalFailHandler types.GomegaFailHandler
|
||||
|
|
@ -45,7 +46,11 @@ func RegisterFailHandler(handler types.GomegaFailHandler) {
|
|||
}
|
||||
|
||||
//RegisterTestingT connects Gomega to Golang's XUnit style
|
||||
//Testing.T tests. You'll need to call this at the top of each XUnit style test:
|
||||
//Testing.T tests. It is now deprecated and you should use NewGomegaWithT() instead.
|
||||
//
|
||||
//Legacy Documentation:
|
||||
//
|
||||
//You'll need to call this at the top of each XUnit style test:
|
||||
//
|
||||
// func TestFarmHasCow(t *testing.T) {
|
||||
// RegisterTestingT(t)
|
||||
|
|
@ -58,6 +63,8 @@ func RegisterFailHandler(handler types.GomegaFailHandler) {
|
|||
// pass `t` down to the matcher itself). This means that you cannot run the XUnit style tests
|
||||
// in parallel as the global fail handler cannot point to more than one testing.T at a time.
|
||||
//
|
||||
// NewGomegaWithT() does not have this limitation
|
||||
//
|
||||
// (As an aside: Ginkgo gets around this limitation by running parallel tests in different *processes*).
|
||||
func RegisterTestingT(t types.GomegaTestingT) {
|
||||
RegisterFailHandler(testingtsupport.BuildTestingTGomegaFailHandler(t))
|
||||
|
|
@ -308,6 +315,60 @@ type GomegaAssertion interface {
|
|||
//OmegaMatcher is deprecated in favor of the better-named and better-organized types.GomegaMatcher but sticks around to support existing code that uses it
|
||||
type OmegaMatcher types.GomegaMatcher
|
||||
|
||||
//GomegaWithT wraps a *testing.T and provides `Expect`, `Eventually`, and `Consistently` methods. This allows you to leverage
|
||||
//Gomega's rich ecosystem of matchers in standard `testing` test suites.
|
||||
//
|
||||
//Use `NewGomegaWithT` to instantiate a `GomegaWithT`
|
||||
type GomegaWithT struct {
|
||||
t types.GomegaTestingT
|
||||
}
|
||||
|
||||
//NewGomegaWithT takes a *testing.T and returngs a `GomegaWithT` allowing you to use `Expect`, `Eventually`, and `Consistently` along with
|
||||
//Gomega's rich ecosystem of matchers in standard `testing` test suits.
|
||||
//
|
||||
// func TestFarmHasCow(t *testing.T) {
|
||||
// g := GomegaWithT(t)
|
||||
//
|
||||
// f := farm.New([]string{"Cow", "Horse"})
|
||||
// g.Expect(f.HasCow()).To(BeTrue(), "Farm should have cow")
|
||||
// }
|
||||
func NewGomegaWithT(t types.GomegaTestingT) *GomegaWithT {
|
||||
return &GomegaWithT{
|
||||
t: t,
|
||||
}
|
||||
}
|
||||
|
||||
//See documentation for Expect
|
||||
func (g *GomegaWithT) Expect(actual interface{}, extra ...interface{}) GomegaAssertion {
|
||||
return assertion.New(actual, testingtsupport.BuildTestingTGomegaFailHandler(g.t), 0, extra...)
|
||||
}
|
||||
|
||||
//See documentation for Eventually
|
||||
func (g *GomegaWithT) Eventually(actual interface{}, intervals ...interface{}) GomegaAsyncAssertion {
|
||||
timeoutInterval := defaultEventuallyTimeout
|
||||
pollingInterval := defaultEventuallyPollingInterval
|
||||
if len(intervals) > 0 {
|
||||
timeoutInterval = toDuration(intervals[0])
|
||||
}
|
||||
if len(intervals) > 1 {
|
||||
pollingInterval = toDuration(intervals[1])
|
||||
}
|
||||
return asyncassertion.New(asyncassertion.AsyncAssertionTypeEventually, actual, testingtsupport.BuildTestingTGomegaFailHandler(g.t), timeoutInterval, pollingInterval, 0)
|
||||
}
|
||||
|
||||
//See documentation for Consistently
|
||||
func (g *GomegaWithT) Consistently(actual interface{}, intervals ...interface{}) GomegaAsyncAssertion {
|
||||
timeoutInterval := defaultConsistentlyDuration
|
||||
pollingInterval := defaultConsistentlyPollingInterval
|
||||
if len(intervals) > 0 {
|
||||
timeoutInterval = toDuration(intervals[0])
|
||||
}
|
||||
if len(intervals) > 1 {
|
||||
pollingInterval = toDuration(intervals[1])
|
||||
}
|
||||
return asyncassertion.New(asyncassertion.AsyncAssertionTypeConsistently, actual, testingtsupport.BuildTestingTGomegaFailHandler(g.t), timeoutInterval, pollingInterval, 0)
|
||||
}
|
||||
|
||||
func toDuration(input interface{}) time.Duration {
|
||||
duration, ok := input.(time.Duration)
|
||||
if ok {
|
||||
|
|
|
|||
13
vendor/github.com/onsi/gomega/internal/assertion/assertion_suite_test.go
generated
vendored
13
vendor/github.com/onsi/gomega/internal/assertion/assertion_suite_test.go
generated
vendored
|
|
@ -1,13 +0,0 @@
|
|||
package assertion_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAssertion(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Assertion Suite")
|
||||
}
|
||||
252
vendor/github.com/onsi/gomega/internal/assertion/assertion_test.go
generated
vendored
252
vendor/github.com/onsi/gomega/internal/assertion/assertion_test.go
generated
vendored
|
|
@ -1,252 +0,0 @@
|
|||
package assertion_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/internal/assertion"
|
||||
"github.com/onsi/gomega/internal/fakematcher"
|
||||
)
|
||||
|
||||
var _ = Describe("Assertion", func() {
|
||||
var (
|
||||
a *Assertion
|
||||
failureMessage string
|
||||
failureCallerSkip int
|
||||
matcher *fakematcher.FakeMatcher
|
||||
)
|
||||
|
||||
input := "The thing I'm testing"
|
||||
|
||||
var fakeFailHandler = func(message string, callerSkip ...int) {
|
||||
failureMessage = message
|
||||
if len(callerSkip) == 1 {
|
||||
failureCallerSkip = callerSkip[0]
|
||||
}
|
||||
}
|
||||
|
||||
BeforeEach(func() {
|
||||
matcher = &fakematcher.FakeMatcher{}
|
||||
failureMessage = ""
|
||||
failureCallerSkip = 0
|
||||
a = New(input, fakeFailHandler, 1)
|
||||
})
|
||||
|
||||
Context("when called", func() {
|
||||
It("should pass the provided input value to the matcher", func() {
|
||||
a.Should(matcher)
|
||||
|
||||
Ω(matcher.ReceivedActual).Should(Equal(input))
|
||||
matcher.ReceivedActual = ""
|
||||
|
||||
a.ShouldNot(matcher)
|
||||
|
||||
Ω(matcher.ReceivedActual).Should(Equal(input))
|
||||
matcher.ReceivedActual = ""
|
||||
|
||||
a.To(matcher)
|
||||
|
||||
Ω(matcher.ReceivedActual).Should(Equal(input))
|
||||
matcher.ReceivedActual = ""
|
||||
|
||||
a.ToNot(matcher)
|
||||
|
||||
Ω(matcher.ReceivedActual).Should(Equal(input))
|
||||
matcher.ReceivedActual = ""
|
||||
|
||||
a.NotTo(matcher)
|
||||
|
||||
Ω(matcher.ReceivedActual).Should(Equal(input))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the matcher succeeds", func() {
|
||||
BeforeEach(func() {
|
||||
matcher.MatchesToReturn = true
|
||||
matcher.ErrToReturn = nil
|
||||
})
|
||||
|
||||
Context("and a positive assertion is being made", func() {
|
||||
It("should not call the failure callback", func() {
|
||||
a.Should(matcher)
|
||||
Ω(failureMessage).Should(Equal(""))
|
||||
})
|
||||
|
||||
It("should be true", func() {
|
||||
Ω(a.Should(matcher)).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
Context("and a negative assertion is being made", func() {
|
||||
It("should call the failure callback", func() {
|
||||
a.ShouldNot(matcher)
|
||||
Ω(failureMessage).Should(Equal("negative: The thing I'm testing"))
|
||||
Ω(failureCallerSkip).Should(Equal(3))
|
||||
})
|
||||
|
||||
It("should be false", func() {
|
||||
Ω(a.ShouldNot(matcher)).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the matcher fails", func() {
|
||||
BeforeEach(func() {
|
||||
matcher.MatchesToReturn = false
|
||||
matcher.ErrToReturn = nil
|
||||
})
|
||||
|
||||
Context("and a positive assertion is being made", func() {
|
||||
It("should call the failure callback", func() {
|
||||
a.Should(matcher)
|
||||
Ω(failureMessage).Should(Equal("positive: The thing I'm testing"))
|
||||
Ω(failureCallerSkip).Should(Equal(3))
|
||||
})
|
||||
|
||||
It("should be false", func() {
|
||||
Ω(a.Should(matcher)).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
|
||||
Context("and a negative assertion is being made", func() {
|
||||
It("should not call the failure callback", func() {
|
||||
a.ShouldNot(matcher)
|
||||
Ω(failureMessage).Should(Equal(""))
|
||||
})
|
||||
|
||||
It("should be true", func() {
|
||||
Ω(a.ShouldNot(matcher)).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("When reporting a failure", func() {
|
||||
BeforeEach(func() {
|
||||
matcher.MatchesToReturn = false
|
||||
matcher.ErrToReturn = nil
|
||||
})
|
||||
|
||||
Context("and there is an optional description", func() {
|
||||
It("should append the description to the failure message", func() {
|
||||
a.Should(matcher, "A description")
|
||||
Ω(failureMessage).Should(Equal("A description\npositive: The thing I'm testing"))
|
||||
Ω(failureCallerSkip).Should(Equal(3))
|
||||
})
|
||||
})
|
||||
|
||||
Context("and there are multiple arguments to the optional description", func() {
|
||||
It("should append the formatted description to the failure message", func() {
|
||||
a.Should(matcher, "A description of [%d]", 3)
|
||||
Ω(failureMessage).Should(Equal("A description of [3]\npositive: The thing I'm testing"))
|
||||
Ω(failureCallerSkip).Should(Equal(3))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("When the matcher returns an error", func() {
|
||||
BeforeEach(func() {
|
||||
matcher.ErrToReturn = errors.New("Kaboom!")
|
||||
})
|
||||
|
||||
Context("and a positive assertion is being made", func() {
|
||||
It("should call the failure callback", func() {
|
||||
matcher.MatchesToReturn = true
|
||||
a.Should(matcher)
|
||||
Ω(failureMessage).Should(Equal("Kaboom!"))
|
||||
Ω(failureCallerSkip).Should(Equal(3))
|
||||
})
|
||||
})
|
||||
|
||||
Context("and a negative assertion is being made", func() {
|
||||
It("should call the failure callback", func() {
|
||||
matcher.MatchesToReturn = false
|
||||
a.ShouldNot(matcher)
|
||||
Ω(failureMessage).Should(Equal("Kaboom!"))
|
||||
Ω(failureCallerSkip).Should(Equal(3))
|
||||
})
|
||||
})
|
||||
|
||||
It("should always be false", func() {
|
||||
Ω(a.Should(matcher)).Should(BeFalse())
|
||||
Ω(a.ShouldNot(matcher)).Should(BeFalse())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when there are extra parameters", func() {
|
||||
It("(a simple example)", func() {
|
||||
Ω(func() (string, int, error) {
|
||||
return "foo", 0, nil
|
||||
}()).Should(Equal("foo"))
|
||||
})
|
||||
|
||||
Context("when the parameters are all nil or zero", func() {
|
||||
It("should invoke the matcher", func() {
|
||||
matcher.MatchesToReturn = true
|
||||
matcher.ErrToReturn = nil
|
||||
|
||||
var typedNil []string
|
||||
a = New(input, fakeFailHandler, 1, 0, nil, typedNil)
|
||||
|
||||
result := a.Should(matcher)
|
||||
Ω(result).Should(BeTrue())
|
||||
Ω(matcher.ReceivedActual).Should(Equal(input))
|
||||
|
||||
Ω(failureMessage).Should(BeZero())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when any of the parameters are not nil or zero", func() {
|
||||
It("should call the failure callback", func() {
|
||||
matcher.MatchesToReturn = false
|
||||
matcher.ErrToReturn = nil
|
||||
|
||||
a = New(input, fakeFailHandler, 1, errors.New("foo"))
|
||||
result := a.Should(matcher)
|
||||
Ω(result).Should(BeFalse())
|
||||
Ω(matcher.ReceivedActual).Should(BeZero(), "The matcher doesn't even get called")
|
||||
Ω(failureMessage).Should(ContainSubstring("foo"))
|
||||
failureMessage = ""
|
||||
|
||||
a = New(input, fakeFailHandler, 1, nil, 1)
|
||||
result = a.ShouldNot(matcher)
|
||||
Ω(result).Should(BeFalse())
|
||||
Ω(failureMessage).Should(ContainSubstring("1"))
|
||||
failureMessage = ""
|
||||
|
||||
a = New(input, fakeFailHandler, 1, nil, 0, []string{"foo"})
|
||||
result = a.To(matcher)
|
||||
Ω(result).Should(BeFalse())
|
||||
Ω(failureMessage).Should(ContainSubstring("foo"))
|
||||
failureMessage = ""
|
||||
|
||||
a = New(input, fakeFailHandler, 1, nil, 0, []string{"foo"})
|
||||
result = a.ToNot(matcher)
|
||||
Ω(result).Should(BeFalse())
|
||||
Ω(failureMessage).Should(ContainSubstring("foo"))
|
||||
failureMessage = ""
|
||||
|
||||
a = New(input, fakeFailHandler, 1, nil, 0, []string{"foo"})
|
||||
result = a.NotTo(matcher)
|
||||
Ω(result).Should(BeFalse())
|
||||
Ω(failureMessage).Should(ContainSubstring("foo"))
|
||||
Ω(failureCallerSkip).Should(Equal(3))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("Making an assertion without a registered fail handler", func() {
|
||||
It("should panic", func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
RegisterFailHandler(Fail)
|
||||
if e == nil {
|
||||
Fail("expected a panic to have occurred")
|
||||
}
|
||||
}()
|
||||
|
||||
RegisterFailHandler(nil)
|
||||
Ω(true).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
})
|
||||
13
vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion_suite_test.go
generated
vendored
13
vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion_suite_test.go
generated
vendored
|
|
@ -1,13 +0,0 @@
|
|||
package asyncassertion_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAsyncAssertion(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "AsyncAssertion Suite")
|
||||
}
|
||||
345
vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion_test.go
generated
vendored
345
vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion_test.go
generated
vendored
|
|
@ -1,345 +0,0 @@
|
|||
package asyncassertion_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/internal/asyncassertion"
|
||||
)
|
||||
|
||||
var _ = Describe("Async Assertion", func() {
|
||||
var (
|
||||
failureMessage string
|
||||
callerSkip int
|
||||
)
|
||||
|
||||
var fakeFailHandler = func(message string, skip ...int) {
|
||||
failureMessage = message
|
||||
callerSkip = skip[0]
|
||||
}
|
||||
|
||||
BeforeEach(func() {
|
||||
failureMessage = ""
|
||||
callerSkip = 0
|
||||
})
|
||||
|
||||
Describe("Eventually", func() {
|
||||
Context("the positive case", func() {
|
||||
It("should poll the function and matcher", func() {
|
||||
counter := 0
|
||||
a := New(AsyncAssertionTypeEventually, func() int {
|
||||
counter++
|
||||
return counter
|
||||
}, fakeFailHandler, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
|
||||
|
||||
a.Should(BeNumerically("==", 5))
|
||||
Ω(failureMessage).Should(BeZero())
|
||||
})
|
||||
|
||||
It("should continue when the matcher errors", func() {
|
||||
counter := 0
|
||||
a := New(AsyncAssertionTypeEventually, func() interface{} {
|
||||
counter++
|
||||
if counter == 5 {
|
||||
return "not-a-number" //this should cause the matcher to error
|
||||
}
|
||||
return counter
|
||||
}, fakeFailHandler, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
|
||||
|
||||
a.Should(BeNumerically("==", 5), "My description %d", 2)
|
||||
|
||||
Ω(failureMessage).Should(ContainSubstring("Timed out after"))
|
||||
Ω(failureMessage).Should(ContainSubstring("My description 2"))
|
||||
Ω(callerSkip).Should(Equal(4))
|
||||
})
|
||||
|
||||
It("should be able to timeout", func() {
|
||||
counter := 0
|
||||
a := New(AsyncAssertionTypeEventually, func() int {
|
||||
counter++
|
||||
return counter
|
||||
}, fakeFailHandler, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
|
||||
|
||||
a.Should(BeNumerically(">", 100), "My description %d", 2)
|
||||
|
||||
Ω(counter).Should(BeNumerically(">", 8))
|
||||
Ω(counter).Should(BeNumerically("<=", 10))
|
||||
Ω(failureMessage).Should(ContainSubstring("Timed out after"))
|
||||
Ω(failureMessage).Should(MatchRegexp(`\<int\>: \d`), "Should pass the correct value to the matcher message formatter.")
|
||||
Ω(failureMessage).Should(ContainSubstring("My description 2"))
|
||||
Ω(callerSkip).Should(Equal(4))
|
||||
})
|
||||
})
|
||||
|
||||
Context("the negative case", func() {
|
||||
It("should poll the function and matcher", func() {
|
||||
counter := 0
|
||||
a := New(AsyncAssertionTypeEventually, func() int {
|
||||
counter += 1
|
||||
return counter
|
||||
}, fakeFailHandler, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
|
||||
|
||||
a.ShouldNot(BeNumerically("<", 3))
|
||||
|
||||
Ω(counter).Should(Equal(3))
|
||||
Ω(failureMessage).Should(BeZero())
|
||||
})
|
||||
|
||||
It("should timeout when the matcher errors", func() {
|
||||
a := New(AsyncAssertionTypeEventually, func() interface{} {
|
||||
return 0 //this should cause the matcher to error
|
||||
}, fakeFailHandler, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
|
||||
|
||||
a.ShouldNot(HaveLen(0), "My description %d", 2)
|
||||
|
||||
Ω(failureMessage).Should(ContainSubstring("Timed out after"))
|
||||
Ω(failureMessage).Should(ContainSubstring("Error:"))
|
||||
Ω(failureMessage).Should(ContainSubstring("My description 2"))
|
||||
Ω(callerSkip).Should(Equal(4))
|
||||
})
|
||||
|
||||
It("should be able to timeout", func() {
|
||||
a := New(AsyncAssertionTypeEventually, func() int {
|
||||
return 0
|
||||
}, fakeFailHandler, time.Duration(0.1*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
|
||||
|
||||
a.ShouldNot(Equal(0), "My description %d", 2)
|
||||
|
||||
Ω(failureMessage).Should(ContainSubstring("Timed out after"))
|
||||
Ω(failureMessage).Should(ContainSubstring("<int>: 0"), "Should pass the correct value to the matcher message formatter.")
|
||||
Ω(failureMessage).Should(ContainSubstring("My description 2"))
|
||||
Ω(callerSkip).Should(Equal(4))
|
||||
})
|
||||
})
|
||||
|
||||
Context("with a function that returns multiple values", func() {
|
||||
It("should eventually succeed if the additional arguments are nil", func() {
|
||||
i := 0
|
||||
Eventually(func() (int, error) {
|
||||
i++
|
||||
return i, nil
|
||||
}).Should(Equal(10))
|
||||
})
|
||||
|
||||
It("should eventually timeout if the additional arguments are not nil", func() {
|
||||
i := 0
|
||||
a := New(AsyncAssertionTypeEventually, func() (int, error) {
|
||||
i++
|
||||
return i, errors.New("bam")
|
||||
}, fakeFailHandler, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
|
||||
a.Should(Equal(2))
|
||||
|
||||
Ω(failureMessage).Should(ContainSubstring("Timed out after"))
|
||||
Ω(failureMessage).Should(ContainSubstring("Error:"))
|
||||
Ω(failureMessage).Should(ContainSubstring("bam"))
|
||||
Ω(callerSkip).Should(Equal(4))
|
||||
})
|
||||
})
|
||||
|
||||
Context("Making an assertion without a registered fail handler", func() {
|
||||
It("should panic", func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
RegisterFailHandler(Fail)
|
||||
if e == nil {
|
||||
Fail("expected a panic to have occurred")
|
||||
}
|
||||
}()
|
||||
|
||||
RegisterFailHandler(nil)
|
||||
c := make(chan bool, 1)
|
||||
c <- true
|
||||
Eventually(c).Should(Receive())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Consistently", func() {
|
||||
Describe("The positive case", func() {
|
||||
Context("when the matcher consistently passes for the duration", func() {
|
||||
It("should pass", func() {
|
||||
calls := 0
|
||||
a := New(AsyncAssertionTypeConsistently, func() string {
|
||||
calls++
|
||||
return "foo"
|
||||
}, fakeFailHandler, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
|
||||
|
||||
a.Should(Equal("foo"))
|
||||
Ω(calls).Should(BeNumerically(">", 8))
|
||||
Ω(calls).Should(BeNumerically("<=", 10))
|
||||
Ω(failureMessage).Should(BeZero())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the matcher fails at some point", func() {
|
||||
It("should fail", func() {
|
||||
calls := 0
|
||||
a := New(AsyncAssertionTypeConsistently, func() interface{} {
|
||||
calls++
|
||||
if calls > 5 {
|
||||
return "bar"
|
||||
}
|
||||
return "foo"
|
||||
}, fakeFailHandler, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
|
||||
|
||||
a.Should(Equal("foo"))
|
||||
Ω(failureMessage).Should(ContainSubstring("to equal"))
|
||||
Ω(callerSkip).Should(Equal(4))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the matcher errors at some point", func() {
|
||||
It("should fail", func() {
|
||||
calls := 0
|
||||
a := New(AsyncAssertionTypeConsistently, func() interface{} {
|
||||
calls++
|
||||
if calls > 5 {
|
||||
return 3
|
||||
}
|
||||
return []int{1, 2, 3}
|
||||
}, fakeFailHandler, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
|
||||
|
||||
a.Should(HaveLen(3))
|
||||
Ω(failureMessage).Should(ContainSubstring("HaveLen matcher expects"))
|
||||
Ω(callerSkip).Should(Equal(4))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("The negative case", func() {
|
||||
Context("when the matcher consistently passes for the duration", func() {
|
||||
It("should pass", func() {
|
||||
c := make(chan bool)
|
||||
a := New(AsyncAssertionTypeConsistently, c, fakeFailHandler, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
|
||||
|
||||
a.ShouldNot(Receive())
|
||||
Ω(failureMessage).Should(BeZero())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the matcher fails at some point", func() {
|
||||
It("should fail", func() {
|
||||
c := make(chan bool)
|
||||
go func() {
|
||||
time.Sleep(time.Duration(100 * time.Millisecond))
|
||||
c <- true
|
||||
}()
|
||||
|
||||
a := New(AsyncAssertionTypeConsistently, c, fakeFailHandler, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
|
||||
|
||||
a.ShouldNot(Receive())
|
||||
Ω(failureMessage).Should(ContainSubstring("not to receive anything"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when the matcher errors at some point", func() {
|
||||
It("should fail", func() {
|
||||
calls := 0
|
||||
a := New(AsyncAssertionTypeConsistently, func() interface{} {
|
||||
calls++
|
||||
return calls
|
||||
}, fakeFailHandler, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
|
||||
|
||||
a.ShouldNot(BeNumerically(">", 5))
|
||||
Ω(failureMessage).Should(ContainSubstring("not to be >"))
|
||||
Ω(callerSkip).Should(Equal(4))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("with a function that returns multiple values", func() {
|
||||
It("should consistently succeed if the additional arguments are nil", func() {
|
||||
i := 2
|
||||
Consistently(func() (int, error) {
|
||||
i++
|
||||
return i, nil
|
||||
}).Should(BeNumerically(">=", 2))
|
||||
})
|
||||
|
||||
It("should eventually timeout if the additional arguments are not nil", func() {
|
||||
i := 2
|
||||
a := New(AsyncAssertionTypeEventually, func() (int, error) {
|
||||
i++
|
||||
return i, errors.New("bam")
|
||||
}, fakeFailHandler, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
|
||||
a.Should(BeNumerically(">=", 2))
|
||||
|
||||
Ω(failureMessage).Should(ContainSubstring("Error:"))
|
||||
Ω(failureMessage).Should(ContainSubstring("bam"))
|
||||
Ω(callerSkip).Should(Equal(4))
|
||||
})
|
||||
})
|
||||
|
||||
Context("Making an assertion without a registered fail handler", func() {
|
||||
It("should panic", func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
RegisterFailHandler(Fail)
|
||||
if e == nil {
|
||||
Fail("expected a panic to have occurred")
|
||||
}
|
||||
}()
|
||||
|
||||
RegisterFailHandler(nil)
|
||||
c := make(chan bool)
|
||||
Consistently(c).ShouldNot(Receive())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("when passed a function with the wrong # or arguments & returns", func() {
|
||||
It("should panic", func() {
|
||||
Ω(func() {
|
||||
New(AsyncAssertionTypeEventually, func() {}, fakeFailHandler, 0, 0, 1)
|
||||
}).Should(Panic())
|
||||
|
||||
Ω(func() {
|
||||
New(AsyncAssertionTypeEventually, func(a string) int { return 0 }, fakeFailHandler, 0, 0, 1)
|
||||
}).Should(Panic())
|
||||
|
||||
Ω(func() {
|
||||
New(AsyncAssertionTypeEventually, func() int { return 0 }, fakeFailHandler, 0, 0, 1)
|
||||
}).ShouldNot(Panic())
|
||||
|
||||
Ω(func() {
|
||||
New(AsyncAssertionTypeEventually, func() (int, error) { return 0, nil }, fakeFailHandler, 0, 0, 1)
|
||||
}).ShouldNot(Panic())
|
||||
})
|
||||
})
|
||||
|
||||
Describe("bailing early", func() {
|
||||
Context("when actual is a value", func() {
|
||||
It("Eventually should bail out and fail early if the matcher says to", func() {
|
||||
c := make(chan bool)
|
||||
close(c)
|
||||
|
||||
t := time.Now()
|
||||
failures := InterceptGomegaFailures(func() {
|
||||
Eventually(c, 0.1).Should(Receive())
|
||||
})
|
||||
Ω(time.Since(t)).Should(BeNumerically("<", 90*time.Millisecond))
|
||||
|
||||
Ω(failures).Should(HaveLen(1))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when actual is a function", func() {
|
||||
It("should never bail early", func() {
|
||||
c := make(chan bool)
|
||||
close(c)
|
||||
|
||||
t := time.Now()
|
||||
failures := InterceptGomegaFailures(func() {
|
||||
Eventually(func() chan bool {
|
||||
return c
|
||||
}, 0.1).Should(Receive())
|
||||
})
|
||||
Ω(time.Since(t)).Should(BeNumerically(">=", 90*time.Millisecond))
|
||||
|
||||
Ω(failures).Should(HaveLen(1))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
12
vendor/github.com/onsi/gomega/internal/testingtsupport/testing_t_support_test.go
generated
vendored
12
vendor/github.com/onsi/gomega/internal/testingtsupport/testing_t_support_test.go
generated
vendored
|
|
@ -1,12 +0,0 @@
|
|||
package testingtsupport_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTestingT(t *testing.T) {
|
||||
RegisterTestingT(t)
|
||||
Ω(true).Should(BeTrue())
|
||||
}
|
||||
76
vendor/github.com/onsi/gomega/matchers.go
generated
vendored
76
vendor/github.com/onsi/gomega/matchers.go
generated
vendored
|
|
@ -53,7 +53,7 @@ func BeFalse() types.GomegaMatcher {
|
|||
//HaveOccurred succeeds if actual is a non-nil error
|
||||
//The typical Go error checking pattern looks like:
|
||||
// err := SomethingThatMightFail()
|
||||
// Ω(err).ShouldNot(HaveOccurred())
|
||||
// Expect(err).ShouldNot(HaveOccurred())
|
||||
func HaveOccurred() types.GomegaMatcher {
|
||||
return &matchers.HaveOccurredMatcher{}
|
||||
}
|
||||
|
|
@ -61,10 +61,10 @@ func HaveOccurred() types.GomegaMatcher {
|
|||
//Succeed passes if actual is a nil error
|
||||
//Succeed is intended to be used with functions that return a single error value. Instead of
|
||||
// err := SomethingThatMightFail()
|
||||
// Ω(err).ShouldNot(HaveOccurred())
|
||||
// Expect(err).ShouldNot(HaveOccurred())
|
||||
//
|
||||
//You can write:
|
||||
// Ω(SomethingThatMightFail()).Should(Succeed())
|
||||
// Expect(SomethingThatMightFail()).Should(Succeed())
|
||||
//
|
||||
//It is a mistake to use Succeed with a function that has multiple return values. Gomega's Ω and Expect
|
||||
//functions automatically trigger failure if any return values after the first return value are non-zero/non-nil.
|
||||
|
|
@ -76,8 +76,8 @@ func Succeed() types.GomegaMatcher {
|
|||
//MatchError succeeds if actual is a non-nil error that matches the passed in string/error.
|
||||
//
|
||||
//These are valid use-cases:
|
||||
// Ω(err).Should(MatchError("an error")) //asserts that err.Error() == "an error"
|
||||
// Ω(err).Should(MatchError(SomeError)) //asserts that err == SomeError (via reflect.DeepEqual)
|
||||
// Expect(err).Should(MatchError("an error")) //asserts that err.Error() == "an error"
|
||||
// Expect(err).Should(MatchError(SomeError)) //asserts that err == SomeError (via reflect.DeepEqual)
|
||||
//
|
||||
//It is an error for err to be nil or an object that does not implement the Error interface
|
||||
func MatchError(expected interface{}) types.GomegaMatcher {
|
||||
|
|
@ -106,11 +106,11 @@ func BeClosed() types.GomegaMatcher {
|
|||
//
|
||||
//Receive returns immediately and never blocks:
|
||||
//
|
||||
//- If there is nothing on the channel `c` then Ω(c).Should(Receive()) will fail and Ω(c).ShouldNot(Receive()) will pass.
|
||||
//- If there is nothing on the channel `c` then Expect(c).Should(Receive()) will fail and Ω(c).ShouldNot(Receive()) will pass.
|
||||
//
|
||||
//- If the channel `c` is closed then Ω(c).Should(Receive()) will fail and Ω(c).ShouldNot(Receive()) will pass.
|
||||
//- If the channel `c` is closed then Expect(c).Should(Receive()) will fail and Ω(c).ShouldNot(Receive()) will pass.
|
||||
//
|
||||
//- If there is something on the channel `c` ready to be read, then Ω(c).Should(Receive()) will pass and Ω(c).ShouldNot(Receive()) will fail.
|
||||
//- If there is something on the channel `c` ready to be read, then Expect(c).Should(Receive()) will pass and Ω(c).ShouldNot(Receive()) will fail.
|
||||
//
|
||||
//If you have a go-routine running in the background that will write to channel `c` you can:
|
||||
// Eventually(c).Should(Receive())
|
||||
|
|
@ -121,7 +121,7 @@ func BeClosed() types.GomegaMatcher {
|
|||
// Consistently(c).ShouldNot(Receive())
|
||||
//
|
||||
//You can pass `Receive` a matcher. If you do so, it will match the received object against the matcher. For example:
|
||||
// Ω(c).Should(Receive(Equal("foo")))
|
||||
// Expect(c).Should(Receive(Equal("foo")))
|
||||
//
|
||||
//When given a matcher, `Receive` will always fail if there is nothing to be received on the channel.
|
||||
//
|
||||
|
|
@ -134,8 +134,8 @@ func BeClosed() types.GomegaMatcher {
|
|||
//Finally, if you want to have a reference to the value *sent* to the channel you can pass the `Receive` matcher a pointer to a variable of the appropriate type:
|
||||
// var myThing thing
|
||||
// Eventually(thingChan).Should(Receive(&myThing))
|
||||
// Ω(myThing.Sprocket).Should(Equal("foo"))
|
||||
// Ω(myThing.IsValid()).Should(BeTrue())
|
||||
// Expect(myThing.Sprocket).Should(Equal("foo"))
|
||||
// Expect(myThing.IsValid()).Should(BeTrue())
|
||||
func Receive(args ...interface{}) types.GomegaMatcher {
|
||||
var arg interface{}
|
||||
if len(args) > 0 {
|
||||
|
|
@ -153,9 +153,9 @@ func Receive(args ...interface{}) types.GomegaMatcher {
|
|||
//
|
||||
//BeSent never blocks:
|
||||
//
|
||||
//- If the channel `c` is not ready to receive then Ω(c).Should(BeSent("foo")) will fail immediately
|
||||
//- If the channel `c` is not ready to receive then Expect(c).Should(BeSent("foo")) will fail immediately
|
||||
//- If the channel `c` is eventually ready to receive then Eventually(c).Should(BeSent("foo")) will succeed.. presuming the channel becomes ready to receive before Eventually's timeout
|
||||
//- If the channel `c` is closed then Ω(c).Should(BeSent("foo")) and Ω(c).ShouldNot(BeSent("foo")) will both fail immediately
|
||||
//- If the channel `c` is closed then Expect(c).Should(BeSent("foo")) and Ω(c).ShouldNot(BeSent("foo")) will both fail immediately
|
||||
//
|
||||
//Of course, the value is actually sent to the channel. The point of `BeSent` is less to make an assertion about the availability of the channel (which is typically an implementation detail that your test should not be concerned with).
|
||||
//Rather, the point of `BeSent` is to make it possible to easily and expressively write tests that can timeout on blocked channel sends.
|
||||
|
|
@ -259,7 +259,7 @@ func BeZero() types.GomegaMatcher {
|
|||
//ContainElement succeeds if actual contains the passed in element.
|
||||
//By default ContainElement() uses Equal() to perform the match, however a
|
||||
//matcher can be passed in instead:
|
||||
// Ω([]string{"Foo", "FooBar"}).Should(ContainElement(ContainSubstring("Bar")))
|
||||
// Expect([]string{"Foo", "FooBar"}).Should(ContainElement(ContainSubstring("Bar")))
|
||||
//
|
||||
//Actual must be an array, slice or map.
|
||||
//For maps, ContainElement searches through the map's values.
|
||||
|
|
@ -269,19 +269,19 @@ func ContainElement(element interface{}) types.GomegaMatcher {
|
|||
}
|
||||
}
|
||||
|
||||
//ConsistOf succeeds if actual contains preciely the elements passed into the matcher. The ordering of the elements does not matter.
|
||||
//ConsistOf succeeds if actual contains precisely the elements passed into the matcher. The ordering of the elements does not matter.
|
||||
//By default ConsistOf() uses Equal() to match the elements, however custom matchers can be passed in instead. Here are some examples:
|
||||
//
|
||||
// Ω([]string{"Foo", "FooBar"}).Should(ConsistOf("FooBar", "Foo"))
|
||||
// Ω([]string{"Foo", "FooBar"}).Should(ConsistOf(ContainSubstring("Bar"), "Foo"))
|
||||
// Ω([]string{"Foo", "FooBar"}).Should(ConsistOf(ContainSubstring("Foo"), ContainSubstring("Foo")))
|
||||
// Expect([]string{"Foo", "FooBar"}).Should(ConsistOf("FooBar", "Foo"))
|
||||
// Expect([]string{"Foo", "FooBar"}).Should(ConsistOf(ContainSubstring("Bar"), "Foo"))
|
||||
// Expect([]string{"Foo", "FooBar"}).Should(ConsistOf(ContainSubstring("Foo"), ContainSubstring("Foo")))
|
||||
//
|
||||
//Actual must be an array, slice or map. For maps, ConsistOf matches against the map's values.
|
||||
//
|
||||
//You typically pass variadic arguments to ConsistOf (as in the examples above). However, if you need to pass in a slice you can provided that it
|
||||
//is the only element passed in to ConsistOf:
|
||||
//
|
||||
// Ω([]string{"Foo", "FooBar"}).Should(ConsistOf([]string{"FooBar", "Foo"}))
|
||||
// Expect([]string{"Foo", "FooBar"}).Should(ConsistOf([]string{"FooBar", "Foo"}))
|
||||
//
|
||||
//Note that Go's type system does not allow you to write this as ConsistOf([]string{"FooBar", "Foo"}...) as []string and []interface{} are different types - hence the need for this special rule.
|
||||
func ConsistOf(elements ...interface{}) types.GomegaMatcher {
|
||||
|
|
@ -293,7 +293,7 @@ func ConsistOf(elements ...interface{}) types.GomegaMatcher {
|
|||
//HaveKey succeeds if actual is a map with the passed in key.
|
||||
//By default HaveKey uses Equal() to perform the match, however a
|
||||
//matcher can be passed in instead:
|
||||
// Ω(map[string]string{"Foo": "Bar", "BazFoo": "Duck"}).Should(HaveKey(MatchRegexp(`.+Foo$`)))
|
||||
// Expect(map[string]string{"Foo": "Bar", "BazFoo": "Duck"}).Should(HaveKey(MatchRegexp(`.+Foo$`)))
|
||||
func HaveKey(key interface{}) types.GomegaMatcher {
|
||||
return &matchers.HaveKeyMatcher{
|
||||
Key: key,
|
||||
|
|
@ -303,8 +303,8 @@ func HaveKey(key interface{}) types.GomegaMatcher {
|
|||
//HaveKeyWithValue succeeds if actual is a map with the passed in key and value.
|
||||
//By default HaveKeyWithValue uses Equal() to perform the match, however a
|
||||
//matcher can be passed in instead:
|
||||
// Ω(map[string]string{"Foo": "Bar", "BazFoo": "Duck"}).Should(HaveKeyWithValue("Foo", "Bar"))
|
||||
// Ω(map[string]string{"Foo": "Bar", "BazFoo": "Duck"}).Should(HaveKeyWithValue(MatchRegexp(`.+Foo$`), "Bar"))
|
||||
// Expect(map[string]string{"Foo": "Bar", "BazFoo": "Duck"}).Should(HaveKeyWithValue("Foo", "Bar"))
|
||||
// Expect(map[string]string{"Foo": "Bar", "BazFoo": "Duck"}).Should(HaveKeyWithValue(MatchRegexp(`.+Foo$`), "Bar"))
|
||||
func HaveKeyWithValue(key interface{}, value interface{}) types.GomegaMatcher {
|
||||
return &matchers.HaveKeyWithValueMatcher{
|
||||
Key: key,
|
||||
|
|
@ -314,15 +314,15 @@ func HaveKeyWithValue(key interface{}, value interface{}) types.GomegaMatcher {
|
|||
|
||||
//BeNumerically performs numerical assertions in a type-agnostic way.
|
||||
//Actual and expected should be numbers, though the specific type of
|
||||
//number is irrelevant (floa32, float64, uint8, etc...).
|
||||
//number is irrelevant (float32, float64, uint8, etc...).
|
||||
//
|
||||
//There are six, self-explanatory, supported comparators:
|
||||
// Ω(1.0).Should(BeNumerically("==", 1))
|
||||
// Ω(1.0).Should(BeNumerically("~", 0.999, 0.01))
|
||||
// Ω(1.0).Should(BeNumerically(">", 0.9))
|
||||
// Ω(1.0).Should(BeNumerically(">=", 1.0))
|
||||
// Ω(1.0).Should(BeNumerically("<", 3))
|
||||
// Ω(1.0).Should(BeNumerically("<=", 1.0))
|
||||
// Expect(1.0).Should(BeNumerically("==", 1))
|
||||
// Expect(1.0).Should(BeNumerically("~", 0.999, 0.01))
|
||||
// Expect(1.0).Should(BeNumerically(">", 0.9))
|
||||
// Expect(1.0).Should(BeNumerically(">=", 1.0))
|
||||
// Expect(1.0).Should(BeNumerically("<", 3))
|
||||
// Expect(1.0).Should(BeNumerically("<=", 1.0))
|
||||
func BeNumerically(comparator string, compareTo ...interface{}) types.GomegaMatcher {
|
||||
return &matchers.BeNumericallyMatcher{
|
||||
Comparator: comparator,
|
||||
|
|
@ -332,8 +332,8 @@ func BeNumerically(comparator string, compareTo ...interface{}) types.GomegaMatc
|
|||
|
||||
//BeTemporally compares time.Time's like BeNumerically
|
||||
//Actual and expected must be time.Time. The comparators are the same as for BeNumerically
|
||||
// Ω(time.Now()).Should(BeTemporally(">", time.Time{}))
|
||||
// Ω(time.Now()).Should(BeTemporally("~", time.Now(), time.Second))
|
||||
// Expect(time.Now()).Should(BeTemporally(">", time.Time{}))
|
||||
// Expect(time.Now()).Should(BeTemporally("~", time.Now(), time.Second))
|
||||
func BeTemporally(comparator string, compareTo time.Time, threshold ...time.Duration) types.GomegaMatcher {
|
||||
return &matchers.BeTemporallyMatcher{
|
||||
Comparator: comparator,
|
||||
|
|
@ -344,10 +344,10 @@ func BeTemporally(comparator string, compareTo time.Time, threshold ...time.Dura
|
|||
|
||||
//BeAssignableToTypeOf succeeds if actual is assignable to the type of expected.
|
||||
//It will return an error when one of the values is nil.
|
||||
// Ω(0).Should(BeAssignableToTypeOf(0)) // Same values
|
||||
// Ω(5).Should(BeAssignableToTypeOf(-1)) // different values same type
|
||||
// Ω("foo").Should(BeAssignableToTypeOf("bar")) // different values same type
|
||||
// Ω(struct{ Foo string }{}).Should(BeAssignableToTypeOf(struct{ Foo string }{}))
|
||||
// Expect(0).Should(BeAssignableToTypeOf(0)) // Same values
|
||||
// Expect(5).Should(BeAssignableToTypeOf(-1)) // different values same type
|
||||
// Expect("foo").Should(BeAssignableToTypeOf("bar")) // different values same type
|
||||
// Expect(struct{ Foo string }{}).Should(BeAssignableToTypeOf(struct{ Foo string }{}))
|
||||
func BeAssignableToTypeOf(expected interface{}) types.GomegaMatcher {
|
||||
return &matchers.AssignableToTypeOfMatcher{
|
||||
Expected: expected,
|
||||
|
|
@ -366,13 +366,13 @@ func BeAnExistingFile() types.GomegaMatcher {
|
|||
return &matchers.BeAnExistingFileMatcher{}
|
||||
}
|
||||
|
||||
//BeARegularFile succeeds iff a file exists and is a regular file.
|
||||
//BeARegularFile succeeds if a file exists and is a regular file.
|
||||
//Actual must be a string representing the abs path to the file being checked.
|
||||
func BeARegularFile() types.GomegaMatcher {
|
||||
return &matchers.BeARegularFileMatcher{}
|
||||
}
|
||||
|
||||
//BeADirectory succeeds iff a file exists and is a directory.
|
||||
//BeADirectory succeeds if a file exists and is a directory.
|
||||
//Actual must be a string representing the abs path to the file being checked.
|
||||
func BeADirectory() types.GomegaMatcher {
|
||||
return &matchers.BeADirectoryMatcher{}
|
||||
|
|
@ -388,7 +388,7 @@ func And(ms ...types.GomegaMatcher) types.GomegaMatcher {
|
|||
}
|
||||
|
||||
//SatisfyAll is an alias for And().
|
||||
// Ω("hi").Should(SatisfyAll(HaveLen(2), Equal("hi")))
|
||||
// Expect("hi").Should(SatisfyAll(HaveLen(2), Equal("hi")))
|
||||
func SatisfyAll(matchers ...types.GomegaMatcher) types.GomegaMatcher {
|
||||
return And(matchers...)
|
||||
}
|
||||
|
|
|
|||
103
vendor/github.com/onsi/gomega/matchers/and_test.go
generated
vendored
103
vendor/github.com/onsi/gomega/matchers/and_test.go
generated
vendored
|
|
@ -1,103 +0,0 @@
|
|||
package matchers_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/matchers"
|
||||
"github.com/onsi/gomega/types"
|
||||
)
|
||||
|
||||
// sample data
|
||||
var (
|
||||
// example input
|
||||
input = "hi"
|
||||
// some matchers that succeed against the input
|
||||
true1 = HaveLen(2)
|
||||
true2 = Equal("hi")
|
||||
true3 = MatchRegexp("hi")
|
||||
// some matchers that fail against the input.
|
||||
false1 = HaveLen(1)
|
||||
false2 = Equal("hip")
|
||||
false3 = MatchRegexp("hope")
|
||||
)
|
||||
|
||||
// verifyFailureMessage expects the matcher to fail with the given input, and verifies the failure message.
|
||||
func verifyFailureMessage(m types.GomegaMatcher, input string, expectedFailureMsgFragment string) {
|
||||
Expect(m.Match(input)).To(BeFalse())
|
||||
Expect(m.FailureMessage(input)).To(Equal(
|
||||
"Expected\n <string>: " + input + "\n" + expectedFailureMsgFragment))
|
||||
}
|
||||
|
||||
var _ = Describe("AndMatcher", func() {
|
||||
It("works with positive cases", func() {
|
||||
Expect(input).To(And())
|
||||
Expect(input).To(And(true1))
|
||||
Expect(input).To(And(true1, true2))
|
||||
Expect(input).To(And(true1, true2, true3))
|
||||
|
||||
// use alias
|
||||
Expect(input).To(SatisfyAll(true1, true2, true3))
|
||||
})
|
||||
|
||||
It("works with negative cases", func() {
|
||||
Expect(input).ToNot(And(false1, false2))
|
||||
Expect(input).ToNot(And(true1, true2, false3))
|
||||
Expect(input).ToNot(And(true1, false2, false3))
|
||||
Expect(input).ToNot(And(false1, true1, true2))
|
||||
})
|
||||
|
||||
Context("failure messages", func() {
|
||||
Context("when match fails", func() {
|
||||
It("gives a descriptive message", func() {
|
||||
verifyFailureMessage(And(false1, true1), input, "to have length 1")
|
||||
verifyFailureMessage(And(true1, false2), input, "to equal\n <string>: hip")
|
||||
verifyFailureMessage(And(true1, true2, false3), input, "to match regular expression\n <string>: hope")
|
||||
})
|
||||
})
|
||||
|
||||
Context("when match succeeds, but expected it to fail", func() {
|
||||
It("gives a descriptive message", func() {
|
||||
verifyFailureMessage(Not(And(true1, true2)), input,
|
||||
`To not satisfy all of these matchers: [%!s(*matchers.HaveLenMatcher=&{2}) %!s(*matchers.EqualMatcher=&{hi})]`)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Context("MatchMayChangeInTheFuture", func() {
|
||||
Context("Match returned false", func() {
|
||||
Context("returns value of the failed matcher", func() {
|
||||
It("false if failed matcher not going to change", func() {
|
||||
// 3 matchers: 1st returns true, 2nd returns false and is not going to change, 3rd is never called
|
||||
m := And(Not(BeNil()), Or(), Equal(1))
|
||||
Expect(m.Match("hi")).To(BeFalse())
|
||||
Expect(m.(*AndMatcher).MatchMayChangeInTheFuture("hi")).To(BeFalse()) // empty Or() indicates not going to change
|
||||
})
|
||||
It("true if failed matcher indicates it might change", func() {
|
||||
// 3 matchers: 1st returns true, 2nd returns false and "might" change, 3rd is never called
|
||||
m := And(Not(BeNil()), Equal(5), Equal(1))
|
||||
Expect(m.Match("hi")).To(BeFalse())
|
||||
Expect(m.(*AndMatcher).MatchMayChangeInTheFuture("hi")).To(BeTrue()) // Equal(5) indicates it might change
|
||||
})
|
||||
})
|
||||
})
|
||||
Context("Match returned true", func() {
|
||||
It("returns true if any of the matchers could change", func() {
|
||||
// 3 matchers, all return true, and all could change
|
||||
m := And(Not(BeNil()), Equal("hi"), HaveLen(2))
|
||||
Expect(m.Match("hi")).To(BeTrue())
|
||||
Expect(m.(*AndMatcher).MatchMayChangeInTheFuture("hi")).To(BeTrue()) // all 3 of these matchers default to 'true'
|
||||
})
|
||||
It("returns false if none of the matchers could change", func() {
|
||||
// empty And() has the property of always matching, and never can change since there are no sub-matchers that could change
|
||||
m := And()
|
||||
Expect(m.Match("anything")).To(BeTrue())
|
||||
Expect(m.(*AndMatcher).MatchMayChangeInTheFuture("anything")).To(BeFalse())
|
||||
|
||||
// And() with 3 sub-matchers that return true, and can't change
|
||||
m = And(And(), And(), And())
|
||||
Expect(m.Match("hi")).To(BeTrue())
|
||||
Expect(m.(*AndMatcher).MatchMayChangeInTheFuture("hi")).To(BeFalse()) // the 3 empty And()'s won't change
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
6
vendor/github.com/onsi/gomega/matchers/assignable_to_type_of_matcher.go
generated
vendored
6
vendor/github.com/onsi/gomega/matchers/assignable_to_type_of_matcher.go
generated
vendored
|
|
@ -12,8 +12,12 @@ type AssignableToTypeOfMatcher struct {
|
|||
}
|
||||
|
||||
func (matcher *AssignableToTypeOfMatcher) Match(actual interface{}) (success bool, err error) {
|
||||
if actual == nil || matcher.Expected == nil {
|
||||
if actual == nil && matcher.Expected == nil {
|
||||
return false, fmt.Errorf("Refusing to compare <nil> to <nil>.\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.")
|
||||
} else if matcher.Expected == nil {
|
||||
return false, fmt.Errorf("Refusing to compare type to <nil>.\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.")
|
||||
} else if actual == nil {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
actualType := reflect.TypeOf(actual)
|
||||
|
|
|
|||
30
vendor/github.com/onsi/gomega/matchers/assignable_to_type_of_matcher_test.go
generated
vendored
30
vendor/github.com/onsi/gomega/matchers/assignable_to_type_of_matcher_test.go
generated
vendored
|
|
@ -1,30 +0,0 @@
|
|||
package matchers_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/matchers"
|
||||
)
|
||||
|
||||
var _ = Describe("AssignableToTypeOf", func() {
|
||||
Context("When asserting assignability between types", func() {
|
||||
It("should do the right thing", func() {
|
||||
Ω(0).Should(BeAssignableToTypeOf(0))
|
||||
Ω(5).Should(BeAssignableToTypeOf(-1))
|
||||
Ω("foo").Should(BeAssignableToTypeOf("bar"))
|
||||
Ω(struct{ Foo string }{}).Should(BeAssignableToTypeOf(struct{ Foo string }{}))
|
||||
|
||||
Ω(0).ShouldNot(BeAssignableToTypeOf("bar"))
|
||||
Ω(5).ShouldNot(BeAssignableToTypeOf(struct{ Foo string }{}))
|
||||
Ω("foo").ShouldNot(BeAssignableToTypeOf(42))
|
||||
})
|
||||
})
|
||||
|
||||
Context("When asserting nil values", func() {
|
||||
It("should error", func() {
|
||||
success, err := (&AssignableToTypeOfMatcher{Expected: nil}).Match(nil)
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(err).Should(HaveOccurred())
|
||||
})
|
||||
})
|
||||
})
|
||||
14
vendor/github.com/onsi/gomega/matchers/attributes_slice.go
generated
vendored
Normal file
14
vendor/github.com/onsi/gomega/matchers/attributes_slice.go
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package matchers
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type attributesSlice []xml.Attr
|
||||
|
||||
func (attrs attributesSlice) Len() int { return len(attrs) }
|
||||
func (attrs attributesSlice) Less(i, j int) bool {
|
||||
return strings.Compare(attrs[i].Name.Local, attrs[j].Name.Local) == -1
|
||||
}
|
||||
func (attrs attributesSlice) Swap(i, j int) { attrs[i], attrs[j] = attrs[j], attrs[i] }
|
||||
40
vendor/github.com/onsi/gomega/matchers/be_a_directory_test.go
generated
vendored
40
vendor/github.com/onsi/gomega/matchers/be_a_directory_test.go
generated
vendored
|
|
@ -1,40 +0,0 @@
|
|||
package matchers_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/matchers"
|
||||
)
|
||||
|
||||
var _ = Describe("BeADirectoryMatcher", func() {
|
||||
Context("when passed a string", func() {
|
||||
It("should do the right thing", func() {
|
||||
Ω("/dne/test").ShouldNot(BeADirectory())
|
||||
|
||||
tmpFile, err := ioutil.TempFile("", "gomega-test-tempfile")
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
defer os.Remove(tmpFile.Name())
|
||||
Ω(tmpFile.Name()).ShouldNot(BeADirectory())
|
||||
|
||||
tmpDir, err := ioutil.TempDir("", "gomega-test-tempdir")
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
defer os.Remove(tmpDir)
|
||||
Ω(tmpDir).Should(BeADirectory())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when passed something else", func() {
|
||||
It("should error", func() {
|
||||
success, err := (&BeADirectoryMatcher{}).Match(nil)
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(err).Should(HaveOccurred())
|
||||
|
||||
success, err = (&BeADirectoryMatcher{}).Match(true)
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(err).Should(HaveOccurred())
|
||||
})
|
||||
})
|
||||
})
|
||||
40
vendor/github.com/onsi/gomega/matchers/be_a_regular_file_test.go
generated
vendored
40
vendor/github.com/onsi/gomega/matchers/be_a_regular_file_test.go
generated
vendored
|
|
@ -1,40 +0,0 @@
|
|||
package matchers_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/matchers"
|
||||
)
|
||||
|
||||
var _ = Describe("BeARegularFileMatcher", func() {
|
||||
Context("when passed a string", func() {
|
||||
It("should do the right thing", func() {
|
||||
Ω("/dne/test").ShouldNot(BeARegularFile())
|
||||
|
||||
tmpFile, err := ioutil.TempFile("", "gomega-test-tempfile")
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
defer os.Remove(tmpFile.Name())
|
||||
Ω(tmpFile.Name()).Should(BeARegularFile())
|
||||
|
||||
tmpDir, err := ioutil.TempDir("", "gomega-test-tempdir")
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
defer os.Remove(tmpDir)
|
||||
Ω(tmpDir).ShouldNot(BeARegularFile())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when passed something else", func() {
|
||||
It("should error", func() {
|
||||
success, err := (&BeARegularFileMatcher{}).Match(nil)
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(err).Should(HaveOccurred())
|
||||
|
||||
success, err = (&BeARegularFileMatcher{}).Match(true)
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(err).Should(HaveOccurred())
|
||||
})
|
||||
})
|
||||
})
|
||||
40
vendor/github.com/onsi/gomega/matchers/be_an_existing_file_test.go
generated
vendored
40
vendor/github.com/onsi/gomega/matchers/be_an_existing_file_test.go
generated
vendored
|
|
@ -1,40 +0,0 @@
|
|||
package matchers_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/matchers"
|
||||
)
|
||||
|
||||
var _ = Describe("BeAnExistingFileMatcher", func() {
|
||||
Context("when passed a string", func() {
|
||||
It("should do the right thing", func() {
|
||||
Ω("/dne/test").ShouldNot(BeAnExistingFile())
|
||||
|
||||
tmpFile, err := ioutil.TempFile("", "gomega-test-tempfile")
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
defer os.Remove(tmpFile.Name())
|
||||
Ω(tmpFile.Name()).Should(BeAnExistingFile())
|
||||
|
||||
tmpDir, err := ioutil.TempDir("", "gomega-test-tempdir")
|
||||
Ω(err).ShouldNot(HaveOccurred())
|
||||
defer os.Remove(tmpDir)
|
||||
Ω(tmpDir).Should(BeAnExistingFile())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when passed something else", func() {
|
||||
It("should error", func() {
|
||||
success, err := (&BeAnExistingFileMatcher{}).Match(nil)
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(err).Should(HaveOccurred())
|
||||
|
||||
success, err = (&BeAnExistingFileMatcher{}).Match(true)
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(err).Should(HaveOccurred())
|
||||
})
|
||||
})
|
||||
})
|
||||
3
vendor/github.com/onsi/gomega/matchers/be_closed_matcher.go
generated
vendored
3
vendor/github.com/onsi/gomega/matchers/be_closed_matcher.go
generated
vendored
|
|
@ -2,8 +2,9 @@ package matchers
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/onsi/gomega/format"
|
||||
"reflect"
|
||||
|
||||
"github.com/onsi/gomega/format"
|
||||
)
|
||||
|
||||
type BeClosedMatcher struct {
|
||||
|
|
|
|||
70
vendor/github.com/onsi/gomega/matchers/be_closed_matcher_test.go
generated
vendored
70
vendor/github.com/onsi/gomega/matchers/be_closed_matcher_test.go
generated
vendored
|
|
@ -1,70 +0,0 @@
|
|||
package matchers_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/matchers"
|
||||
)
|
||||
|
||||
var _ = Describe("BeClosedMatcher", func() {
|
||||
Context("when passed a channel", func() {
|
||||
It("should do the right thing", func() {
|
||||
openChannel := make(chan bool)
|
||||
Ω(openChannel).ShouldNot(BeClosed())
|
||||
|
||||
var openReaderChannel <-chan bool
|
||||
openReaderChannel = openChannel
|
||||
Ω(openReaderChannel).ShouldNot(BeClosed())
|
||||
|
||||
closedChannel := make(chan bool)
|
||||
close(closedChannel)
|
||||
|
||||
Ω(closedChannel).Should(BeClosed())
|
||||
|
||||
var closedReaderChannel <-chan bool
|
||||
closedReaderChannel = closedChannel
|
||||
Ω(closedReaderChannel).Should(BeClosed())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when passed a send-only channel", func() {
|
||||
It("should error", func() {
|
||||
openChannel := make(chan bool)
|
||||
var openWriterChannel chan<- bool
|
||||
openWriterChannel = openChannel
|
||||
|
||||
success, err := (&BeClosedMatcher{}).Match(openWriterChannel)
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(err).Should(HaveOccurred())
|
||||
|
||||
closedChannel := make(chan bool)
|
||||
close(closedChannel)
|
||||
|
||||
var closedWriterChannel chan<- bool
|
||||
closedWriterChannel = closedChannel
|
||||
|
||||
success, err = (&BeClosedMatcher{}).Match(closedWriterChannel)
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(err).Should(HaveOccurred())
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
Context("when passed something else", func() {
|
||||
It("should error", func() {
|
||||
var nilChannel chan bool
|
||||
|
||||
success, err := (&BeClosedMatcher{}).Match(nilChannel)
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(err).Should(HaveOccurred())
|
||||
|
||||
success, err = (&BeClosedMatcher{}).Match(nil)
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(err).Should(HaveOccurred())
|
||||
|
||||
success, err = (&BeClosedMatcher{}).Match(7)
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(err).Should(HaveOccurred())
|
||||
})
|
||||
})
|
||||
})
|
||||
1
vendor/github.com/onsi/gomega/matchers/be_empty_matcher.go
generated
vendored
1
vendor/github.com/onsi/gomega/matchers/be_empty_matcher.go
generated
vendored
|
|
@ -2,6 +2,7 @@ package matchers
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/onsi/gomega/format"
|
||||
)
|
||||
|
||||
|
|
|
|||
52
vendor/github.com/onsi/gomega/matchers/be_empty_matcher_test.go
generated
vendored
52
vendor/github.com/onsi/gomega/matchers/be_empty_matcher_test.go
generated
vendored
|
|
@ -1,52 +0,0 @@
|
|||
package matchers_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/matchers"
|
||||
)
|
||||
|
||||
var _ = Describe("BeEmpty", func() {
|
||||
Context("when passed a supported type", func() {
|
||||
It("should do the right thing", func() {
|
||||
Ω("").Should(BeEmpty())
|
||||
Ω(" ").ShouldNot(BeEmpty())
|
||||
|
||||
Ω([0]int{}).Should(BeEmpty())
|
||||
Ω([1]int{1}).ShouldNot(BeEmpty())
|
||||
|
||||
Ω([]int{}).Should(BeEmpty())
|
||||
Ω([]int{1}).ShouldNot(BeEmpty())
|
||||
|
||||
Ω(map[string]int{}).Should(BeEmpty())
|
||||
Ω(map[string]int{"a": 1}).ShouldNot(BeEmpty())
|
||||
|
||||
c := make(chan bool, 1)
|
||||
Ω(c).Should(BeEmpty())
|
||||
c <- true
|
||||
Ω(c).ShouldNot(BeEmpty())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when passed a correctly typed nil", func() {
|
||||
It("should be true", func() {
|
||||
var nilSlice []int
|
||||
Ω(nilSlice).Should(BeEmpty())
|
||||
|
||||
var nilMap map[int]string
|
||||
Ω(nilMap).Should(BeEmpty())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when passed an unsupported type", func() {
|
||||
It("should error", func() {
|
||||
success, err := (&BeEmptyMatcher{}).Match(0)
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(err).Should(HaveOccurred())
|
||||
|
||||
success, err = (&BeEmptyMatcher{}).Match(nil)
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(err).Should(HaveOccurred())
|
||||
})
|
||||
})
|
||||
})
|
||||
3
vendor/github.com/onsi/gomega/matchers/be_equivalent_to_matcher.go
generated
vendored
3
vendor/github.com/onsi/gomega/matchers/be_equivalent_to_matcher.go
generated
vendored
|
|
@ -2,8 +2,9 @@ package matchers
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/onsi/gomega/format"
|
||||
"reflect"
|
||||
|
||||
"github.com/onsi/gomega/format"
|
||||
)
|
||||
|
||||
type BeEquivalentToMatcher struct {
|
||||
|
|
|
|||
50
vendor/github.com/onsi/gomega/matchers/be_equivalent_to_matcher_test.go
generated
vendored
50
vendor/github.com/onsi/gomega/matchers/be_equivalent_to_matcher_test.go
generated
vendored
|
|
@ -1,50 +0,0 @@
|
|||
package matchers_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/matchers"
|
||||
)
|
||||
|
||||
var _ = Describe("BeEquivalentTo", func() {
|
||||
Context("when asserting that nil is equivalent to nil", func() {
|
||||
It("should error", func() {
|
||||
success, err := (&BeEquivalentToMatcher{Expected: nil}).Match(nil)
|
||||
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(err).Should(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
||||
Context("When asserting on nil", func() {
|
||||
It("should do the right thing", func() {
|
||||
Ω("foo").ShouldNot(BeEquivalentTo(nil))
|
||||
Ω(nil).ShouldNot(BeEquivalentTo(3))
|
||||
Ω([]int{1, 2}).ShouldNot(BeEquivalentTo(nil))
|
||||
})
|
||||
})
|
||||
|
||||
Context("When asserting on type aliases", func() {
|
||||
It("should the right thing", func() {
|
||||
Ω(StringAlias("foo")).Should(BeEquivalentTo("foo"))
|
||||
Ω("foo").Should(BeEquivalentTo(StringAlias("foo")))
|
||||
Ω(StringAlias("foo")).ShouldNot(BeEquivalentTo("bar"))
|
||||
Ω("foo").ShouldNot(BeEquivalentTo(StringAlias("bar")))
|
||||
})
|
||||
})
|
||||
|
||||
Context("When asserting on numbers", func() {
|
||||
It("should convert actual to expected and do the right thing", func() {
|
||||
Ω(5).Should(BeEquivalentTo(5))
|
||||
Ω(5.0).Should(BeEquivalentTo(5.0))
|
||||
Ω(5).Should(BeEquivalentTo(5.0))
|
||||
|
||||
Ω(5).ShouldNot(BeEquivalentTo("5"))
|
||||
Ω(5).ShouldNot(BeEquivalentTo(3))
|
||||
|
||||
//Here be dragons!
|
||||
Ω(5.1).Should(BeEquivalentTo(5))
|
||||
Ω(5).ShouldNot(BeEquivalentTo(5.1))
|
||||
})
|
||||
})
|
||||
})
|
||||
1
vendor/github.com/onsi/gomega/matchers/be_false_matcher.go
generated
vendored
1
vendor/github.com/onsi/gomega/matchers/be_false_matcher.go
generated
vendored
|
|
@ -2,6 +2,7 @@ package matchers
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/onsi/gomega/format"
|
||||
)
|
||||
|
||||
|
|
|
|||
20
vendor/github.com/onsi/gomega/matchers/be_false_matcher_test.go
generated
vendored
20
vendor/github.com/onsi/gomega/matchers/be_false_matcher_test.go
generated
vendored
|
|
@ -1,20 +0,0 @@
|
|||
package matchers_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/matchers"
|
||||
)
|
||||
|
||||
var _ = Describe("BeFalse", func() {
|
||||
It("should handle true and false correctly", func() {
|
||||
Ω(true).ShouldNot(BeFalse())
|
||||
Ω(false).Should(BeFalse())
|
||||
})
|
||||
|
||||
It("should only support booleans", func() {
|
||||
success, err := (&BeFalseMatcher{}).Match("foo")
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(err).Should(HaveOccurred())
|
||||
})
|
||||
})
|
||||
61
vendor/github.com/onsi/gomega/matchers/be_identical_to_test.go
generated
vendored
61
vendor/github.com/onsi/gomega/matchers/be_identical_to_test.go
generated
vendored
|
|
@ -1,61 +0,0 @@
|
|||
package matchers_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/matchers"
|
||||
)
|
||||
|
||||
var _ = Describe("BeIdenticalTo", func() {
|
||||
Context("when asserting that nil equals nil", func() {
|
||||
It("should error", func() {
|
||||
success, err := (&BeIdenticalToMatcher{Expected: nil}).Match(nil)
|
||||
|
||||
Ω(success).Should(BeFalse())
|
||||
Ω(err).Should(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
||||
It("should treat the same pointer to a struct as identical", func() {
|
||||
mySpecialStruct := myCustomType{}
|
||||
Ω(&mySpecialStruct).Should(BeIdenticalTo(&mySpecialStruct))
|
||||
Ω(&myCustomType{}).ShouldNot(BeIdenticalTo(&mySpecialStruct))
|
||||
})
|
||||
|
||||
It("should be strict about types", func() {
|
||||
Ω(5).ShouldNot(BeIdenticalTo("5"))
|
||||
Ω(5).ShouldNot(BeIdenticalTo(5.0))
|
||||
Ω(5).ShouldNot(BeIdenticalTo(3))
|
||||
})
|
||||
|
||||
It("should treat primtives as identical", func() {
|
||||
Ω("5").Should(BeIdenticalTo("5"))
|
||||
Ω("5").ShouldNot(BeIdenticalTo("55"))
|
||||
|
||||
Ω(5.55).Should(BeIdenticalTo(5.55))
|
||||
Ω(5.55).ShouldNot(BeIdenticalTo(6.66))
|
||||
|
||||
Ω(5).Should(BeIdenticalTo(5))
|
||||
Ω(5).ShouldNot(BeIdenticalTo(55))
|
||||
})
|
||||
|
||||
It("should treat the same pointers to a slice as identical", func() {
|
||||
mySlice := []int{1, 2}
|
||||
Ω(&mySlice).Should(BeIdenticalTo(&mySlice))
|
||||
Ω(&mySlice).ShouldNot(BeIdenticalTo(&[]int{1, 2}))
|
||||
})
|
||||
|
||||
It("should treat the same pointers to a map as identical", func() {
|
||||
myMap := map[string]string{"a": "b", "c": "d"}
|
||||
Ω(&myMap).Should(BeIdenticalTo(&myMap))
|
||||
Ω(myMap).ShouldNot(BeIdenticalTo(map[string]string{"a": "b", "c": "d"}))
|
||||
})
|
||||
|
||||
It("should treat the same pointers to an error as identical", func() {
|
||||
myError := errors.New("foo")
|
||||
Ω(&myError).Should(BeIdenticalTo(&myError))
|
||||
Ω(errors.New("foo")).ShouldNot(BeIdenticalTo(errors.New("bar")))
|
||||
})
|
||||
})
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue