Skip to content

Commit

Permalink
Merge branch 'master' into SoMsg
Browse files Browse the repository at this point in the history
  • Loading branch information
riannucci committed Apr 27, 2021
2 parents 63cc4ee + 5f060cc commit f724034
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 21 deletions.
18 changes: 7 additions & 11 deletions .travis.yml
@@ -1,17 +1,13 @@
arch:
- amd64
- ppc64le

language: go

go:
- 1.2.x
- 1.3.x
- 1.4.x
- 1.5.x
- 1.6.x
- 1.7.x
- 1.8.x
- 1.9.x
- 1.10.x
- 1.11.x
- 1.12.x
- 1.13.x
- 1.14.x
- 1.15.x
- master

install:
Expand Down
2 changes: 1 addition & 1 deletion convey/context.go
Expand Up @@ -169,7 +169,7 @@ func (ctx *context) SkipSo(stuff ...interface{}) {
ctx.assertionReport(reporting.NewSkipReport())
}

func (ctx *context) So(actual interface{}, assert assertion, expected ...interface{}) {
func (ctx *context) So(actual interface{}, assert Assertion, expected ...interface{}) {
if result := assert(actual, expected...); result == assertionSuccess {
ctx.assertionReport(reporting.NewSuccessReport())
} else {
Expand Down
10 changes: 5 additions & 5 deletions convey/doc.go
Expand Up @@ -23,8 +23,8 @@ type C interface {
SkipConvey(items ...interface{})
FocusConvey(items ...interface{})

So(actual interface{}, assert assertion, expected ...interface{})
SoMsg(msg string, actual interface{}, assert assertion, expected ...interface{})
So(actual interface{}, assert Assertion, expected ...interface{})
SoMsg(msg string, actual interface{}, assert Assertion, expected ...interface{})
SkipSo(stuff ...interface{})

Reset(action func())
Expand Down Expand Up @@ -105,11 +105,11 @@ func Reset(action func()) {

/////////////////////////////////// Assertions ///////////////////////////////////

// assertion is an alias for a function with a signature that the convey.So()
// 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
type Assertion func(actual interface{}, expected ...interface{}) string

const assertionSuccess = ""

Expand All @@ -122,7 +122,7 @@ const assertionSuccess = ""
// 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{}) {
func So(actual interface{}, assert Assertion, expected ...interface{}) {
mustGetCurrentContext().So(actual, assert, expected...)
}

Expand Down
9 changes: 9 additions & 0 deletions web/server/parser/packageParser.go
Expand Up @@ -50,6 +50,15 @@ func (self *outputParser) separateTestFunctionsAndMetadata() {
if self.processNonTestOutput() {
break
}
// Hack for results from ginkgo tests
lines := strings.Split(self.line, " --- ")
if len(lines) == 2 && len(strings.TrimSpace(lines[0])) > 0 && strings.HasPrefix(lines[1], "PASS") {
self.line = lines[0]
self.processTestOutput()
self.line = "--- " + lines[1]
self.processTestOutput()
continue
}
self.processTestOutput()
}
}
Expand Down
42 changes: 42 additions & 0 deletions web/server/parser/package_parser_test.go
Expand Up @@ -1068,3 +1068,45 @@ var expectedGolang17Subtests = contract.PackageResult{
},
},
}

const inputGinkgo_Passes = `
SUCCESS! -- 12 Passed | 0 Failed | 0 Pending | 0 Skipped --- PASS: TestModels (0.01s)
PASS
ok github.com/smartystreets/goconvey/webserver/examples 3.433s
`

var expectedGinkgo_Passes = contract.PackageResult{
PackageName: "github.com/smartystreets/goconvey/webserver/examples",
Elapsed: 3.433,
Outcome: contract.Passed,
}

func TestParsePackage_GinkgoWithSuccessOutput(t *testing.T) {
actual := &contract.PackageResult{PackageName: expectedGinkgo_Passes.PackageName}
ParsePackageResults(actual, inputGinkgo_Passes)
assertEqual(t, expectedGinkgo_Passes, *actual)
}

const inputGinkgo_Fails = `
Summarizing 1 Failure:
[Fail] main.go GetHostname [It] returns an error if systemInfo.hostname == nil
/Users/joeuser/go/src/github.com/smartystreets/goconvey/webserver/examples/main.go:141
Ran 33 of 33 Specs in 0.005 seconds
FAIL! -- 32 Passed | 1 Failed | 0 Pending | 0 Skipped --- FAIL: TestRoutes (0.01s)
FAIL
FAIL github.com/smartystreets/goconvey/webserver/examples 0.810s
`

var expectedGinkgo_Fails = contract.PackageResult{
PackageName: "github.com/smartystreets/goconvey/webserver/examples",
Elapsed: 0.810,
Outcome: contract.Failed,
}

func TestParsePackage_GinkgoWithFailureOutput(t *testing.T) {
actual := &contract.PackageResult{PackageName: expectedGinkgo_Fails.PackageName}
ParsePackageResults(actual, inputGinkgo_Fails)
assertEqual(t, expectedGinkgo_Fails, *actual)
}
4 changes: 0 additions & 4 deletions web/server/system/shell.go
Expand Up @@ -52,10 +52,6 @@ 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
Expand Down
7 changes: 7 additions & 0 deletions web/server/system/shell_1_16.go
@@ -0,0 +1,7 @@
// +build go1.16

package system

func compile(directory, gobin, tagsArg string) Command {
return NewCommand(directory, gobin, "test", tagsArg)
}
7 changes: 7 additions & 0 deletions web/server/system/shell_older_than_1_16.go
@@ -0,0 +1,7 @@
// +build !go1.16

package system

func compile(directory, gobin, tagsArg string) Command {
return NewCommand(directory, gobin, "test", "-i", tagsArg)
}

0 comments on commit f724034

Please sign in to comment.