diff options
Diffstat (limited to 'vendor/github.com/smartystreets/goconvey')
52 files changed, 0 insertions, 3887 deletions
diff --git a/vendor/github.com/smartystreets/goconvey/CONTRIBUTING.md b/vendor/github.com/smartystreets/goconvey/CONTRIBUTING.md deleted file mode 100644 index cc0e8e8e..00000000 --- a/vendor/github.com/smartystreets/goconvey/CONTRIBUTING.md +++ /dev/null @@ -1,35 +0,0 @@ -# Subject: GoConvey maintainers wanted - -We'd like to open the project up to additional maintainers who want to move the project forward in a meaningful way. - -We've spent significant time at SmartyStreets building GoConvey and it has perfectly met (and exceeded) all of our initial design specifications. We've used it to great effect. Being so well-matched to our development workflows at SmartyStreets, we haven't had a need to hack on it lately. This had been frustrating to many in the community who have ideas for the project and would like to see new features released (and some old bugs fixed). The release of Go 1.5 and the new vendoring experiment has been a source of confusion and hassle for those who have already upgraded and find that GoConvey needs to be brought up to speed. - -GoConvey is a popular 2-pronged, open-source github project (1,600+ stargazers, 100+ forks): - -- A package you import in your test code that allows you to write BDD-style tests. -- An executable that runs a local web server which displays auto-updating test results in a web browser. - ----- - -- http://goconvey.co/ -- https://github.com/smartystreets/goconvey -- https://github.com/smartystreets/goconvey/wiki - -_I should mention that the [assertions package](https://github.com/smartystreets/assertions) imported by the convey package is used by other projects at SmartyStreets and so we will be continuing to maintain that project internally._ - -We hope to hear from you soon. Thanks! - ---- - -# Contributing - -In general, the code posted to the [SmartyStreets github organization](https://github.com/smartystreets) is created to solve specific problems at SmartyStreets that are ancillary to our core products in the address verification industry and may or may not be useful to other organizations or developers. Our reason for posting said code isn't necessarily to solicit feedback or contributions from the community but more as a showcase of some of the approaches to solving problems we have adopted. - -Having stated that, we do consider issues raised by other githubbers as well as contributions submitted via pull requests. When submitting such a pull request, please follow these guidelines: - -- _Look before you leap:_ If the changes you plan to make are significant, it's in everyone's best interest for you to discuss them with a SmartyStreets team member prior to opening a pull request. -- _License and ownership:_ If modifying the `LICENSE.md` file, limit your changes to fixing typographical mistakes. Do NOT modify the actual terms in the license or the copyright by **SmartyStreets, LLC**. Code submitted to SmartyStreets projects becomes property of SmartyStreets and must be compatible with the associated license. -- _Testing:_ If the code you are submitting resides in packages/modules covered by automated tests, be sure to add passing tests that cover your changes and assert expected behavior and state. Submit the additional test cases as part of your change set. -- _Style:_ Match your approach to **naming** and **formatting** with the surrounding code. Basically, the code you submit shouldn't stand out. - - "Naming" refers to such constructs as variables, methods, functions, classes, structs, interfaces, packages, modules, directories, files, etc... - - "Formatting" refers to such constructs as whitespace, horizontal line length, vertical function length, vertical file length, indentation, curly braces, etc... diff --git a/vendor/github.com/smartystreets/goconvey/LICENSE.md b/vendor/github.com/smartystreets/goconvey/LICENSE.md deleted file mode 100644 index 3f87a40e..00000000 --- a/vendor/github.com/smartystreets/goconvey/LICENSE.md +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (c) 2016 SmartyStreets, LLC - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -NOTE: Various optional and subordinate components carry their own licensing -requirements and restrictions. Use of those components is subject to the terms -and conditions outlined the respective license of each component. diff --git a/vendor/github.com/smartystreets/goconvey/README.md b/vendor/github.com/smartystreets/goconvey/README.md deleted file mode 100644 index 00df4806..00000000 --- a/vendor/github.com/smartystreets/goconvey/README.md +++ /dev/null @@ -1,124 +0,0 @@ -GoConvey is awesome Go testing -============================== - -[](https://travis-ci.org/smartystreets/goconvey) -[](http://godoc.org/github.com/smartystreets/goconvey) - - -Welcome to GoConvey, a yummy Go testing tool for gophers. Works with `go test`. Use it in the terminal or browser according to your viewing pleasure. **[View full feature tour.](http://goconvey.co)** - -**Features:** - -- Directly integrates with `go test` -- Fully-automatic web UI (works with native Go tests, too) -- Huge suite of regression tests -- Shows test coverage (Go 1.2+) -- Readable, colorized console output (understandable by any manager, IT or not) -- Test code generator -- Desktop notifications (optional) -- Immediately open problem lines in [Sublime Text](http://www.sublimetext.com) ([some assembly required](https://github.com/asuth/subl-handler)) - - -You can ask questions about how to use GoConvey on [StackOverflow](http://stackoverflow.com/questions/ask?tags=goconvey,go&title=GoConvey%3A%20). Use the tags `go` and `goconvey`. - -**Menu:** - -- [Installation](#installation) -- [Quick start](#quick-start) -- [Documentation](#documentation) -- [Screenshots](#screenshots) -- [Contributors](#contributors) - - - - -Installation ------------- - - $ go get github.com/smartystreets/goconvey - -[Quick start](https://github.com/smartystreets/goconvey/wiki#get-going-in-25-seconds) ------------ - -Make a test, for example: - -```go -package package_name - -import ( - "testing" - . "github.com/smartystreets/goconvey/convey" -) - -func TestSpec(t *testing.T) { - - // Only pass t into top-level Convey calls - Convey("Given some integer with a starting value", t, func() { - x := 1 - - Convey("When the integer is incremented", func() { - x++ - - Convey("The value should be greater by one", func() { - So(x, ShouldEqual, 2) - }) - }) - }) -} -``` - - -#### [In the browser](https://github.com/smartystreets/goconvey/wiki/Web-UI) - -Start up the GoConvey web server at your project's path: - - $ $GOPATH/bin/goconvey - -Then watch the test results display in your browser at: - - http://localhost:8080 - - -If the browser doesn't open automatically, please click [http://localhost:8080](http://localhost:8080) to open manually. - -There you have it. - -As long as GoConvey is running, test results will automatically update in your browser window. - - -The design is responsive, so you can squish the browser real tight if you need to put it beside your code. - - -The [web UI](https://github.com/smartystreets/goconvey/wiki/Web-UI) supports traditional Go tests, so use it even if you're not using GoConvey tests. - - - -#### [In the terminal](https://github.com/smartystreets/goconvey/wiki/Execution) - -Just do what you do best: - - $ go test - -Or if you want the output to include the story: - - $ go test -v - - -[Documentation](https://github.com/smartystreets/goconvey/wiki) ------------ - -Check out the - -- [GoConvey wiki](https://github.com/smartystreets/goconvey/wiki), -- [](http://godoc.org/github.com/smartystreets/goconvey) -- and the *_test.go files scattered throughout this project. - -[Screenshots](http://goconvey.co) ------------ - -For web UI and terminal screenshots, check out [the full feature tour](http://goconvey.co). - -Contributors ----------------------- - -GoConvey is brought to you by [SmartyStreets](https://github.com/smartystreets) and [several contributors](https://github.com/smartystreets/goconvey/graphs/contributors) (Thanks!). diff --git a/vendor/github.com/smartystreets/goconvey/convey/assertions.go b/vendor/github.com/smartystreets/goconvey/convey/assertions.go deleted file mode 100644 index 97e3bec8..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/assertions.go +++ /dev/null @@ -1,71 +0,0 @@ -package convey - -import "github.com/smartystreets/assertions" - -var ( - ShouldEqual = assertions.ShouldEqual - ShouldNotEqual = assertions.ShouldNotEqual - ShouldAlmostEqual = assertions.ShouldAlmostEqual - ShouldNotAlmostEqual = assertions.ShouldNotAlmostEqual - ShouldResemble = assertions.ShouldResemble - ShouldNotResemble = assertions.ShouldNotResemble - ShouldPointTo = assertions.ShouldPointTo - ShouldNotPointTo = assertions.ShouldNotPointTo - ShouldBeNil = assertions.ShouldBeNil - ShouldNotBeNil = assertions.ShouldNotBeNil - ShouldBeTrue = assertions.ShouldBeTrue - ShouldBeFalse = assertions.ShouldBeFalse - ShouldBeZeroValue = assertions.ShouldBeZeroValue - ShouldNotBeZeroValue = assertions.ShouldNotBeZeroValue - - ShouldBeGreaterThan = assertions.ShouldBeGreaterThan - ShouldBeGreaterThanOrEqualTo = assertions.ShouldBeGreaterThanOrEqualTo - ShouldBeLessThan = assertions.ShouldBeLessThan - ShouldBeLessThanOrEqualTo = assertions.ShouldBeLessThanOrEqualTo - ShouldBeBetween = assertions.ShouldBeBetween - ShouldNotBeBetween = assertions.ShouldNotBeBetween - ShouldBeBetweenOrEqual = assertions.ShouldBeBetweenOrEqual - ShouldNotBeBetweenOrEqual = assertions.ShouldNotBeBetweenOrEqual - - ShouldContain = assertions.ShouldContain - ShouldNotContain = assertions.ShouldNotContain - ShouldContainKey = assertions.ShouldContainKey - ShouldNotContainKey = assertions.ShouldNotContainKey - ShouldBeIn = assertions.ShouldBeIn - ShouldNotBeIn = assertions.ShouldNotBeIn - ShouldBeEmpty = assertions.ShouldBeEmpty - ShouldNotBeEmpty = assertions.ShouldNotBeEmpty - ShouldHaveLength = assertions.ShouldHaveLength - - ShouldStartWith = assertions.ShouldStartWith - ShouldNotStartWith = assertions.ShouldNotStartWith - ShouldEndWith = assertions.ShouldEndWith - ShouldNotEndWith = assertions.ShouldNotEndWith - ShouldBeBlank = assertions.ShouldBeBlank - ShouldNotBeBlank = assertions.ShouldNotBeBlank - ShouldContainSubstring = assertions.ShouldContainSubstring - ShouldNotContainSubstring = assertions.ShouldNotContainSubstring - - ShouldPanic = assertions.ShouldPanic - ShouldNotPanic = assertions.ShouldNotPanic - ShouldPanicWith = assertions.ShouldPanicWith - ShouldNotPanicWith = assertions.ShouldNotPanicWith - - ShouldHaveSameTypeAs = assertions.ShouldHaveSameTypeAs - ShouldNotHaveSameTypeAs = assertions.ShouldNotHaveSameTypeAs - ShouldImplement = assertions.ShouldImplement - ShouldNotImplement = assertions.ShouldNotImplement - - ShouldHappenBefore = assertions.ShouldHappenBefore - ShouldHappenOnOrBefore = assertions.ShouldHappenOnOrBefore - ShouldHappenAfter = assertions.ShouldHappenAfter - ShouldHappenOnOrAfter = assertions.ShouldHappenOnOrAfter - ShouldHappenBetween = assertions.ShouldHappenBetween - ShouldHappenOnOrBetween = assertions.ShouldHappenOnOrBetween - ShouldNotHappenOnOrBetween = assertions.ShouldNotHappenOnOrBetween - ShouldHappenWithin = assertions.ShouldHappenWithin - ShouldNotHappenWithin = assertions.ShouldNotHappenWithin - ShouldBeChronological = assertions.ShouldBeChronological - - ShouldBeError = assertions.ShouldBeError -) diff --git a/vendor/github.com/smartystreets/goconvey/convey/context.go b/vendor/github.com/smartystreets/goconvey/convey/context.go deleted file mode 100644 index 2c75c2d7..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/context.go +++ /dev/null @@ -1,272 +0,0 @@ -package convey - -import ( - "fmt" - - "github.com/jtolds/gls" - "github.com/smartystreets/goconvey/convey/reporting" -) - -type conveyErr struct { - fmt string - params []interface{} -} - -func (e *conveyErr) Error() string { - return fmt.Sprintf(e.fmt, e.params...) -} - -func conveyPanic(fmt string, params ...interface{}) { - panic(&conveyErr{fmt, params}) -} - -const ( - missingGoTest = `Top-level calls to Convey(...) need a reference to the *testing.T. - Hint: Convey("description here", t, func() { /* notice that the second argument was the *testing.T (t)! */ }) ` - extraGoTest = `Only the top-level call to Convey(...) needs a reference to the *testing.T.` - noStackContext = "Convey operation made without context on goroutine stack.\n" + - "Hint: Perhaps you meant to use `Convey(..., func(c C){...})` ?" - differentConveySituations = "Different set of Convey statements on subsequent pass!\nDid not expect %#v." - multipleIdenticalConvey = "Multiple convey suites with identical names: %#v" -) - -const ( - failureHalt = "___FAILURE_HALT___" - - nodeKey = "node" -) - -///////////////////////////////// Stack Context ///////////////////////////////// - -func getCurrentContext() *context { - ctx, ok := ctxMgr.GetValue(nodeKey) - if ok { - return ctx.(*context) - } - return nil -} - -func mustGetCurrentContext() *context { - ctx := getCurrentContext() - if ctx == nil { - conveyPanic(noStackContext) - } - return ctx -} - -//////////////////////////////////// Context //////////////////////////////////// - -// context magically handles all coordination of Convey's and So assertions. -// -// It is tracked on the stack as goroutine-local-storage with the gls package, -// or explicitly if the user decides to call convey like: -// -// Convey(..., func(c C) { -// c.So(...) -// }) -// -// This implements the `C` interface. -type context struct { - reporter reporting.Reporter - - children map[string]*context - - resets []func() - - executedOnce bool - expectChildRun *bool - complete bool - - focus bool - failureMode FailureMode -} - -// rootConvey is the main entry point to a test suite. This is called when -// there's no context in the stack already, and items must contain a `t` object, -// or this panics. -func rootConvey(items ...interface{}) { - entry := discover(items) - - if entry.Test == nil { - conveyPanic(missingGoTest) - } - - expectChildRun := true - ctx := &context{ - reporter: buildReporter(), - - children: make(map[string]*context), - - expectChildRun: &expectChildRun, - - focus: entry.Focus, - failureMode: defaultFailureMode.combine(entry.FailMode), - } - ctxMgr.SetValues(gls.Values{nodeKey: ctx}, func() { - ctx.reporter.BeginStory(reporting.NewStoryReport(entry.Test)) - defer ctx.reporter.EndStory() - - for ctx.shouldVisit() { - ctx.conveyInner(entry.Situation, entry.Func) - expectChildRun = true - } - }) -} - -//////////////////////////////////// Methods //////////////////////////////////// - -func (ctx *context) SkipConvey(items ...interface{}) { - ctx.Convey(items, skipConvey) -} - -func (ctx *context) FocusConvey(items ...interface{}) { - ctx.Convey(items, focusConvey) -} - -func (ctx *context) Convey(items ...interface{}) { - entry := discover(items) - - // we're a branch, or leaf (on the wind) - if entry.Test != nil { - conveyPanic(extraGoTest) - } - if ctx.focus && !entry.Focus { - return - } - - var inner_ctx *context - if ctx.executedOnce { - var ok bool - inner_ctx, ok = ctx.children[entry.Situation] - if !ok { - conveyPanic(differentConveySituations, entry.Situation) - } - } else { - if _, ok := ctx.children[entry.Situation]; ok { - conveyPanic(multipleIdenticalConvey, entry.Situation) - } - inner_ctx = &context{ - reporter: ctx.reporter, - - children: make(map[string]*context), - - expectChildRun: ctx.expectChildRun, - - focus: entry.Focus, - failureMode: ctx.failureMode.combine(entry.FailMode), - } - ctx.children[entry.Situation] = inner_ctx - } - - if inner_ctx.shouldVisit() { - ctxMgr.SetValues(gls.Values{nodeKey: inner_ctx}, func() { - inner_ctx.conveyInner(entry.Situation, entry.Func) - }) - } -} - -func (ctx *context) SkipSo(stuff ...interface{}) { - ctx.assertionReport(reporting.NewSkipReport()) -} - -func (ctx *context) So(actual interface{}, assert assertion, expected ...interface{}) { - if result := assert(actual, expected...); result == assertionSuccess { - ctx.assertionReport(reporting.NewSuccessReport()) - } else { - ctx.assertionReport(reporting.NewFailureReport(result)) - } -} - -func (ctx *context) Reset(action func()) { - /* TODO: Failure mode configuration */ - ctx.resets = append(ctx.resets, action) -} - -func (ctx *context) Print(items ...interface{}) (int, error) { - fmt.Fprint(ctx.reporter, items...) - return fmt.Print(items...) -} - -func (ctx *context) Println(items ...interface{}) (int, error) { - fmt.Fprintln(ctx.reporter, items...) - return fmt.Println(items...) -} - -func (ctx *context) Printf(format string, items ...interface{}) (int, error) { - fmt.Fprintf(ctx.reporter, format, items...) - return fmt.Printf(format, items...) -} - -//////////////////////////////////// Private //////////////////////////////////// - -// shouldVisit returns true iff we should traverse down into a Convey. Note -// that just because we don't traverse a Convey this time, doesn't mean that -// we may not traverse it on a subsequent pass. -func (c *context) shouldVisit() bool { - return !c.complete && *c.expectChildRun -} - -// conveyInner is the function which actually executes the user's anonymous test -// function body. At this point, Convey or RootConvey has decided that this -// function should actually run. -func (ctx *context) conveyInner(situation string, f func(C)) { - // Record/Reset state for next time. - defer func() { - ctx.executedOnce = true - - // This is only needed at the leaves, but there's no harm in also setting it - // when returning from branch Convey's - *ctx.expectChildRun = false - }() - - // Set up+tear down our scope for the reporter - ctx.reporter.Enter(reporting.NewScopeReport(situation)) - defer ctx.reporter.Exit() - - // Recover from any panics in f, and assign the `complete` status for this - // node of the tree. - defer func() { - ctx.complete = true - if problem := recover(); problem != nil { - if problem, ok := problem.(*conveyErr); ok { - panic(problem) - } - if problem != failureHalt { - ctx.reporter.Report(reporting.NewErrorReport(problem)) - } - } else { - for _, child := range ctx.children { - if !child.complete { - ctx.complete = false - return - } - } - } - }() - - // Resets are registered as the `f` function executes, so nil them here. - // All resets are run in registration order (FIFO). - ctx.resets = []func(){} - defer func() { - for _, r := range ctx.resets { - // panics handled by the previous defer - r() - } - }() - - if f == nil { - // if f is nil, this was either a Convey(..., nil), or a SkipConvey - ctx.reporter.Report(reporting.NewSkipReport()) - } else { - f(ctx) - } -} - -// assertionReport is a helper for So and SkipSo which makes the report and -// then possibly panics, depending on the current context's failureMode. -func (ctx *context) assertionReport(r *reporting.AssertionResult) { - ctx.reporter.Report(r) - if r.Failure != "" && ctx.failureMode == FailureHalts { - panic(failureHalt) - } -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/convey.goconvey b/vendor/github.com/smartystreets/goconvey/convey/convey.goconvey deleted file mode 100644 index a2d9327d..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/convey.goconvey +++ /dev/null @@ -1,4 +0,0 @@ -#ignore --timeout=1s -#-covermode=count -#-coverpkg=github.com/smartystreets/goconvey/convey,github.com/smartystreets/goconvey/convey/gotest,github.com/smartystreets/goconvey/convey/reporting
\ No newline at end of file diff --git a/vendor/github.com/smartystreets/goconvey/convey/discovery.go b/vendor/github.com/smartystreets/goconvey/convey/discovery.go deleted file mode 100644 index eb8d4cb2..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/discovery.go +++ /dev/null @@ -1,103 +0,0 @@ -package convey - -type actionSpecifier uint8 - -const ( - noSpecifier actionSpecifier = iota - skipConvey - focusConvey -) - -type suite struct { - Situation string - Test t - Focus bool - Func func(C) // nil means skipped - FailMode FailureMode -} - -func newSuite(situation string, failureMode FailureMode, f func(C), test t, specifier actionSpecifier) *suite { - ret := &suite{ - Situation: situation, - Test: test, - Func: f, - FailMode: failureMode, - } - switch specifier { - case skipConvey: - ret.Func = nil - case focusConvey: - ret.Focus = true - } - return ret -} - -func discover(items []interface{}) *suite { - name, items := parseName(items) - test, items := parseGoTest(items) - failure, items := parseFailureMode(items) - action, items := parseAction(items) - specifier, items := parseSpecifier(items) - - if len(items) != 0 { - conveyPanic(parseError) - } - - return newSuite(name, failure, action, test, specifier) -} -func item(items []interface{}) interface{} { - if len(items) == 0 { - conveyPanic(parseError) - } - return items[0] -} -func parseName(items []interface{}) (string, []interface{}) { - if name, parsed := item(items).(string); parsed { - return name, items[1:] - } - conveyPanic(parseError) - panic("never get here") -} -func parseGoTest(items []interface{}) (t, []interface{}) { - if test, parsed := item(items).(t); parsed { - return test, items[1:] - } - return nil, items -} -func parseFailureMode(items []interface{}) (FailureMode, []interface{}) { - if mode, parsed := item(items).(FailureMode); parsed { - return mode, items[1:] - } - return FailureInherits, items -} -func parseAction(items []interface{}) (func(C), []interface{}) { - switch x := item(items).(type) { - case nil: - return nil, items[1:] - case func(C): - return x, items[1:] - case func(): - return func(C) { x() }, items[1:] - } - conveyPanic(parseError) - panic("never get here") -} -func parseSpecifier(items []interface{}) (actionSpecifier, []interface{}) { - if len(items) == 0 { - return noSpecifier, items - } - if spec, ok := items[0].(actionSpecifier); ok { - return spec, items[1:] - } - conveyPanic(parseError) - panic("never get here") -} - -// This interface allows us to pass the *testing.T struct -// throughout the internals of this package without ever -// having to import the "testing" package. -type t interface { - Fail() -} - -const parseError = "You must provide a name (string), then a *testing.T (if in outermost scope), an optional FailureMode, and then an action (func())." diff --git a/vendor/github.com/smartystreets/goconvey/convey/doc.go b/vendor/github.com/smartystreets/goconvey/convey/doc.go deleted file mode 100644 index a60e32ae..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/doc.go +++ /dev/null @@ -1,218 +0,0 @@ -// Package convey contains all of the public-facing entry points to this project. -// This means that it should never be required of the user to import any other -// packages from this project as they serve internal purposes. -package convey - -import "github.com/smartystreets/goconvey/convey/reporting" - -////////////////////////////////// suite ////////////////////////////////// - -// C is the Convey context which you can optionally obtain in your action -// by calling Convey like: -// -// Convey(..., func(c C) { -// ... -// }) -// -// See the documentation on Convey for more details. -// -// All methods in this context behave identically to the global functions of the -// same name in this package. -type C interface { - Convey(items ...interface{}) - SkipConvey(items ...interface{}) - FocusConvey(items ...interface{}) - - So(actual interface{}, assert assertion, expected ...interface{}) - SkipSo(stuff ...interface{}) - - Reset(action func()) - - Println(items ...interface{}) (int, error) - Print(items ...interface{}) (int, error) - Printf(format string, items ...interface{}) (int, error) -} - -// Convey is the method intended for use when declaring the scopes of -// a specification. Each scope has a description and a func() which may contain -// other calls to Convey(), Reset() or Should-style assertions. Convey calls can -// be nested as far as you see fit. -// -// IMPORTANT NOTE: The top-level Convey() within a Test method -// must conform to the following signature: -// -// Convey(description string, t *testing.T, action func()) -// -// All other calls should look like this (no need to pass in *testing.T): -// -// Convey(description string, action func()) -// -// Don't worry, goconvey will panic if you get it wrong so you can fix it. -// -// Additionally, you may explicitly obtain access to the Convey context by doing: -// -// Convey(description string, action func(c C)) -// -// You may need to do this if you want to pass the context through to a -// goroutine, or to close over the context in a handler to a library which -// calls your handler in a goroutine (httptest comes to mind). -// -// All Convey()-blocks also accept an optional parameter of FailureMode which sets -// how goconvey should treat failures for So()-assertions in the block and -// nested blocks. See the constants in this file for the available options. -// -// By default it will inherit from its parent block and the top-level blocks -// default to the FailureHalts setting. -// -// This parameter is inserted before the block itself: -// -// Convey(description string, t *testing.T, mode FailureMode, action func()) -// Convey(description string, mode FailureMode, action func()) -// -// See the examples package for, well, examples. -func Convey(items ...interface{}) { - if ctx := getCurrentContext(); ctx == nil { - rootConvey(items...) - } else { - ctx.Convey(items...) - } -} - -// SkipConvey is analagous to Convey except that the scope is not executed -// (which means that child scopes defined within this scope are not run either). -// The reporter will be notified that this step was skipped. -func SkipConvey(items ...interface{}) { - Convey(append(items, skipConvey)...) -} - -// FocusConvey is has the inverse effect of SkipConvey. If the top-level -// Convey is changed to `FocusConvey`, only nested scopes that are defined -// with FocusConvey will be run. The rest will be ignored completely. This -// is handy when debugging a large suite that runs a misbehaving function -// repeatedly as you can disable all but one of that function -// without swaths of `SkipConvey` calls, just a targeted chain of calls -// to FocusConvey. -func FocusConvey(items ...interface{}) { - Convey(append(items, focusConvey)...) -} - -// Reset registers a cleanup function to be run after each Convey() -// in the same scope. See the examples package for a simple use case. -func Reset(action func()) { - mustGetCurrentContext().Reset(action) -} - -/////////////////////////////////// Assertions /////////////////////////////////// - -// assertion is an alias for a function with a signature that the convey.So() -// method can handle. Any future or custom assertions should conform to this -// method signature. The return value should be an empty string if the assertion -// passes and a well-formed failure message if not. -type assertion func(actual interface{}, expected ...interface{}) string - -const assertionSuccess = "" - -// So is the means by which assertions are made against the system under test. -// The majority of exported names in the assertions package begin with the word -// 'Should' and describe how the first argument (actual) should compare with any -// of the final (expected) arguments. How many final arguments are accepted -// depends on the particular assertion that is passed in as the assert argument. -// See the examples package for use cases and the assertions package for -// documentation on specific assertion methods. A failing assertion will -// cause t.Fail() to be invoked--you should never call this method (or other -// failure-inducing methods) in your test code. Leave that to GoConvey. -func So(actual interface{}, assert assertion, expected ...interface{}) { - mustGetCurrentContext().So(actual, assert, expected...) -} - -// SkipSo is analagous to So except that the assertion that would have been passed -// to So is not executed and the reporter is notified that the assertion was skipped. -func SkipSo(stuff ...interface{}) { - mustGetCurrentContext().SkipSo() -} - -// FailureMode is a type which determines how the So() blocks should fail -// if their assertion fails. See constants further down for acceptable values -type FailureMode string - -const ( - - // FailureContinues is a failure mode which prevents failing - // So()-assertions from halting Convey-block execution, instead - // allowing the test to continue past failing So()-assertions. - FailureContinues FailureMode = "continue" - - // FailureHalts is the default setting for a top-level Convey()-block - // and will cause all failing So()-assertions to halt further execution - // in that test-arm and continue on to the next arm. - FailureHalts FailureMode = "halt" - - // FailureInherits is the default setting for failure-mode, it will - // default to the failure-mode of the parent block. You should never - // need to specify this mode in your tests.. - FailureInherits FailureMode = "inherits" -) - -func (f FailureMode) combine(other FailureMode) FailureMode { - if other == FailureInherits { - return f - } - return other -} - -var defaultFailureMode FailureMode = FailureHalts - -// SetDefaultFailureMode allows you to specify the default failure mode -// for all Convey blocks. It is meant to be used in an init function to -// allow the default mode to be changdd across all tests for an entire packgae -// but it can be used anywhere. -func SetDefaultFailureMode(mode FailureMode) { - if mode == FailureContinues || mode == FailureHalts { - defaultFailureMode = mode - } else { - panic("You may only use the constants named 'FailureContinues' and 'FailureHalts' as default failure modes.") - } -} - -//////////////////////////////////// Print functions //////////////////////////////////// - -// Print is analogous to fmt.Print (and it even calls fmt.Print). It ensures that -// output is aligned with the corresponding scopes in the web UI. -func Print(items ...interface{}) (written int, err error) { - return mustGetCurrentContext().Print(items...) -} - -// Print is analogous to fmt.Println (and it even calls fmt.Println). It ensures that -// output is aligned with the corresponding scopes in the web UI. -func Println(items ...interface{}) (written int, err error) { - return mustGetCurrentContext().Println(items...) -} - -// Print is analogous to fmt.Printf (and it even calls fmt.Printf). It ensures that -// output is aligned with the corresponding scopes in the web UI. -func Printf(format string, items ...interface{}) (written int, err error) { - return mustGetCurrentContext().Printf(format, items...) -} - -/////////////////////////////////////////////////////////////////////////////// - -// SuppressConsoleStatistics prevents automatic printing of console statistics. -// Calling PrintConsoleStatistics explicitly will force printing of statistics. -func SuppressConsoleStatistics() { - reporting.SuppressConsoleStatistics() -} - -// PrintConsoleStatistics may be called at any time to print assertion statistics. -// Generally, the best place to do this would be in a TestMain function, -// after all tests have been run. Something like this: -// -// func TestMain(m *testing.M) { -// convey.SuppressConsoleStatistics() -// result := m.Run() -// convey.PrintConsoleStatistics() -// os.Exit(result) -// } -// -func PrintConsoleStatistics() { - reporting.PrintConsoleStatistics() -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/gotest/utils.go b/vendor/github.com/smartystreets/goconvey/convey/gotest/utils.go deleted file mode 100644 index 167c8fb7..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/gotest/utils.go +++ /dev/null @@ -1,28 +0,0 @@ -// Package gotest contains internal functionality. Although this package -// contains one or more exported names it is not intended for public -// consumption. See the examples package for how to use this project. -package gotest - -import ( - "runtime" - "strings" -) - -func ResolveExternalCaller() (file string, line int, name string) { - var caller_id uintptr - callers := runtime.Callers(0, callStack) - - for x := 0; x < callers; x++ { - caller_id, file, line, _ = runtime.Caller(x) - if strings.HasSuffix(file, "_test.go") || strings.HasSuffix(file, "_tests.go") { - name = runtime.FuncForPC(caller_id).Name() - return - } - } - file, line, name = "<unknown file>", -1, "<unknown name>" - return // panic? -} - -const maxStackDepth = 100 // This had better be enough... - -var callStack []uintptr = make([]uintptr, maxStackDepth, maxStackDepth) diff --git a/vendor/github.com/smartystreets/goconvey/convey/init.go b/vendor/github.com/smartystreets/goconvey/convey/init.go deleted file mode 100644 index cb930a0d..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/init.go +++ /dev/null @@ -1,81 +0,0 @@ -package convey - -import ( - "flag" - "os" - - "github.com/jtolds/gls" - "github.com/smartystreets/assertions" - "github.com/smartystreets/goconvey/convey/reporting" -) - -func init() { - assertions.GoConveyMode(true) - - declareFlags() - - ctxMgr = gls.NewContextManager() -} - -func declareFlags() { - flag.BoolVar(&json, "convey-json", false, "When true, emits results in JSON blocks. Default: 'false'") - flag.BoolVar(&silent, "convey-silent", false, "When true, all output from GoConvey is suppressed.") - flag.BoolVar(&story, "convey-story", false, "When true, emits story output, otherwise emits dot output. When not provided, this flag mirrors the value of the '-test.v' flag") - - if noStoryFlagProvided() { - story = verboseEnabled - } - - // FYI: flag.Parse() is called from the testing package. -} - -func noStoryFlagProvided() bool { - return !story && !storyDisabled -} - -func buildReporter() reporting.Reporter { - selectReporter := os.Getenv("GOCONVEY_REPORTER") - - switch { - case testReporter != nil: - return testReporter - case json || selectReporter == "json": - return reporting.BuildJsonReporter() - case silent || selectReporter == "silent": - return reporting.BuildSilentReporter() - case selectReporter == "dot": - // Story is turned on when verbose is set, so we need to check for dot reporter first. - return reporting.BuildDotReporter() - case story || selectReporter == "story": - return reporting.BuildStoryReporter() - default: - return reporting.BuildDotReporter() - } -} - -var ( - ctxMgr *gls.ContextManager - - // only set by internal tests - testReporter reporting.Reporter -) - -var ( - json bool - silent bool - story bool - - verboseEnabled = flagFound("-test.v=true") - storyDisabled = flagFound("-story=false") -) - -// flagFound parses the command line args manually for flags defined in other -// packages. Like the '-v' flag from the "testing" package, for instance. -func flagFound(flagValue string) bool { - for _, arg := range os.Args { - if arg == flagValue { - return true - } - } - return false -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/nilReporter.go b/vendor/github.com/smartystreets/goconvey/convey/nilReporter.go deleted file mode 100644 index 777b2a51..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/nilReporter.go +++ /dev/null @@ -1,15 +0,0 @@ -package convey - -import ( - "github.com/smartystreets/goconvey/convey/reporting" -) - -type nilReporter struct{} - -func (self *nilReporter) BeginStory(story *reporting.StoryReport) {} -func (self *nilReporter) Enter(scope *reporting.ScopeReport) {} -func (self *nilReporter) Report(report *reporting.AssertionResult) {} -func (self *nilReporter) Exit() {} -func (self *nilReporter) EndStory() {} -func (self *nilReporter) Write(p []byte) (int, error) { return len(p), nil } -func newNilReporter() *nilReporter { return &nilReporter{} } diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/console.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/console.go deleted file mode 100644 index 7bf67dbb..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/console.go +++ /dev/null @@ -1,16 +0,0 @@ -package reporting - -import ( - "fmt" - "io" -) - -type console struct{} - -func (self *console) Write(p []byte) (n int, err error) { - return fmt.Print(string(p)) -} - -func NewConsole() io.Writer { - return new(console) -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/doc.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/doc.go deleted file mode 100644 index a37d0019..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -// Package reporting contains internal functionality related -// to console reporting and output. Although this package has -// exported names is not intended for public consumption. See the -// examples package for how to use this project. -package reporting diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/dot.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/dot.go deleted file mode 100644 index 47d57c6b..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/dot.go +++ /dev/null @@ -1,40 +0,0 @@ -package reporting - -import "fmt" - -type dot struct{ out *Printer } - -func (self *dot) BeginStory(story *StoryReport) {} - -func (self *dot) Enter(scope *ScopeReport) {} - -func (self *dot) Report(report *AssertionResult) { - if report.Error != nil { - fmt.Print(redColor) - self.out.Insert(dotError) - } else if report.Failure != "" { - fmt.Print(yellowColor) - self.out.Insert(dotFailure) - } else if report.Skipped { - fmt.Print(yellowColor) - self.out.Insert(dotSkip) - } else { - fmt.Print(greenColor) - self.out.Insert(dotSuccess) - } - fmt.Print(resetColor) -} - -func (self *dot) Exit() {} - -func (self *dot) EndStory() {} - -func (self *dot) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewDotReporter(out *Printer) *dot { - self := new(dot) - self.out = out - return self -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/gotest.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/gotest.go deleted file mode 100644 index c396e16b..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/gotest.go +++ /dev/null @@ -1,33 +0,0 @@ -package reporting - -type gotestReporter struct{ test T } - -func (self *gotestReporter) BeginStory(story *StoryReport) { - self.test = story.Test -} - -func (self *gotestReporter) Enter(scope *ScopeReport) {} - -func (self *gotestReporter) Report(r *AssertionResult) { - if !passed(r) { - self.test.Fail() - } -} - -func (self *gotestReporter) Exit() {} - -func (self *gotestReporter) EndStory() { - self.test = nil -} - -func (self *gotestReporter) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewGoTestReporter() *gotestReporter { - return new(gotestReporter) -} - -func passed(r *AssertionResult) bool { - return r.Error == nil && r.Failure == "" -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/init.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/init.go deleted file mode 100644 index 99c3bd6d..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/init.go +++ /dev/null @@ -1,94 +0,0 @@ -package reporting - -import ( - "os" - "runtime" - "strings" -) - -func init() { - if !isColorableTerminal() { - monochrome() - } - - if runtime.GOOS == "windows" { - success, failure, error_ = dotSuccess, dotFailure, dotError - } -} - -func BuildJsonReporter() Reporter { - out := NewPrinter(NewConsole()) - return NewReporters( - NewGoTestReporter(), - NewJsonReporter(out)) -} -func BuildDotReporter() Reporter { - out := NewPrinter(NewConsole()) - return NewReporters( - NewGoTestReporter(), - NewDotReporter(out), - NewProblemReporter(out), - consoleStatistics) -} -func BuildStoryReporter() Reporter { - out := NewPrinter(NewConsole()) - return NewReporters( - NewGoTestReporter(), - NewStoryReporter(out), - NewProblemReporter(out), - consoleStatistics) -} -func BuildSilentReporter() Reporter { - out := NewPrinter(NewConsole()) - return NewReporters( - NewGoTestReporter(), - NewSilentProblemReporter(out)) -} - -var ( - newline = "\n" - success = "✔" - failure = "✘" - error_ = "🔥" - skip = "⚠" - dotSuccess = "." - dotFailure = "x" - dotError = "E" - dotSkip = "S" - errorTemplate = "* %s \nLine %d: - %v \n%s\n" - failureTemplate = "* %s \nLine %d:\n%s\n%s\n" -) - -var ( - greenColor = "\033[32m" - yellowColor = "\033[33m" - redColor = "\033[31m" - resetColor = "\033[0m" -) - -var consoleStatistics = NewStatisticsReporter(NewPrinter(NewConsole())) - -func SuppressConsoleStatistics() { consoleStatistics.Suppress() } -func PrintConsoleStatistics() { consoleStatistics.PrintSummary() } - -// QuietMode disables all console output symbols. This is only meant to be used -// for tests that are internal to goconvey where the output is distracting or -// otherwise not needed in the test output. -func QuietMode() { - success, failure, error_, skip, dotSuccess, dotFailure, dotError, dotSkip = "", "", "", "", "", "", "", "" -} - -func monochrome() { - greenColor, yellowColor, redColor, resetColor = "", "", "", "" -} - -func isColorableTerminal() bool { - return strings.Contains(os.Getenv("TERM"), "color") -} - -// This interface allows us to pass the *testing.T struct -// throughout the internals of this tool without ever -// having to import the "testing" package. -type T interface { - Fail() -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/json.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/json.go deleted file mode 100644 index f8526979..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/json.go +++ /dev/null @@ -1,88 +0,0 @@ -// TODO: under unit test - -package reporting - -import ( - "bytes" - "encoding/json" - "fmt" - "strings" -) - -type JsonReporter struct { - out *Printer - currentKey []string - current *ScopeResult - index map[string]*ScopeResult - scopes []*ScopeResult -} - -func (self *JsonReporter) depth() int { return len(self.currentKey) } - -func (self *JsonReporter) BeginStory(story *StoryReport) {} - -func (self *JsonReporter) Enter(scope *ScopeReport) { - self.currentKey = append(self.currentKey, scope.Title) - ID := strings.Join(self.currentKey, "|") - if _, found := self.index[ID]; !found { - next := newScopeResult(scope.Title, self.depth(), scope.File, scope.Line) - self.scopes = append(self.scopes, next) - self.index[ID] = next - } - self.current = self.index[ID] -} - -func (self *JsonReporter) Report(report *AssertionResult) { - self.current.Assertions = append(self.current.Assertions, report) -} - -func (self *JsonReporter) Exit() { - self.currentKey = self.currentKey[:len(self.currentKey)-1] -} - -func (self *JsonReporter) EndStory() { - self.report() - self.reset() -} -func (self *JsonReporter) report() { - scopes := []string{} - for _, scope := range self.scopes { - serialized, err := json.Marshal(scope) - if err != nil { - self.out.Println(jsonMarshalFailure) - panic(err) - } - var buffer bytes.Buffer - json.Indent(&buffer, serialized, "", " ") - scopes = append(scopes, buffer.String()) - } - self.out.Print(fmt.Sprintf("%s\n%s,\n%s\n", OpenJson, strings.Join(scopes, ","), CloseJson)) -} -func (self *JsonReporter) reset() { - self.scopes = []*ScopeResult{} - self.index = map[string]*ScopeResult{} - self.currentKey = nil -} - -func (self *JsonReporter) Write(content []byte) (written int, err error) { - self.current.Output += string(content) - return len(content), nil -} - -func NewJsonReporter(out *Printer) *JsonReporter { - self := new(JsonReporter) - self.out = out - self.reset() - return self -} - -const OpenJson = ">->->OPEN-JSON->->->" // "⌦" -const CloseJson = "<-<-<-CLOSE-JSON<-<-<" // "⌫" -const jsonMarshalFailure = ` - -GOCONVEY_JSON_MARSHALL_FAILURE: There was an error when attempting to convert test results to JSON. -Please file a bug report and reference the code that caused this failure if possible. - -Here's the panic: - -` diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/printer.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/printer.go deleted file mode 100644 index 3dac0d4d..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/printer.go +++ /dev/null @@ -1,60 +0,0 @@ -package reporting - -import ( - "fmt" - "io" - "strings" -) - -type Printer struct { - out io.Writer - prefix string -} - -func (self *Printer) Println(message string, values ...interface{}) { - formatted := self.format(message, values...) + newline - self.out.Write([]byte(formatted)) -} - -func (self *Printer) Print(message string, values ...interface{}) { - formatted := self.format(message, values...) - self.out.Write([]byte(formatted)) -} - -func (self *Printer) Insert(text string) { - self.out.Write([]byte(text)) -} - -func (self *Printer) format(message string, values ...interface{}) string { - var formatted string - if len(values) == 0 { - formatted = self.prefix + message - } else { - formatted = self.prefix + fmt_Sprintf(message, values...) - } - indented := strings.Replace(formatted, newline, newline+self.prefix, -1) - return strings.TrimRight(indented, space) -} - -// Extracting fmt.Sprintf to a separate variable circumvents go vet, which, as of go 1.10 is run with go test. -var fmt_Sprintf = fmt.Sprintf - -func (self *Printer) Indent() { - self.prefix += pad -} - -func (self *Printer) Dedent() { - if len(self.prefix) >= padLength { - self.prefix = self.prefix[:len(self.prefix)-padLength] - } -} - -func NewPrinter(out io.Writer) *Printer { - self := new(Printer) - self.out = out - return self -} - -const space = " " -const pad = space + space -const padLength = len(pad) diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/problems.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/problems.go deleted file mode 100644 index 33d5e147..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/problems.go +++ /dev/null @@ -1,80 +0,0 @@ -package reporting - -import "fmt" - -type problem struct { - silent bool - out *Printer - errors []*AssertionResult - failures []*AssertionResult -} - -func (self *problem) BeginStory(story *StoryReport) {} - -func (self *problem) Enter(scope *ScopeReport) {} - -func (self *problem) Report(report *AssertionResult) { - if report.Error != nil { - self.errors = append(self.errors, report) - } else if report.Failure != "" { - self.failures = append(self.failures, report) - } -} - -func (self *problem) Exit() {} - -func (self *problem) EndStory() { - self.show(self.showErrors, redColor) - self.show(self.showFailures, yellowColor) - self.prepareForNextStory() -} -func (self *problem) show(display func(), color string) { - if !self.silent { - fmt.Print(color) - } - display() - if !self.silent { - fmt.Print(resetColor) - } - self.out.Dedent() -} -func (self *problem) showErrors() { - for i, e := range self.errors { - if i == 0 { - self.out.Println("\nErrors:\n") - self.out.Indent() - } - self.out.Println(errorTemplate, e.File, e.Line, e.Error, e.StackTrace) - } -} -func (self *problem) showFailures() { - for i, f := range self.failures { - if i == 0 { - self.out.Println("\nFailures:\n") - self.out.Indent() - } - self.out.Println(failureTemplate, f.File, f.Line, f.Failure, f.StackTrace) - } -} - -func (self *problem) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewProblemReporter(out *Printer) *problem { - self := new(problem) - self.out = out - self.prepareForNextStory() - return self -} - -func NewSilentProblemReporter(out *Printer) *problem { - self := NewProblemReporter(out) - self.silent = true - return self -} - -func (self *problem) prepareForNextStory() { - self.errors = []*AssertionResult{} - self.failures = []*AssertionResult{} -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/reporter.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/reporter.go deleted file mode 100644 index cce6c5e4..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/reporter.go +++ /dev/null @@ -1,39 +0,0 @@ -package reporting - -import "io" - -type Reporter interface { - BeginStory(story *StoryReport) - Enter(scope *ScopeReport) - Report(r *AssertionResult) - Exit() - EndStory() - io.Writer -} - -type reporters struct{ collection []Reporter } - -func (self *reporters) BeginStory(s *StoryReport) { self.foreach(func(r Reporter) { r.BeginStory(s) }) } -func (self *reporters) Enter(s *ScopeReport) { self.foreach(func(r Reporter) { r.Enter(s) }) } -func (self *reporters) Report(a *AssertionResult) { self.foreach(func(r Reporter) { r.Report(a) }) } -func (self *reporters) Exit() { self.foreach(func(r Reporter) { r.Exit() }) } -func (self *reporters) EndStory() { self.foreach(func(r Reporter) { r.EndStory() }) } - -func (self *reporters) Write(contents []byte) (written int, err error) { - self.foreach(func(r Reporter) { - written, err = r.Write(contents) - }) - return written, err -} - -func (self *reporters) foreach(action func(Reporter)) { - for _, r := range self.collection { - action(r) - } -} - -func NewReporters(collection ...Reporter) *reporters { - self := new(reporters) - self.collection = collection - return self -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey b/vendor/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey deleted file mode 100644 index 79982854..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey +++ /dev/null @@ -1,2 +0,0 @@ -#ignore --timeout=1s diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/reports.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/reports.go deleted file mode 100644 index 712e6ade..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/reports.go +++ /dev/null @@ -1,179 +0,0 @@ -package reporting - -import ( - "encoding/json" - "fmt" - "runtime" - "strings" - - "github.com/smartystreets/goconvey/convey/gotest" -) - -////////////////// ScopeReport //////////////////// - -type ScopeReport struct { - Title string - File string - Line int -} - -func NewScopeReport(title string) *ScopeReport { - file, line, _ := gotest.ResolveExternalCaller() - self := new(ScopeReport) - self.Title = title - self.File = file - self.Line = line - return self -} - -////////////////// ScopeResult //////////////////// - -type ScopeResult struct { - Title string - File string - Line int - Depth int - Assertions []*AssertionResult - Output string -} - -func newScopeResult(title string, depth int, file string, line int) *ScopeResult { - self := new(ScopeResult) - self.Title = title - self.Depth = depth - self.File = file - self.Line = line - self.Assertions = []*AssertionResult{} - return self -} - -/////////////////// StoryReport ///////////////////// - -type StoryReport struct { - Test T - Name string - File string - Line int -} - -func NewStoryReport(test T) *StoryReport { - file, line, name := gotest.ResolveExternalCaller() - name = removePackagePath(name) - self := new(StoryReport) - self.Test = test - self.Name = name - self.File = file - self.Line = line - return self -} - -// name comes in looking like "github.com/smartystreets/goconvey/examples.TestName". -// We only want the stuff after the last '.', which is the name of the test function. -func removePackagePath(name string) string { - parts := strings.Split(name, ".") - return parts[len(parts)-1] -} - -/////////////////// FailureView //////////////////////// - -// This struct is also declared in github.com/smartystreets/assertions. -// The json struct tags should be equal in both declarations. -type FailureView struct { - Message string `json:"Message"` - Expected string `json:"Expected"` - Actual string `json:"Actual"` -} - -////////////////////AssertionResult ////////////////////// - -type AssertionResult struct { - File string - Line int - Expected string - Actual string - Failure string - Error interface{} - StackTrace string - Skipped bool -} - -func NewFailureReport(failure string) *AssertionResult { - report := new(AssertionResult) - report.File, report.Line = caller() - report.StackTrace = stackTrace() - parseFailure(failure, report) - return report -} -func parseFailure(failure string, report *AssertionResult) { - view := new(FailureView) - err := json.Unmarshal([]byte(failure), view) - if err == nil { - report.Failure = view.Message - report.Expected = view.Expected - report.Actual = view.Actual - } else { - report.Failure = failure - } -} -func NewErrorReport(err interface{}) *AssertionResult { - report := new(AssertionResult) - report.File, report.Line = caller() - report.StackTrace = fullStackTrace() - report.Error = fmt.Sprintf("%v", err) - return report -} -func NewSuccessReport() *AssertionResult { - return new(AssertionResult) -} -func NewSkipReport() *AssertionResult { - report := new(AssertionResult) - report.File, report.Line = caller() - report.StackTrace = fullStackTrace() - report.Skipped = true - return report -} - -func caller() (file string, line int) { - file, line, _ = gotest.ResolveExternalCaller() - return -} - -func stackTrace() string { - buffer := make([]byte, 1024*64) - n := runtime.Stack(buffer, false) - return removeInternalEntries(string(buffer[:n])) -} -func fullStackTrace() string { - buffer := make([]byte, 1024*64) - n := runtime.Stack(buffer, true) - return removeInternalEntries(string(buffer[:n])) -} -func removeInternalEntries(stack string) string { - lines := strings.Split(stack, newline) - filtered := []string{} - for _, line := range lines { - if !isExternal(line) { - filtered = append(filtered, line) - } - } - return strings.Join(filtered, newline) -} -func isExternal(line string) bool { - for _, p := range internalPackages { - if strings.Contains(line, p) { - return true - } - } - return false -} - -// NOTE: any new packages that host goconvey packages will need to be added here! -// An alternative is to scan the goconvey directory and then exclude stuff like -// the examples package but that's nasty too. -var internalPackages = []string{ - "goconvey/assertions", - "goconvey/convey", - "goconvey/execution", - "goconvey/gotest", - "goconvey/reporting", -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/statistics.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/statistics.go deleted file mode 100644 index c3ccd056..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/statistics.go +++ /dev/null @@ -1,108 +0,0 @@ -package reporting - -import ( - "fmt" - "sync" -) - -func (self *statistics) BeginStory(story *StoryReport) {} - -func (self *statistics) Enter(scope *ScopeReport) {} - -func (self *statistics) Report(report *AssertionResult) { - self.Lock() - defer self.Unlock() - - if !self.failing && report.Failure != "" { - self.failing = true - } - if !self.erroring && report.Error != nil { - self.erroring = true - } - if report.Skipped { - self.skipped += 1 - } else { - self.total++ - } -} - -func (self *statistics) Exit() {} - -func (self *statistics) EndStory() { - self.Lock() - defer self.Unlock() - - if !self.suppressed { - self.printSummaryLocked() - } -} - -func (self *statistics) Suppress() { - self.Lock() - defer self.Unlock() - self.suppressed = true -} - -func (self *statistics) PrintSummary() { - self.Lock() - defer self.Unlock() - self.printSummaryLocked() -} - -func (self *statistics) printSummaryLocked() { - self.reportAssertionsLocked() - self.reportSkippedSectionsLocked() - self.completeReportLocked() -} -func (self *statistics) reportAssertionsLocked() { - self.decideColorLocked() - self.out.Print("\n%d total %s", self.total, plural("assertion", self.total)) -} -func (self *statistics) decideColorLocked() { - if self.failing && !self.erroring { - fmt.Print(yellowColor) - } else if self.erroring { - fmt.Print(redColor) - } else { - fmt.Print(greenColor) - } -} -func (self *statistics) reportSkippedSectionsLocked() { - if self.skipped > 0 { - fmt.Print(yellowColor) - self.out.Print(" (one or more sections skipped)") - } -} -func (self *statistics) completeReportLocked() { - fmt.Print(resetColor) - self.out.Print("\n") - self.out.Print("\n") -} - -func (self *statistics) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewStatisticsReporter(out *Printer) *statistics { - self := statistics{} - self.out = out - return &self -} - -type statistics struct { - sync.Mutex - - out *Printer - total int - failing bool - erroring bool - skipped int - suppressed bool -} - -func plural(word string, count int) string { - if count == 1 { - return word - } - return word + "s" -} diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/story.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/story.go deleted file mode 100644 index 9e73c971..00000000 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/story.go +++ /dev/null @@ -1,73 +0,0 @@ -// TODO: in order for this reporter to be completely honest -// we need to retrofit to be more like the json reporter such that: -// 1. it maintains ScopeResult collections, which count assertions -// 2. it reports only after EndStory(), so that all tick marks -// are placed near the appropriate title. -// 3. Under unit test - -package reporting - -import ( - "fmt" - "strings" -) - -type story struct { - out *Printer - titlesById map[string]string - currentKey []string -} - -func (self *story) BeginStory(story *StoryReport) {} - -func (self *story) Enter(scope *ScopeReport) { - self.out.Indent() - - self.currentKey = append(self.currentKey, scope.Title) - ID := strings.Join(self.currentKey, "|") - - if _, found := self.titlesById[ID]; !found { - self.out.Println("") - self.out.Print(scope.Title) - self.out.Insert(" ") - self.titlesById[ID] = scope.Title - } -} - -func (self *story) Report(report *AssertionResult) { - if report.Error != nil { - fmt.Print(redColor) - self.out.Insert(error_) - } else if report.Failure != "" { - fmt.Print(yellowColor) - self.out.Insert(failure) - } else if report.Skipped { - fmt.Print(yellowColor) - self.out.Insert(skip) - } else { - fmt.Print(greenColor) - self.out.Insert(success) - } - fmt.Print(resetColor) -} - -func (self *story) Exit() { - self.out.Dedent() - self.currentKey = self.currentKey[:len(self.currentKey)-1] -} - -func (self *story) EndStory() { - self.titlesById = make(map[string]string) - self.out.Println("\n") -} - -func (self *story) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewStoryReporter(out *Printer) *story { - self := new(story) - self.out = out - self.titlesById = make(map[string]string) - return self -} diff --git a/vendor/github.com/smartystreets/goconvey/dependencies.go b/vendor/github.com/smartystreets/goconvey/dependencies.go deleted file mode 100644 index 0839e27f..00000000 --- a/vendor/github.com/smartystreets/goconvey/dependencies.go +++ /dev/null @@ -1,4 +0,0 @@ -package main - -import _ "github.com/jtolds/gls" -import _ "github.com/smartystreets/assertions" diff --git a/vendor/github.com/smartystreets/goconvey/go.mod b/vendor/github.com/smartystreets/goconvey/go.mod deleted file mode 100644 index 5764a0a3..00000000 --- a/vendor/github.com/smartystreets/goconvey/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module github.com/smartystreets/goconvey - -require ( - github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect - github.com/jtolds/gls v4.20.0+incompatible - github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d - golang.org/x/tools v0.0.0-20190328211700-ab21143f2384 -) diff --git a/vendor/github.com/smartystreets/goconvey/go.sum b/vendor/github.com/smartystreets/goconvey/go.sum deleted file mode 100644 index 4267185d..00000000 --- a/vendor/github.com/smartystreets/goconvey/go.sum +++ /dev/null @@ -1,12 +0,0 @@ -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384 h1:TFlARGu6Czu1z7q93HTxcP1P+/ZFC/IKythI5RzrnRg= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= diff --git a/vendor/github.com/smartystreets/goconvey/goconvey.go b/vendor/github.com/smartystreets/goconvey/goconvey.go deleted file mode 100644 index 2e1be674..00000000 --- a/vendor/github.com/smartystreets/goconvey/goconvey.go +++ /dev/null @@ -1,293 +0,0 @@ -// This executable provides an HTTP server that watches for file system changes -// to .go files within the working directory (and all nested go packages). -// Navigating to the configured host and port in a web browser will display the -// latest results of running `go test` in each go package. -package main - -import ( - "flag" - "fmt" - "log" - "net" - "net/http" - "os" - "os/exec" - "path/filepath" - "regexp" - "runtime" - "strconv" - "strings" - "time" - - "github.com/smartystreets/goconvey/web/server/api" - "github.com/smartystreets/goconvey/web/server/contract" - "github.com/smartystreets/goconvey/web/server/executor" - "github.com/smartystreets/goconvey/web/server/messaging" - "github.com/smartystreets/goconvey/web/server/parser" - "github.com/smartystreets/goconvey/web/server/system" - "github.com/smartystreets/goconvey/web/server/watch" -) - -func init() { - flags() - folders() -} -func flags() { - flag.IntVar(&port, "port", 8080, "The port at which to serve http.") - flag.StringVar(&host, "host", "127.0.0.1", "The host at which to serve http.") - flag.DurationVar(&nap, "poll", quarterSecond, "The interval to wait between polling the file system for changes.") - flag.IntVar(¶llelPackages, "packages", 10, "The number of packages to test in parallel. Higher == faster but more costly in terms of computing.") - flag.StringVar(&gobin, "gobin", "go", "The path to the 'go' binary (default: search on the PATH).") - flag.BoolVar(&cover, "cover", true, "Enable package-level coverage statistics. Requires Go 1.2+ and the go cover tool.") - flag.IntVar(&depth, "depth", -1, "The directory scanning depth. If -1, scan infinitely deep directory structures. 0: scan working directory. 1+: Scan into nested directories, limited to value.") - flag.StringVar(&timeout, "timeout", "0", "The test execution timeout if none is specified in the *.goconvey file (default is '0', which is the same as not providing this option).") - flag.StringVar(&watchedSuffixes, "watchedSuffixes", ".go", "A comma separated list of file suffixes to watch for modifications.") - flag.StringVar(&excludedDirs, "excludedDirs", "vendor,node_modules", "A comma separated list of directories that will be excluded from being watched") - flag.StringVar(&workDir, "workDir", "", "set goconvey working directory (default current directory)") - flag.BoolVar(&autoLaunchBrowser, "launchBrowser", true, "toggle auto launching of browser (default: true)") - - log.SetOutput(os.Stdout) - log.SetFlags(log.LstdFlags | log.Lshortfile) -} -func folders() { - _, file, _, _ := runtime.Caller(0) - here := filepath.Dir(file) - static = filepath.Join(here, "/web/client") - reports = filepath.Join(static, "reports") -} - -func main() { - flag.Parse() - log.Printf(initialConfiguration, host, port, nap, cover) - - working := getWorkDir() - cover = coverageEnabled(cover, reports) - shell := system.NewShell(gobin, reports, cover, timeout) - - watcherInput := make(chan messaging.WatcherCommand) - watcherOutput := make(chan messaging.Folders) - excludedDirItems := strings.Split(excludedDirs, `,`) - watcher := watch.NewWatcher(working, depth, nap, watcherInput, watcherOutput, watchedSuffixes, excludedDirItems) - - parser := parser.NewParser(parser.ParsePackageResults) - tester := executor.NewConcurrentTester(shell) - tester.SetBatchSize(parallelPackages) - - longpollChan := make(chan chan string) - executor := executor.NewExecutor(tester, parser, longpollChan) - server := api.NewHTTPServer(working, watcherInput, executor, longpollChan) - listener := createListener() - go runTestOnUpdates(watcherOutput, executor, server) - go watcher.Listen() - if autoLaunchBrowser { - go launchBrowser(listener.Addr().String()) - } - serveHTTP(server, listener) -} - -func browserCmd() (string, bool) { - browser := map[string]string{ - "darwin": "open", - "linux": "xdg-open", - "windows": "start", - } - cmd, ok := browser[runtime.GOOS] - return cmd, ok -} - -func launchBrowser(addr string) { - browser, ok := browserCmd() - if !ok { - log.Printf("Skipped launching browser for this OS: %s", runtime.GOOS) - return - } - - log.Printf("Launching browser on %s", addr) - url := fmt.Sprintf("http://%s", addr) - cmd := exec.Command(browser, url) - - output, err := cmd.CombinedOutput() - if err != nil { - log.Println(err) - } - log.Println(string(output)) -} - -func runTestOnUpdates(queue chan messaging.Folders, executor contract.Executor, server contract.Server) { - for update := range queue { - log.Println("Received request from watcher to execute tests...") - packages := extractPackages(update) - output := executor.ExecuteTests(packages) - root := extractRoot(update, packages) - server.ReceiveUpdate(root, output) - } -} - -func extractPackages(folderList messaging.Folders) []*contract.Package { - packageList := []*contract.Package{} - for _, folder := range folderList { - hasImportCycle := testFilesImportTheirOwnPackage(folder.Path) - packageName := resolvePackageName(folder.Path) - packageList = append( - packageList, - contract.NewPackage(folder, packageName, hasImportCycle), - ) - } - return packageList -} - -func extractRoot(folderList messaging.Folders, packageList []*contract.Package) string { - path := packageList[0].Path - folder := folderList[path] - return folder.Root -} - -func createListener() net.Listener { - l, err := net.Listen("tcp", fmt.Sprintf("%s:%d", host, port)) - if err != nil { - log.Println(err) - } - if l == nil { - os.Exit(1) - } - return l -} - -func serveHTTP(server contract.Server, listener net.Listener) { - serveStaticResources() - serveAjaxMethods(server) - activateServer(listener) -} - -func serveStaticResources() { - http.Handle("/", http.FileServer(http.Dir(static))) -} - -func serveAjaxMethods(server contract.Server) { - http.HandleFunc("/watch", server.Watch) - http.HandleFunc("/ignore", server.Ignore) - http.HandleFunc("/reinstate", server.Reinstate) - http.HandleFunc("/latest", server.Results) - http.HandleFunc("/execute", server.Execute) - http.HandleFunc("/status", server.Status) - http.HandleFunc("/status/poll", server.LongPollStatus) - http.HandleFunc("/pause", server.TogglePause) -} - -func activateServer(listener net.Listener) { - log.Printf("Serving HTTP at: http://%s\n", listener.Addr()) - err := http.Serve(listener, nil) - if err != nil { - log.Println(err) - } -} - -func coverageEnabled(cover bool, reports string) bool { - return (cover && - goMinVersion(1, 2) && - coverToolInstalled() && - ensureReportDirectoryExists(reports)) -} -func goMinVersion(wanted ...int) bool { - version := runtime.Version() // 'go1.2....' - s := regexp.MustCompile(`go([\d]+)\.([\d]+)\.?([\d]+)?`).FindAllStringSubmatch(version, 1) - if len(s) == 0 { - log.Printf("Cannot determine if newer than go1.2, disabling coverage.") - return false - } - for idx, str := range s[0][1:] { - if len(wanted) == idx { - break - } - if v, _ := strconv.Atoi(str); v < wanted[idx] { - log.Printf(pleaseUpgradeGoVersion, version) - return false - } - } - return true -} -func coverToolInstalled() bool { - working := getWorkDir() - command := system.NewCommand(working, "go", "tool", "cover").Execute() - installed := strings.Contains(command.Output, "Usage of 'go tool cover':") - if !installed { - log.Print(coverToolMissing) - return false - } - return true -} -func ensureReportDirectoryExists(reports string) bool { - result, err := exists(reports) - if err != nil { - log.Fatal(err) - } - if result { - return true - } - - if err := os.Mkdir(reports, 0755); err == nil { - return true - } - - log.Printf(reportDirectoryUnavailable, reports) - return false -} -func exists(path string) (bool, error) { - _, err := os.Stat(path) - if err == nil { - return true, nil - } - if os.IsNotExist(err) { - return false, nil - } - return false, err -} -func getWorkDir() string { - working := "" - var err error - if workDir != "" { - working = workDir - } else { - working, err = os.Getwd() - if err != nil { - log.Fatal(err) - } - } - result, err := exists(working) - if err != nil { - log.Fatal(err) - } - if !result { - log.Fatalf("Path:%s does not exists", working) - } - return working -} - -var ( - port int - host string - gobin string - nap time.Duration - parallelPackages int - cover bool - depth int - timeout string - watchedSuffixes string - excludedDirs string - autoLaunchBrowser bool - - static string - reports string - - quarterSecond = time.Millisecond * 250 - workDir string -) - -const ( - initialConfiguration = "Initial configuration: [host: %s] [port: %d] [poll: %v] [cover: %v]\n" - pleaseUpgradeGoVersion = "Go version is less that 1.2 (%s), please upgrade to the latest stable version to enable coverage reporting.\n" - coverToolMissing = "Go cover tool is not installed or not accessible: for Go < 1.5 run`go get golang.org/x/tools/cmd/cover`\n For >= Go 1.5 run `go install $GOROOT/src/cmd/cover`\n" - reportDirectoryUnavailable = "Could not find or create the coverage report directory (at: '%s'). You probably won't see any coverage statistics...\n" - separator = string(filepath.Separator) - endGoPath = separator + "src" + separator -) diff --git a/vendor/github.com/smartystreets/goconvey/goconvey_1_8.go b/vendor/github.com/smartystreets/goconvey/goconvey_1_8.go deleted file mode 100644 index a40694c2..00000000 --- a/vendor/github.com/smartystreets/goconvey/goconvey_1_8.go +++ /dev/null @@ -1,42 +0,0 @@ -// +build !go1.9 - -// To work correctly with out of GOPATH modules, some functions needed to -// switch from using go/build to golang.org/x/tools/go/packages. But that -// package depends on changes to go/types that were introduced in Go 1.9. Since -// modules weren't introduced until Go 1.11, users of Go 1.8 or below can't be -// using modules, so they can continue to use go/build. - -package main - -import ( - "go/build" - "strings" -) - -// This method exists because of a bug in the go cover tool that -// causes an infinite loop when you try to run `go test -cover` -// on a package that has an import cycle defined in one of it's -// test files. Yuck. -func testFilesImportTheirOwnPackage(packagePath string) bool { - meta, err := build.ImportDir(packagePath, build.AllowBinary) - if err != nil { - return false - } - - for _, dependency := range meta.TestImports { - if dependency == meta.ImportPath { - return true - } - } - return false -} - -func resolvePackageName(path string) string { - pkg, err := build.ImportDir(path, build.FindOnly) - if err == nil { - return pkg.ImportPath - } - - nameArr := strings.Split(path, endGoPath) - return nameArr[len(nameArr)-1] -} diff --git a/vendor/github.com/smartystreets/goconvey/goconvey_1_9.go b/vendor/github.com/smartystreets/goconvey/goconvey_1_9.go deleted file mode 100644 index 9a5c0bd9..00000000 --- a/vendor/github.com/smartystreets/goconvey/goconvey_1_9.go +++ /dev/null @@ -1,64 +0,0 @@ -// +build go1.9 - -// To work correctly with out of GOPATH modules, some functions needed to -// switch from using go/build to golang.org/x/tools/go/packages. But that -// package depends on changes to go/types that were introduced in Go 1.9. Since -// modules weren't introduced until Go 1.11, using -// golang.org/x/tools/go/packages can safely be restricted to users of Go 1.9 -// or above. -package main - -import ( - "fmt" - "strings" - - "golang.org/x/tools/go/packages" -) - -// This method exists because of a bug in the go cover tool that -// causes an infinite loop when you try to run `go test -cover` -// on a package that has an import cycle defined in one of it's -// test files. Yuck. -func testFilesImportTheirOwnPackage(packagePath string) bool { - meta, err := packages.Load( - &packages.Config{ - Mode: packages.NeedName | packages.NeedImports, - Tests: true, - }, - packagePath, - ) - if err != nil { - return false - } - - testPackageID := fmt.Sprintf("%s [%s.test]", meta[0], meta[0]) - - for _, testPackage := range meta[1:] { - if testPackage.ID != testPackageID { - continue - } - - for dependency := range testPackage.Imports { - if dependency == meta[0].PkgPath { - return true - } - } - break - } - return false -} - -func resolvePackageName(path string) string { - pkg, err := packages.Load( - &packages.Config{ - Mode: packages.NeedName, - }, - path, - ) - if err == nil { - return pkg[0].PkgPath - } - - nameArr := strings.Split(path, endGoPath) - return nameArr[len(nameArr)-1] -} diff --git a/vendor/github.com/smartystreets/goconvey/web/server/api/api.goconvey b/vendor/github.com/smartystreets/goconvey/web/server/api/api.goconvey deleted file mode 100644 index 79982854..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/api/api.goconvey +++ /dev/null @@ -1,2 +0,0 @@ -#ignore --timeout=1s diff --git a/vendor/github.com/smartystreets/goconvey/web/server/api/server.go b/vendor/github.com/smartystreets/goconvey/web/server/api/server.go deleted file mode 100644 index 6cea26da..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/api/server.go +++ /dev/null @@ -1,164 +0,0 @@ -package api - -import ( - "encoding/json" - "fmt" - "net/http" - "os" - "strconv" - "time" - - "github.com/smartystreets/goconvey/web/server/contract" - "github.com/smartystreets/goconvey/web/server/messaging" -) - -type HTTPServer struct { - watcher chan messaging.WatcherCommand - executor contract.Executor - latest *contract.CompleteOutput - currentRoot string - longpoll chan chan string - paused bool -} - -func (self *HTTPServer) ReceiveUpdate(root string, update *contract.CompleteOutput) { - self.currentRoot = root - self.latest = update -} - -func (self *HTTPServer) Watch(response http.ResponseWriter, request *http.Request) { - if request.Method == "POST" { - self.adjustRoot(response, request) - } else if request.Method == "GET" { - response.Write([]byte(self.currentRoot)) - } -} - -func (self *HTTPServer) adjustRoot(response http.ResponseWriter, request *http.Request) { - newRoot := self.parseQueryString("root", response, request) - if newRoot == "" { - return - } - info, err := os.Stat(newRoot) // TODO: how to unit test? - if !info.IsDir() || err != nil { - http.Error(response, err.Error(), http.StatusNotFound) - return - } - - self.watcher <- messaging.WatcherCommand{ - Instruction: messaging.WatcherAdjustRoot, - Details: newRoot, - } -} - -func (self *HTTPServer) Ignore(response http.ResponseWriter, request *http.Request) { - paths := self.parseQueryString("paths", response, request) - if paths != "" { - self.watcher <- messaging.WatcherCommand{ - Instruction: messaging.WatcherIgnore, - Details: paths, - } - } -} - -func (self *HTTPServer) Reinstate(response http.ResponseWriter, request *http.Request) { - paths := self.parseQueryString("paths", response, request) - if paths != "" { - self.watcher <- messaging.WatcherCommand{ - Instruction: messaging.WatcherReinstate, - Details: paths, - } - } -} - -func (self *HTTPServer) parseQueryString(key string, response http.ResponseWriter, request *http.Request) string { - value := request.URL.Query()[key] - - if len(value) == 0 { - http.Error(response, fmt.Sprintf("No '%s' query string parameter included!", key), http.StatusBadRequest) - return "" - } - - path := value[0] - if path == "" { - http.Error(response, "You must provide a non-blank path.", http.StatusBadRequest) - } - return path -} - -func (self *HTTPServer) Status(response http.ResponseWriter, request *http.Request) { - status := self.executor.Status() - response.Write([]byte(status)) -} - -func (self *HTTPServer) LongPollStatus(response http.ResponseWriter, request *http.Request) { - if self.executor.ClearStatusFlag() { - response.Write([]byte(self.executor.Status())) - return - } - - timeout, err := strconv.Atoi(request.URL.Query().Get("timeout")) - if err != nil || timeout > 180000 || timeout < 0 { - timeout = 60000 // default timeout is 60 seconds - } - - myReqChan := make(chan string) - - select { - case self.longpoll <- myReqChan: // this case means the executor's status is changing - case <-time.After(time.Duration(timeout) * time.Millisecond): // this case means the executor hasn't changed status - return - } - - out := <-myReqChan - - if out != "" { // TODO: Why is this check necessary? Sometimes it writes empty string... - response.Write([]byte(out)) - } -} - -func (self *HTTPServer) Results(response http.ResponseWriter, request *http.Request) { - response.Header().Set("Content-Type", "application/json") - response.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") - response.Header().Set("Pragma", "no-cache") - response.Header().Set("Expires", "0") - if self.latest != nil { - self.latest.Paused = self.paused - } - stuff, _ := json.Marshal(self.latest) - response.Write(stuff) -} - -func (self *HTTPServer) Execute(response http.ResponseWriter, request *http.Request) { - go self.execute() -} - -func (self *HTTPServer) execute() { - self.watcher <- messaging.WatcherCommand{Instruction: messaging.WatcherExecute} -} - -func (self *HTTPServer) TogglePause(response http.ResponseWriter, request *http.Request) { - instruction := messaging.WatcherPause - if self.paused { - instruction = messaging.WatcherResume - } - - self.watcher <- messaging.WatcherCommand{Instruction: instruction} - self.paused = !self.paused - - fmt.Fprint(response, self.paused) // we could write out whatever helps keep the UI honest... -} - -func NewHTTPServer( - root string, - watcher chan messaging.WatcherCommand, - executor contract.Executor, - status chan chan string) *HTTPServer { - - self := new(HTTPServer) - self.currentRoot = root - self.watcher = watcher - self.executor = executor - self.longpoll = status - return self -} diff --git a/vendor/github.com/smartystreets/goconvey/web/server/contract/contracts.go b/vendor/github.com/smartystreets/goconvey/web/server/contract/contracts.go deleted file mode 100644 index e758f3e1..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/contract/contracts.go +++ /dev/null @@ -1,27 +0,0 @@ -package contract - -import "net/http" - -type ( - Server interface { - ReceiveUpdate(root string, update *CompleteOutput) - Watch(writer http.ResponseWriter, request *http.Request) - Ignore(writer http.ResponseWriter, request *http.Request) - Reinstate(writer http.ResponseWriter, request *http.Request) - Status(writer http.ResponseWriter, request *http.Request) - LongPollStatus(writer http.ResponseWriter, request *http.Request) - Results(writer http.ResponseWriter, request *http.Request) - Execute(writer http.ResponseWriter, request *http.Request) - TogglePause(writer http.ResponseWriter, request *http.Request) - } - - Executor interface { - ExecuteTests([]*Package) *CompleteOutput - Status() string - ClearStatusFlag() bool - } - - Shell interface { - GoTest(directory, packageName string, tags, arguments []string) (output string, err error) - } -) diff --git a/vendor/github.com/smartystreets/goconvey/web/server/contract/result.go b/vendor/github.com/smartystreets/goconvey/web/server/contract/result.go deleted file mode 100644 index 8feef715..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/contract/result.go +++ /dev/null @@ -1,100 +0,0 @@ -package contract - -import ( - "github.com/smartystreets/goconvey/convey/reporting" - "github.com/smartystreets/goconvey/web/server/messaging" -) - -type Package struct { - Path string - Name string - Ignored bool - Disabled bool - BuildTags []string - TestArguments []string - Error error - Output string - Result *PackageResult - - HasImportCycle bool -} - -func NewPackage(folder *messaging.Folder, name string, hasImportCycle bool) *Package { - self := new(Package) - self.Path = folder.Path - self.Name = name - self.Result = NewPackageResult(self.Name) - self.Ignored = folder.Ignored - self.Disabled = folder.Disabled - self.BuildTags = folder.BuildTags - self.TestArguments = folder.TestArguments - self.HasImportCycle = hasImportCycle - return self -} - -func (self *Package) Active() bool { - return !self.Disabled && !self.Ignored -} - -func (self *Package) HasUsableResult() bool { - return self.Active() && (self.Error == nil || (self.Output != "")) -} - -type CompleteOutput struct { - Packages []*PackageResult - Revision string - Paused bool -} - -var ( // PackageResult.Outcome values: - Ignored = "ignored" - Disabled = "disabled" - Passed = "passed" - Failed = "failed" - Panicked = "panicked" - BuildFailure = "build failure" - NoTestFiles = "no test files" - NoTestFunctions = "no test functions" - NoGoFiles = "no go code" - - TestRunAbortedUnexpectedly = "test run aborted unexpectedly" -) - -type PackageResult struct { - PackageName string - Elapsed float64 - Coverage float64 - Outcome string - BuildOutput string - TestResults []TestResult -} - -func NewPackageResult(packageName string) *PackageResult { - self := new(PackageResult) - self.PackageName = packageName - self.TestResults = []TestResult{} - self.Coverage = -1 - return self -} - -type TestResult struct { - TestName string - Elapsed float64 - Passed bool - Skipped bool - File string - Line int - Message string - Error string - Stories []reporting.ScopeResult - - RawLines []string `json:",omitempty"` -} - -func NewTestResult(testName string) *TestResult { - self := new(TestResult) - self.Stories = []reporting.ScopeResult{} - self.RawLines = []string{} - self.TestName = testName - return self -} diff --git a/vendor/github.com/smartystreets/goconvey/web/server/executor/contract.go b/vendor/github.com/smartystreets/goconvey/web/server/executor/contract.go deleted file mode 100644 index 209dbca5..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/executor/contract.go +++ /dev/null @@ -1,12 +0,0 @@ -package executor - -import "github.com/smartystreets/goconvey/web/server/contract" - -type Parser interface { - Parse([]*contract.Package) -} - -type Tester interface { - SetBatchSize(batchSize int) - TestAll(folders []*contract.Package) -} diff --git a/vendor/github.com/smartystreets/goconvey/web/server/executor/coordinator.go b/vendor/github.com/smartystreets/goconvey/web/server/executor/coordinator.go deleted file mode 100644 index 117dd56d..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/executor/coordinator.go +++ /dev/null @@ -1,71 +0,0 @@ -package executor - -import ( - "errors" - "fmt" - "log" - "strings" - "sync" - - "github.com/smartystreets/goconvey/web/server/contract" -) - -type concurrentCoordinator struct { - batchSize int - queue chan *contract.Package - folders []*contract.Package - shell contract.Shell - waiter sync.WaitGroup -} - -func (self *concurrentCoordinator) ExecuteConcurrently() { - self.enlistWorkers() - self.scheduleTasks() - self.awaitCompletion() -} - -func (self *concurrentCoordinator) enlistWorkers() { - for i := 0; i < self.batchSize; i++ { - self.waiter.Add(1) - go self.worker(i) - } -} -func (self *concurrentCoordinator) worker(id int) { - for folder := range self.queue { - packageName := strings.Replace(folder.Name, "\\", "/", -1) - if !folder.Active() { - log.Printf("Skipping concurrent execution: %s\n", packageName) - continue - } - - if folder.HasImportCycle { - message := fmt.Sprintf("can't load package: import cycle not allowed\npackage %s\n\timports %s", packageName, packageName) - log.Println(message) - folder.Output, folder.Error = message, errors.New(message) - } else { - log.Printf("Executing concurrent tests: %s\n", packageName) - folder.Output, folder.Error = self.shell.GoTest(folder.Path, packageName, folder.BuildTags, folder.TestArguments) - } - } - self.waiter.Done() -} - -func (self *concurrentCoordinator) scheduleTasks() { - for _, folder := range self.folders { - self.queue <- folder - } -} - -func (self *concurrentCoordinator) awaitCompletion() { - close(self.queue) - self.waiter.Wait() -} - -func newConcurrentCoordinator(folders []*contract.Package, batchSize int, shell contract.Shell) *concurrentCoordinator { - self := new(concurrentCoordinator) - self.queue = make(chan *contract.Package) - self.folders = folders - self.batchSize = batchSize - self.shell = shell - return self -} diff --git a/vendor/github.com/smartystreets/goconvey/web/server/executor/executor.go b/vendor/github.com/smartystreets/goconvey/web/server/executor/executor.go deleted file mode 100644 index 887080cc..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/executor/executor.go +++ /dev/null @@ -1,84 +0,0 @@ -package executor - -import ( - "log" - "time" - - "github.com/smartystreets/goconvey/web/server/contract" -) - -const ( - Idle = "idle" - Executing = "executing" -) - -type Executor struct { - tester Tester - parser Parser - status string - statusChan chan chan string - statusFlag bool -} - -func (self *Executor) Status() string { - return self.status -} - -func (self *Executor) ClearStatusFlag() bool { - hasNewStatus := self.statusFlag - self.statusFlag = false - return hasNewStatus -} - -func (self *Executor) ExecuteTests(folders []*contract.Package) *contract.CompleteOutput { - defer func() { self.setStatus(Idle) }() - self.execute(folders) - result := self.parse(folders) - return result -} - -func (self *Executor) execute(folders []*contract.Package) { - self.setStatus(Executing) - self.tester.TestAll(folders) -} - -func (self *Executor) parse(folders []*contract.Package) *contract.CompleteOutput { - result := &contract.CompleteOutput{Revision: now().String()} - self.parser.Parse(folders) - for _, folder := range folders { - result.Packages = append(result.Packages, folder.Result) - } - return result -} - -func (self *Executor) setStatus(status string) { - self.status = status - self.statusFlag = true - -Loop: - for { - select { - case c := <-self.statusChan: - self.statusFlag = false - c <- status - default: - break Loop - } - } - - log.Printf("Executor status: '%s'\n", self.status) -} - -func NewExecutor(tester Tester, parser Parser, ch chan chan string) *Executor { - return &Executor{ - tester: tester, - parser: parser, - status: Idle, - statusChan: ch, - statusFlag: false, - } -} - -var now = func() time.Time { - return time.Now() -} diff --git a/vendor/github.com/smartystreets/goconvey/web/server/executor/executor.goconvey b/vendor/github.com/smartystreets/goconvey/web/server/executor/executor.goconvey deleted file mode 100644 index 79982854..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/executor/executor.goconvey +++ /dev/null @@ -1,2 +0,0 @@ -#ignore --timeout=1s diff --git a/vendor/github.com/smartystreets/goconvey/web/server/executor/tester.go b/vendor/github.com/smartystreets/goconvey/web/server/executor/tester.go deleted file mode 100644 index 76f353a5..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/executor/tester.go +++ /dev/null @@ -1,56 +0,0 @@ -package executor - -import ( - "errors" - "fmt" - "log" - "strings" - - "github.com/smartystreets/goconvey/web/server/contract" -) - -type ConcurrentTester struct { - shell contract.Shell - batchSize int -} - -func (self *ConcurrentTester) SetBatchSize(batchSize int) { - self.batchSize = batchSize - log.Printf("Now configured to test %d packages concurrently.\n", self.batchSize) -} - -func (self *ConcurrentTester) TestAll(folders []*contract.Package) { - if self.batchSize == 1 { - self.executeSynchronously(folders) - } else { - newConcurrentCoordinator(folders, self.batchSize, self.shell).ExecuteConcurrently() - } - return -} - -func (self *ConcurrentTester) executeSynchronously(folders []*contract.Package) { - for _, folder := range folders { - packageName := strings.Replace(folder.Name, "\\", "/", -1) - if !folder.Active() { - log.Printf("Skipping execution: %s\n", packageName) - continue - } - if folder.HasImportCycle { - message := fmt.Sprintf("can't load package: import cycle not allowed\npackage %s\n\timports %s", packageName, packageName) - log.Println(message) - folder.Output, folder.Error = message, errors.New(message) - } else { - log.Printf("Executing tests: %s\n", packageName) - folder.Output, folder.Error = self.shell.GoTest(folder.Path, packageName, folder.BuildTags, folder.TestArguments) - } - } -} - -func NewConcurrentTester(shell contract.Shell) *ConcurrentTester { - self := new(ConcurrentTester) - self.shell = shell - self.batchSize = defaultBatchSize - return self -} - -const defaultBatchSize = 10 diff --git a/vendor/github.com/smartystreets/goconvey/web/server/messaging/messages.go b/vendor/github.com/smartystreets/goconvey/web/server/messaging/messages.go deleted file mode 100644 index 7a920911..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/messaging/messages.go +++ /dev/null @@ -1,56 +0,0 @@ -package messaging - -/////////////////////////////////////////////////////////////////////////////// - -type WatcherCommand struct { - Instruction WatcherInstruction - Details string -} - -type WatcherInstruction int - -func (this WatcherInstruction) String() string { - switch this { - case WatcherPause: - return "Pause" - case WatcherResume: - return "Resume" - case WatcherIgnore: - return "Ignore" - case WatcherReinstate: - return "Reinstate" - case WatcherAdjustRoot: - return "AdjustRoot" - case WatcherExecute: - return "Execute" - case WatcherStop: - return "Stop" - default: - return "UNKNOWN INSTRUCTION" - } -} - -const ( - WatcherPause WatcherInstruction = iota - WatcherResume - WatcherIgnore - WatcherReinstate - WatcherAdjustRoot - WatcherExecute - WatcherStop -) - -/////////////////////////////////////////////////////////////////////////////// - -type Folders map[string]*Folder - -type Folder struct { - Path string // key - Root string - Ignored bool - Disabled bool - BuildTags []string - TestArguments []string -} - -/////////////////////////////////////////////////////////////////////////////// diff --git a/vendor/github.com/smartystreets/goconvey/web/server/parser/packageParser.go b/vendor/github.com/smartystreets/goconvey/web/server/parser/packageParser.go deleted file mode 100644 index 406cc68c..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/parser/packageParser.go +++ /dev/null @@ -1,178 +0,0 @@ -package parser - -import ( - "fmt" - "regexp" - "sort" - "strconv" - "strings" - - "github.com/smartystreets/goconvey/web/server/contract" -) - -var ( - testNamePattern = regexp.MustCompile("^=== RUN:? +(.+)$") -) - -func ParsePackageResults(result *contract.PackageResult, rawOutput string) { - newOutputParser(result, rawOutput).parse() -} - -type outputParser struct { - raw string - lines []string - result *contract.PackageResult - tests []*contract.TestResult - - // place holders for loops - line string - test *contract.TestResult - testMap map[string]*contract.TestResult -} - -func newOutputParser(result *contract.PackageResult, rawOutput string) *outputParser { - self := new(outputParser) - self.raw = strings.TrimSpace(rawOutput) - self.lines = strings.Split(self.raw, "\n") - self.result = result - self.tests = []*contract.TestResult{} - self.testMap = make(map[string]*contract.TestResult) - return self -} - -func (self *outputParser) parse() { - self.separateTestFunctionsAndMetadata() - self.parseEachTestFunction() -} - -func (self *outputParser) separateTestFunctionsAndMetadata() { - for _, self.line = range self.lines { - if self.processNonTestOutput() { - break - } - self.processTestOutput() - } -} -func (self *outputParser) processNonTestOutput() bool { - if noGoFiles(self.line) { - self.recordFinalOutcome(contract.NoGoFiles) - - } else if buildFailed(self.line) { - self.recordFinalOutcome(contract.BuildFailure) - - } else if noTestFiles(self.line) { - self.recordFinalOutcome(contract.NoTestFiles) - - } else if noTestFunctions(self.line) { - self.recordFinalOutcome(contract.NoTestFunctions) - - } else { - return false - } - return true -} - -func (self *outputParser) recordFinalOutcome(outcome string) { - self.result.Outcome = outcome - self.result.BuildOutput = strings.Join(self.lines, "\n") -} - -func (self *outputParser) processTestOutput() { - self.line = strings.TrimSpace(self.line) - if isNewTest(self.line) { - self.registerTestFunction() - - } else if isTestResult(self.line) { - self.recordTestMetadata() - - } else if isPackageReport(self.line) { - self.recordPackageMetadata() - - } else { - self.saveLineForParsingLater() - - } -} - -func (self *outputParser) registerTestFunction() { - testNameReg := testNamePattern.FindStringSubmatch(self.line) - if len(testNameReg) < 2 { // Test-related lines that aren't about a new test - return - } - self.test = contract.NewTestResult(testNameReg[1]) - self.tests = append(self.tests, self.test) - self.testMap[self.test.TestName] = self.test -} -func (self *outputParser) recordTestMetadata() { - testName := strings.Split(self.line, " ")[2] - if test, ok := self.testMap[testName]; ok { - self.test = test - self.test.Passed = !strings.HasPrefix(self.line, "--- FAIL: ") - self.test.Skipped = strings.HasPrefix(self.line, "--- SKIP: ") - self.test.Elapsed = parseTestFunctionDuration(self.line) - } -} -func (self *outputParser) recordPackageMetadata() { - if packageFailed(self.line) { - self.recordTestingOutcome(contract.Failed) - - } else if packagePassed(self.line) { - self.recordTestingOutcome(contract.Passed) - - } else if isCoverageSummary(self.line) { - self.recordCoverageSummary(self.line) - } -} -func (self *outputParser) recordTestingOutcome(outcome string) { - self.result.Outcome = outcome - fields := strings.Split(self.line, "\t") - self.result.PackageName = strings.TrimSpace(fields[1]) - self.result.Elapsed = parseDurationInSeconds(fields[2], 3) -} -func (self *outputParser) recordCoverageSummary(summary string) { - start := len("coverage: ") - end := strings.Index(summary, "%") - value := summary[start:end] - parsed, err := strconv.ParseFloat(value, 64) - if err != nil { - self.result.Coverage = -1 - } else { - self.result.Coverage = parsed - } -} -func (self *outputParser) saveLineForParsingLater() { - self.line = strings.TrimLeft(self.line, "\t") - if self.test == nil { - fmt.Println("Potential error parsing output of", self.result.PackageName, "; couldn't handle this stray line:", self.line) - return - } - self.test.RawLines = append(self.test.RawLines, self.line) -} - -// TestResults is a collection of TestResults that implements sort.Interface. -type TestResults []contract.TestResult - -func (r TestResults) Len() int { - return len(r) -} - -// Less compares TestResults on TestName -func (r TestResults) Less(i, j int) bool { - return r[i].TestName < r[j].TestName -} - -func (r TestResults) Swap(i, j int) { - r[i], r[j] = r[j], r[i] -} - -func (self *outputParser) parseEachTestFunction() { - for _, self.test = range self.tests { - self.test = parseTestOutput(self.test) - if self.test.Error != "" { - self.result.Outcome = contract.Panicked - } - self.test.RawLines = []string{} - self.result.TestResults = append(self.result.TestResults, *self.test) - } - sort.Sort(TestResults(self.result.TestResults)) -} diff --git a/vendor/github.com/smartystreets/goconvey/web/server/parser/parser.go b/vendor/github.com/smartystreets/goconvey/web/server/parser/parser.go deleted file mode 100644 index f6250caf..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/parser/parser.go +++ /dev/null @@ -1,32 +0,0 @@ -package parser - -import ( - "log" - - "github.com/smartystreets/goconvey/web/server/contract" -) - -type Parser struct { - parser func(*contract.PackageResult, string) -} - -func (self *Parser) Parse(packages []*contract.Package) { - for _, p := range packages { - if p.Active() && p.HasUsableResult() { - self.parser(p.Result, p.Output) - } else if p.Ignored { - p.Result.Outcome = contract.Ignored - } else if p.Disabled { - p.Result.Outcome = contract.Disabled - } else { - p.Result.Outcome = contract.TestRunAbortedUnexpectedly - } - log.Printf("[%s]: %s\n", p.Result.Outcome, p.Name) - } -} - -func NewParser(helper func(*contract.PackageResult, string)) *Parser { - self := new(Parser) - self.parser = helper - return self -} diff --git a/vendor/github.com/smartystreets/goconvey/web/server/parser/parser.goconvey b/vendor/github.com/smartystreets/goconvey/web/server/parser/parser.goconvey deleted file mode 100644 index 79982854..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/parser/parser.goconvey +++ /dev/null @@ -1,2 +0,0 @@ -#ignore --timeout=1s diff --git a/vendor/github.com/smartystreets/goconvey/web/server/parser/rules.go b/vendor/github.com/smartystreets/goconvey/web/server/parser/rules.go deleted file mode 100644 index e632ec0e..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/parser/rules.go +++ /dev/null @@ -1,45 +0,0 @@ -package parser - -import "strings" - -func noGoFiles(line string) bool { - return strings.HasPrefix(line, "can't load package: ") && - (strings.Contains(line, ": no buildable Go source files in ") || - strings.Contains(line, ": no Go ") || - strings.Contains(line, "cannot find module providing package")) -} -func buildFailed(line string) bool { - return strings.HasPrefix(line, "# ") || - strings.Contains(line, "cannot find package") || - (strings.HasPrefix(line, "can't load package: ") && !strings.Contains(line, ": no Go ")) || - (strings.Contains(line, ": found packages ") && strings.Contains(line, ".go) and ") && strings.Contains(line, ".go) in ")) -} -func noTestFunctions(line string) bool { - return line == "testing: warning: no tests to run" -} -func noTestFiles(line string) bool { - return strings.HasPrefix(line, "?") && strings.Contains(line, "[no test files]") -} -func isNewTest(line string) bool { - return strings.HasPrefix(line, "=== ") -} -func isTestResult(line string) bool { - return strings.HasPrefix(line, "--- FAIL:") || strings.HasPrefix(line, "--- PASS:") || strings.HasPrefix(line, "--- SKIP:") -} -func isPackageReport(line string) bool { - return (strings.HasPrefix(line, "FAIL") || - strings.HasPrefix(line, "exit status") || - strings.HasPrefix(line, "PASS") || - isCoverageSummary(line) || - packagePassed(line)) -} - -func packageFailed(line string) bool { - return strings.HasPrefix(line, "FAIL\t") -} -func packagePassed(line string) bool { - return strings.HasPrefix(line, "ok \t") -} -func isCoverageSummary(line string) bool { - return strings.HasPrefix(line, "coverage: ") && strings.Contains(line, "% of statements") -} diff --git a/vendor/github.com/smartystreets/goconvey/web/server/parser/testParser.go b/vendor/github.com/smartystreets/goconvey/web/server/parser/testParser.go deleted file mode 100644 index 9fda9802..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/parser/testParser.go +++ /dev/null @@ -1,177 +0,0 @@ -package parser - -import ( - "encoding/json" - "fmt" - "strconv" - "strings" - - "github.com/smartystreets/goconvey/convey/reporting" - "github.com/smartystreets/goconvey/web/server/contract" -) - -type testParser struct { - test *contract.TestResult - line string - index int - inJson bool - jsonLines []string - otherLines []string -} - -func parseTestOutput(test *contract.TestResult) *contract.TestResult { - parser := newTestParser(test) - parser.parseTestFunctionOutput() - return test -} - -func newTestParser(test *contract.TestResult) *testParser { - self := new(testParser) - self.test = test - return self -} - -func (self *testParser) parseTestFunctionOutput() { - if len(self.test.RawLines) > 0 { - self.processLines() - self.deserializeJson() - self.composeCapturedOutput() - } -} - -func (self *testParser) processLines() { - for self.index, self.line = range self.test.RawLines { - if !self.processLine() { - break - } - } -} - -func (self *testParser) processLine() bool { - if strings.HasSuffix(self.line, reporting.OpenJson) { - self.inJson = true - self.accountForOutputWithoutNewline() - - } else if self.line == reporting.CloseJson { - self.inJson = false - - } else if self.inJson { - self.jsonLines = append(self.jsonLines, self.line) - - } else if isPanic(self.line) { - self.parsePanicOutput() - return false - - } else if isGoTestLogOutput(self.line) { - self.parseLogLocation() - - } else { - self.otherLines = append(self.otherLines, self.line) - } - return true -} - -// If fmt.Print(f) produces output with no \n and that output -// is that last output before the framework spits out json -// (which starts with ''>>>>>'') then without this code -// all of the json is counted as output, not as json to be -// parsed and displayed by the web UI. -func (self *testParser) accountForOutputWithoutNewline() { - prefix := strings.Split(self.line, reporting.OpenJson)[0] - if prefix != "" { - self.otherLines = append(self.otherLines, prefix) - } -} - -func (self *testParser) deserializeJson() { - formatted := createArrayForJsonItems(self.jsonLines) - var scopes []reporting.ScopeResult - err := json.Unmarshal(formatted, &scopes) - if err != nil { - panic(fmt.Sprintf(bugReportRequest, err, formatted)) - } - self.test.Stories = scopes -} -func (self *testParser) parsePanicOutput() { - for index, line := range self.test.RawLines[self.index:] { - self.parsePanicLocation(index, line) - self.preserveStackTraceIndentation(index, line) - } - self.test.Error = strings.Join(self.test.RawLines, "\n") -} -func (self *testParser) parsePanicLocation(index int, line string) { - if !panicLineHasMetadata(line) { - return - } - metaLine := self.test.RawLines[index+4] - fields := strings.Split(metaLine, " ") - fileAndLine := strings.Split(fields[0], ":") - self.test.File = fileAndLine[0] - if len(fileAndLine) >= 2 { - self.test.Line, _ = strconv.Atoi(fileAndLine[1]) - } -} -func (self *testParser) preserveStackTraceIndentation(index int, line string) { - if panicLineShouldBeIndented(index, line) { - self.test.RawLines[index] = "\t" + line - } -} -func (self *testParser) parseLogLocation() { - self.otherLines = append(self.otherLines, self.line) - lineFields := strings.TrimSpace(self.line) - if strings.HasPrefix(lineFields, "Error Trace:") { - lineFields = strings.TrimPrefix(lineFields, "Error Trace:") - } - fields := strings.Split(lineFields, ":") - self.test.File = strings.TrimSpace(fields[0]) - self.test.Line, _ = strconv.Atoi(fields[1]) -} - -func (self *testParser) composeCapturedOutput() { - self.test.Message = strings.Join(self.otherLines, "\n") -} - -func createArrayForJsonItems(lines []string) []byte { - jsonArrayItems := strings.Join(lines, "") - jsonArrayItems = removeTrailingComma(jsonArrayItems) - return []byte(fmt.Sprintf("[%s]\n", jsonArrayItems)) -} -func removeTrailingComma(rawJson string) string { - if trailingComma(rawJson) { - return rawJson[:len(rawJson)-1] - } - return rawJson -} -func trailingComma(value string) bool { - return strings.HasSuffix(value, ",") -} - -func isGoTestLogOutput(line string) bool { - return strings.Count(line, ":") == 2 -} - -func isPanic(line string) bool { - return strings.HasPrefix(line, "panic: ") -} - -func panicLineHasMetadata(line string) bool { - return strings.HasPrefix(line, "goroutine") && strings.Contains(line, "[running]") -} -func panicLineShouldBeIndented(index int, line string) bool { - return strings.Contains(line, "+") || (index > 0 && strings.Contains(line, "panic: ")) -} - -const bugReportRequest = ` -Uh-oh! Looks like something went wrong. Please copy the following text and file a bug report at: - -https://github.com/smartystreets/goconvey/issues?state=open - -======= BEGIN BUG REPORT ======= - -ERROR: %v - -OUTPUT: %s - -======= END BUG REPORT ======= - -` diff --git a/vendor/github.com/smartystreets/goconvey/web/server/parser/util.go b/vendor/github.com/smartystreets/goconvey/web/server/parser/util.go deleted file mode 100644 index 474bfa6d..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/parser/util.go +++ /dev/null @@ -1,49 +0,0 @@ -package parser - -import ( - "math" - "strings" - "time" -) - -// parseTestFunctionDuration parses the duration in seconds as a float64 -// from a line of go test output that looks something like this: -// --- PASS: TestOldSchool_PassesWithMessage (0.03 seconds) -func parseTestFunctionDuration(line string) float64 { - line = strings.Replace(line, "(", "", 1) - line = strings.Replace(line, ")", "", 1) - fields := strings.Split(line, " ") - return parseDurationInSeconds(fields[3], 2) -} - -func parseDurationInSeconds(raw string, precision int) float64 { - elapsed, err := time.ParseDuration(raw) - if err != nil { - elapsed, _ = time.ParseDuration(raw + "s") - } - return round(elapsed.Seconds(), precision) -} - -// round returns the rounded version of x with precision. -// -// Special cases are: -// round(±0) = ±0 -// round(±Inf) = ±Inf -// round(NaN) = NaN -// -// Why, oh why doesn't the math package come with a round function? -// Inspiration: http://play.golang.org/p/ZmFfr07oHp -func round(x float64, precision int) float64 { - var rounder float64 - pow := math.Pow(10, float64(precision)) - intermediate := x * pow - - if intermediate < 0.0 { - intermediate -= 0.5 - } else { - intermediate += 0.5 - } - rounder = float64(int64(intermediate)) - - return rounder / float64(pow) -} diff --git a/vendor/github.com/smartystreets/goconvey/web/server/system/shell.go b/vendor/github.com/smartystreets/goconvey/web/server/system/shell.go deleted file mode 100644 index 0adb8942..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/system/shell.go +++ /dev/null @@ -1,174 +0,0 @@ -package system - -import ( - "log" - "os/exec" - "path/filepath" - "regexp" - "strings" -) - -/////////////////////////////////////////////////////////////////////////////// -// Integration: /////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// - -type Shell struct { - coverage bool - gobin string - reportsPath string - defaultTimeout string -} - -func NewShell(gobin, reportsPath string, coverage bool, defaultTimeout string) *Shell { - return &Shell{ - coverage: coverage, - gobin: gobin, - reportsPath: reportsPath, - defaultTimeout: defaultTimeout, - } -} - -func (self *Shell) GoTest(directory, packageName string, tags, arguments []string) (output string, err error) { - reportFilename := strings.Replace(packageName, "/", "-", -1) - reportPath := filepath.Join(self.reportsPath, reportFilename) - reportData := reportPath + ".txt" - reportHTML := reportPath + ".html" - tagsArg := "-tags=" + strings.Join(tags, ",") - - goconvey := findGoConvey(directory, self.gobin, packageName, tagsArg).Execute() - compilation := compile(directory, self.gobin, tagsArg).Execute() - withCoverage := runWithCoverage(compilation, goconvey, self.coverage, reportData, directory, self.gobin, self.defaultTimeout, tagsArg, arguments).Execute() - final := runWithoutCoverage(compilation, withCoverage, goconvey, directory, self.gobin, self.defaultTimeout, tagsArg, arguments).Execute() - go generateReports(final, self.coverage, directory, self.gobin, reportData, reportHTML).Execute() - - return final.Output, final.Error -} - -/////////////////////////////////////////////////////////////////////////////// -// Functional Core://////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// - -func findGoConvey(directory, gobin, packageName, tagsArg string) Command { - return NewCommand(directory, gobin, "list", "-f", "'{{.TestImports}}{{.XTestImports}}'", tagsArg, packageName) -} - -func compile(directory, gobin, tagsArg string) Command { - return NewCommand(directory, gobin, "test", "-i", tagsArg) -} - -func runWithCoverage(compile, goconvey Command, coverage bool, reportPath, directory, gobin, defaultTimeout, tagsArg string, customArguments []string) Command { - if compile.Error != nil || goconvey.Error != nil { - return compile - } - - if !coverage { - return compile - } - - arguments := []string{"test", "-v", "-coverprofile=" + reportPath, tagsArg} - - customArgsText := strings.Join(customArguments, "\t") - if !strings.Contains(customArgsText, "-covermode=") { - arguments = append(arguments, "-covermode=set") - } - - if !strings.Contains(customArgsText, "-timeout=") { - arguments = append(arguments, "-timeout="+defaultTimeout) - } - - if strings.Contains(goconvey.Output, goconveyDSLImport) { - arguments = append(arguments, "-convey-json") - } - - arguments = append(arguments, customArguments...) - - return NewCommand(directory, gobin, arguments...) -} - -func runWithoutCoverage(compile, withCoverage, goconvey Command, directory, gobin, defaultTimeout, tagsArg string, customArguments []string) Command { - if compile.Error != nil { - return compile - } - - if goconvey.Error != nil { - log.Println(gopathProblem, goconvey.Output, goconvey.Error) - return goconvey - } - - if coverageStatementRE.MatchString(withCoverage.Output) { - return withCoverage - } - - log.Printf("Coverage output: %v", withCoverage.Output) - - log.Print("Run without coverage") - - arguments := []string{"test", "-v", tagsArg} - customArgsText := strings.Join(customArguments, "\t") - if !strings.Contains(customArgsText, "-timeout=") { - arguments = append(arguments, "-timeout="+defaultTimeout) - } - - if strings.Contains(goconvey.Output, goconveyDSLImport) { - arguments = append(arguments, "-convey-json") - } - arguments = append(arguments, customArguments...) - return NewCommand(directory, gobin, arguments...) -} - -func generateReports(previous Command, coverage bool, directory, gobin, reportData, reportHTML string) Command { - if previous.Error != nil { - return previous - } - - if !coverage { - return previous - } - - return NewCommand(directory, gobin, "tool", "cover", "-html="+reportData, "-o", reportHTML) -} - -/////////////////////////////////////////////////////////////////////////////// -// Imperative Shell: ////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// - -type Command struct { - directory string - executable string - arguments []string - - Output string - Error error -} - -func NewCommand(directory, executable string, arguments ...string) Command { - return Command{ - directory: directory, - executable: executable, - arguments: arguments, - } -} - -func (this Command) Execute() Command { - if len(this.executable) == 0 { - return this - } - - if len(this.Output) > 0 || this.Error != nil { - return this - } - - command := exec.Command(this.executable, this.arguments...) - command.Dir = this.directory - var rawOutput []byte - rawOutput, this.Error = command.CombinedOutput() - this.Output = string(rawOutput) - return this -} - -/////////////////////////////////////////////////////////////////////////////// - -const goconveyDSLImport = "github.com/smartystreets/goconvey/convey " // note the trailing space: we don't want to target packages nested in the /convey package. -const gopathProblem = "Please run goconvey from within $GOPATH/src (also, symlinks might be problematic). Output and Error: " - -var coverageStatementRE = regexp.MustCompile(`(?m)^coverage: \d+\.\d% of statements(.*)$|^panic: test timed out after `) diff --git a/vendor/github.com/smartystreets/goconvey/web/server/system/system.goconvey b/vendor/github.com/smartystreets/goconvey/web/server/system/system.goconvey deleted file mode 100644 index aa26e8b7..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/system/system.goconvey +++ /dev/null @@ -1,3 +0,0 @@ -#ignore --timeout=1s --short
\ No newline at end of file diff --git a/vendor/github.com/smartystreets/goconvey/web/server/watch/functional_core.go b/vendor/github.com/smartystreets/goconvey/web/server/watch/functional_core.go deleted file mode 100644 index 404a25d3..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/watch/functional_core.go +++ /dev/null @@ -1,171 +0,0 @@ -package watch - -import ( - "os" - "path/filepath" - "strings" - - "github.com/smartystreets/goconvey/web/server/messaging" -) - -/////////////////////////////////////////////////////////////////////////////// - -func Categorize(items chan *FileSystemItem, root string, watchSuffixes []string) (folders, profiles, goFiles []*FileSystemItem) { - for item := range items { - if item.IsFolder && !isHidden(item.Name) && !foundInHiddenDirectory(item, root) { - folders = append(folders, item) - - } else if strings.HasSuffix(item.Name, ".goconvey") && len(item.Name) > len(".goconvey") { - profiles = append(profiles, item) - - } else { - for _, suffix := range watchSuffixes { - if strings.HasSuffix(item.Name, suffix) && !isHidden(item.Name) && !foundInHiddenDirectory(item, root) { - goFiles = append(goFiles, item) - } - } - } - } - return folders, profiles, goFiles -} - -func foundInHiddenDirectory(item *FileSystemItem, root string) bool { - path := item.Path - if len(path) > len(root) { - path = path[len(root):] - } - - for _, folder := range strings.Split(filepath.Dir(path), slash) { - if isHidden(folder) { - return true - } - } - - return false -} -func isHidden(path string) bool { - return strings.HasPrefix(path, ".") || strings.HasPrefix(path, "_") || strings.HasPrefix(path, "flymake_") -} - -/////////////////////////////////////////////////////////////////////////////// - -func ParseProfile(profile string) (isDisabled bool, tags, arguments []string) { - lines := strings.Split(profile, "\n") - - for _, line := range lines { - line = strings.TrimSpace(line) - - if len(arguments) == 0 && strings.ToLower(line) == "ignore" { - return true, nil, nil - - } else if strings.HasPrefix(line, "-tags=") { - tags = append(tags, strings.Split(strings.SplitN(line, "=", 2)[1], ",")...) - continue - - } else if len(line) == 0 { - continue - - } else if strings.HasPrefix(line, "#") { - continue - - } else if strings.HasPrefix(line, "//") { - continue - - } else if line == "-cover" || strings.HasPrefix(line, "-coverprofile") { - continue - - } else if line == "-v" { - continue // Verbose mode is always enabled so there is no need to record it here. - - } - - arguments = append(arguments, line) - } - - return false, tags, arguments -} - -/////////////////////////////////////////////////////////////////////////////// - -func CreateFolders(items []*FileSystemItem) messaging.Folders { - folders := map[string]*messaging.Folder{} - - for _, item := range items { - folders[item.Path] = &messaging.Folder{Path: item.Path, Root: item.Root} - } - - return folders -} - -/////////////////////////////////////////////////////////////////////////////// - -func LimitDepth(folders messaging.Folders, depth int) { - if depth < 0 { - return - } - - for path, folder := range folders { - if strings.Count(path[len(folder.Root):], slash) > depth { - delete(folders, path) - } - } -} - -/////////////////////////////////////////////////////////////////////////////// - -func AttachProfiles(folders messaging.Folders, items []*FileSystemItem) { - for _, profile := range items { - if folder, exists := folders[filepath.Dir(profile.Path)]; exists { - folder.Disabled, folder.BuildTags, folder.TestArguments = profile.ProfileDisabled, profile.ProfileTags, profile.ProfileArguments - } - } -} - -/////////////////////////////////////////////////////////////////////////////// - -func MarkIgnored(folders messaging.Folders, ignored map[string]struct{}) { - if len(ignored) == 0 { - return - } - - for _, folder := range folders { - for ignored := range ignored { - if !folder.Ignored && strings.HasSuffix(folder.Path, ignored) { - folder.Ignored = true - } - } - } -} - -/////////////////////////////////////////////////////////////////////////////// - -func ActiveFolders(folders messaging.Folders) messaging.Folders { - var active messaging.Folders = map[string]*messaging.Folder{} - - for path, folder := range folders { - if folder.Ignored || folder.Disabled { - continue - } - - active[path] = folder - } - return active -} - -/////////////////////////////////////////////////////////////////////////////// - -func Sum(folders messaging.Folders, items []*FileSystemItem) int64 { - var sum int64 - for _, item := range items { - if _, exists := folders[filepath.Dir(item.Path)]; exists { - sum += item.Size + item.Modified - } - } - return sum -} - -/////////////////////////////////////////////////////////////////////////////// - -const slash = string(os.PathSeparator) - -/////////////////////////////////////////////////////////////////////////////// diff --git a/vendor/github.com/smartystreets/goconvey/web/server/watch/imperative_shell.go b/vendor/github.com/smartystreets/goconvey/web/server/watch/imperative_shell.go deleted file mode 100644 index 9d9890d2..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/watch/imperative_shell.go +++ /dev/null @@ -1,82 +0,0 @@ -package watch - -import ( - "io" - "io/ioutil" - "os" - "path/filepath" - "strings" -) - -/////////////////////////////////////////////////////////////////////////////// - -type FileSystemItem struct { - Root string - Path string - Name string - Size int64 - Modified int64 - IsFolder bool - - ProfileDisabled bool - ProfileTags []string - ProfileArguments []string -} - -/////////////////////////////////////////////////////////////////////////////// - -func YieldFileSystemItems(root string, excludedDirs []string) chan *FileSystemItem { - items := make(chan *FileSystemItem) - - go func() { - filepath.Walk(root, func(path string, info os.FileInfo, err error) error { - if err != nil { - return filepath.SkipDir - } - - if info.IsDir() && strings.HasPrefix(info.Name(), ".") { - return filepath.SkipDir - } - - basePath := filepath.Base(path) - for _, item := range excludedDirs { - if item == basePath && info.IsDir() && item != "" && basePath != "" { - return filepath.SkipDir - } - } - - items <- &FileSystemItem{ - Root: root, - Path: path, - Name: info.Name(), - Size: info.Size(), - Modified: info.ModTime().Unix(), - IsFolder: info.IsDir(), - } - - return nil - }) - close(items) - }() - - return items -} - -/////////////////////////////////////////////////////////////////////////////// - -// ReadContents reads files wholesale. This function is only called on files -// that end in '.goconvey'. These files should be very small, probably not -// ever more than a few hundred bytes. The ignored errors are ok because in -// the event of an IO error all that need be returned is an empty string. -func ReadContents(path string) string { - file, err := os.Open(path) - if err != nil { - return "" - } - defer file.Close() - reader := io.LimitReader(file, 1024*4) - content, _ := ioutil.ReadAll(reader) - return string(content) -} - -/////////////////////////////////////////////////////////////////////////////// diff --git a/vendor/github.com/smartystreets/goconvey/web/server/watch/integration.go b/vendor/github.com/smartystreets/goconvey/web/server/watch/integration.go deleted file mode 100644 index 9827c043..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/watch/integration.go +++ /dev/null @@ -1,183 +0,0 @@ -package watch - -import ( - "log" - "os" - "strings" - "sync" - "time" - - "github.com/smartystreets/goconvey/web/server/messaging" -) - -type Watcher struct { - nap time.Duration - rootFolder string - folderDepth int - ignoredFolders map[string]struct{} - fileSystemState int64 - paused bool - stopped bool - watchSuffixes []string - excludedDirs []string - - input chan messaging.WatcherCommand - output chan messaging.Folders - - lock sync.RWMutex -} - -func NewWatcher(rootFolder string, folderDepth int, nap time.Duration, - input chan messaging.WatcherCommand, output chan messaging.Folders, watchSuffixes string, excludedDirs []string) *Watcher { - - return &Watcher{ - nap: nap, - rootFolder: rootFolder, - folderDepth: folderDepth, - input: input, - output: output, - watchSuffixes: strings.Split(watchSuffixes, ","), - excludedDirs: excludedDirs, - - ignoredFolders: make(map[string]struct{}), - } -} - -func (this *Watcher) Listen() { - for { - if this.stopped { - return - } - - select { - - case command := <-this.input: - this.respond(command) - - default: - if !this.paused { - this.scan() - } - time.Sleep(this.nap) - } - } -} - -func (this *Watcher) respond(command messaging.WatcherCommand) { - switch command.Instruction { - - case messaging.WatcherAdjustRoot: - log.Println("Adjusting root...") - this.rootFolder = command.Details - this.execute() - - case messaging.WatcherIgnore: - log.Println("Ignoring specified folders") - this.ignore(command.Details) - // Prevent a filesystem change due to the number of active folders changing - _, checksum := this.gather() - this.set(checksum) - - case messaging.WatcherReinstate: - log.Println("Reinstating specified folders") - this.reinstate(command.Details) - // Prevent a filesystem change due to the number of active folders changing - _, checksum := this.gather() - this.set(checksum) - - case messaging.WatcherPause: - log.Println("Pausing watcher...") - this.paused = true - - case messaging.WatcherResume: - log.Println("Resuming watcher...") - this.paused = false - - case messaging.WatcherExecute: - log.Println("Gathering folders for immediate execution...") - this.execute() - - case messaging.WatcherStop: - log.Println("Stopping the watcher...") - close(this.output) - this.stopped = true - - default: - log.Println("Unrecognized command from server:", command.Instruction) - } -} - -func (this *Watcher) execute() { - folders, _ := this.gather() - this.sendToExecutor(folders) -} - -func (this *Watcher) scan() { - folders, checksum := this.gather() - - if checksum == this.fileSystemState { - return - } - - log.Println("File system state modified, publishing current folders...", this.fileSystemState, checksum) - - defer this.set(checksum) - this.sendToExecutor(folders) -} - -func (this *Watcher) gather() (folders messaging.Folders, checksum int64) { - items := YieldFileSystemItems(this.rootFolder, this.excludedDirs) - folderItems, profileItems, goFileItems := Categorize(items, this.rootFolder, this.watchSuffixes) - - for _, item := range profileItems { - // TODO: don't even bother if the item's size is over a few hundred bytes... - contents := ReadContents(item.Path) - item.ProfileDisabled, item.ProfileTags, item.ProfileArguments = ParseProfile(contents) - } - - folders = CreateFolders(folderItems) - LimitDepth(folders, this.folderDepth) - AttachProfiles(folders, profileItems) - this.protectedRead(func() { MarkIgnored(folders, this.ignoredFolders) }) - - active := ActiveFolders(folders) - checksum = int64(len(active)) - checksum += Sum(active, profileItems) - checksum += Sum(active, goFileItems) - - return folders, checksum -} - -func (this *Watcher) set(state int64) { - this.fileSystemState = state -} - -func (this *Watcher) sendToExecutor(folders messaging.Folders) { - this.output <- folders -} - -func (this *Watcher) ignore(paths string) { - this.protectedWrite(func() { - for _, folder := range strings.Split(paths, string(os.PathListSeparator)) { - this.ignoredFolders[folder] = struct{}{} - log.Println("Currently ignored folders:", this.ignoredFolders) - } - }) -} -func (this *Watcher) reinstate(paths string) { - this.protectedWrite(func() { - for _, folder := range strings.Split(paths, string(os.PathListSeparator)) { - delete(this.ignoredFolders, folder) - } - }) -} -func (this *Watcher) protectedWrite(protected func()) { - this.lock.Lock() - defer this.lock.Unlock() - protected() -} -func (this *Watcher) protectedRead(protected func()) { - this.lock.RLock() - defer this.lock.RUnlock() - protected() -} diff --git a/vendor/github.com/smartystreets/goconvey/web/server/watch/watch.goconvey b/vendor/github.com/smartystreets/goconvey/web/server/watch/watch.goconvey deleted file mode 100644 index aa26e8b7..00000000 --- a/vendor/github.com/smartystreets/goconvey/web/server/watch/watch.goconvey +++ /dev/null @@ -1,3 +0,0 @@ -#ignore --timeout=1s --short
\ No newline at end of file |