Skip to content

Commit

Permalink
Set minimum Go version to 1.16
Browse files Browse the repository at this point in the history
This also selects stable versions for go.mod dependencies.

Unfortunately, the gopherjs dependency is an indirect dependency
of gls, which supports gopherjs specifically for the purpose of
allowing GoConvey to work with gopherjs applications.
  • Loading branch information
riannucci committed Oct 26, 2021
1 parent e098f86 commit 6f7d522
Show file tree
Hide file tree
Showing 11 changed files with 651 additions and 181 deletions.
6 changes: 5 additions & 1 deletion README.md
Expand Up @@ -7,12 +7,16 @@ GoConvey is awesome Go testing

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)**

GoConvey supports the current versions of Go (see the official Go
[release policy](https://golang.org/doc/devel/release#policy)). Currently
this means Go 1.16 and Go 1.17 are supported.

**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+)
- Shows test coverage
- Readable, colorized console output (understandable by any manager, IT or not)
- Test code generator
- Desktop notifications (optional)
Expand Down
4 changes: 0 additions & 4 deletions dependencies.go

This file was deleted.

7 changes: 4 additions & 3 deletions go.mod
@@ -1,8 +1,9 @@
module github.com/smartystreets/goconvey

go 1.16

require (
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
github.com/gopherjs/gopherjs v0.0.0-20211023200351-1e6abe791855 // 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
github.com/smartystreets/assertions v1.2.0
)
572 changes: 569 additions & 3 deletions go.sum

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions goconvey.go
Expand Up @@ -316,3 +316,54 @@ const (
separator = string(filepath.Separator)
endGoPath = separator + "src" + separator
)

// 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 {
return false
// 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 {
return ""

// 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]
}
42 changes: 0 additions & 42 deletions goconvey_1_8.go

This file was deleted.

64 changes: 0 additions & 64 deletions goconvey_1_9.go

This file was deleted.

21 changes: 6 additions & 15 deletions web/server/system/shell.go
Expand Up @@ -36,9 +36,8 @@ func (self *Shell) GoTest(directory, packageName string, tags, arguments []strin
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()
withCoverage := runWithCoverage(goconvey, self.coverage, reportData, directory, self.gobin, self.defaultTimeout, tagsArg, arguments).Execute()
final := runWithoutCoverage(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
Expand All @@ -52,13 +51,9 @@ func findGoConvey(directory, gobin, packageName, tagsArg string) Command {
return NewCommand(directory, gobin, "list", "-f", "'{{.TestImports}}{{.XTestImports}}'", tagsArg, packageName)
}

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
func runWithCoverage(goconvey Command, coverage bool, reportPath, directory, gobin, defaultTimeout, tagsArg string, customArguments []string) Command {
if !coverage || goconvey.Error != nil {
return Command{}
}

arguments := []string{"test", "-v", "-coverprofile=" + reportPath, tagsArg}
Expand All @@ -81,11 +76,7 @@ func runWithCoverage(compile, goconvey Command, coverage bool, reportPath, direc
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
}

func runWithoutCoverage(withCoverage, goconvey Command, directory, gobin, defaultTimeout, tagsArg string, customArguments []string) Command {
if goconvey.Error != nil {
log.Println(gopathProblem, goconvey.Output, goconvey.Error)
return goconvey
Expand Down
10 changes: 0 additions & 10 deletions web/server/system/shell_1_16.go

This file was deleted.

7 changes: 0 additions & 7 deletions web/server/system/shell_older_than_1_16.go

This file was deleted.

48 changes: 16 additions & 32 deletions web/server/system/shell_test.go
Expand Up @@ -32,24 +32,16 @@ func TestShellCommandComposition(t *testing.T) {
)

Convey("When attempting to run tests with coverage flags", t, func() {
Convey("And buildSucceeded failed", func() {
result := runWithCoverage(buildFailed, goConvey, noCoverage, "", "", "", "", "-tags=", nil)

Convey("Then no action should be taken", func() {
So(result, ShouldResemble, buildFailed)
})
})

Convey("And coverage is not wanted", func() {
result := runWithCoverage(buildSucceeded, goConvey, noCoverage, "", "", "", "", "-tags=", nil)
result := runWithCoverage(goConvey, noCoverage, "", "", "", "", "-tags=", nil)

Convey("Then no action should be taken", func() {
So(result, ShouldResemble, buildSucceeded)
So(result, ShouldResemble, Command{})
})
})

Convey("And the package being tested usees the GoConvey DSL (`convey` package)", func() {
result := runWithCoverage(buildSucceeded, goConvey, yesCoverage, "reportsPath", "/directory", "go", "5s", "-tags=bob", []string{"-arg1", "-arg2"})
result := runWithCoverage(goConvey, yesCoverage, "reportsPath", "/directory", "go", "5s", "-tags=bob", []string{"-arg1", "-arg2"})

Convey("The returned command should be well formed (and include the -json flag)", func() {
So(result, ShouldResemble, Command{
Expand All @@ -61,7 +53,7 @@ func TestShellCommandComposition(t *testing.T) {
})

Convey("And the package being tested does NOT use the GoConvey DSL", func() {
result := runWithCoverage(buildSucceeded, noGoConvey, yesCoverage, "reportsPath", "/directory", "go", "1s", "-tags=bob", []string{"-arg1", "-arg2"})
result := runWithCoverage(noGoConvey, yesCoverage, "reportsPath", "/directory", "go", "1s", "-tags=bob", []string{"-arg1", "-arg2"})

Convey("The returned command should be well formed (and NOT include the -json flag)", func() {
So(result, ShouldResemble, Command{
Expand All @@ -73,15 +65,15 @@ func TestShellCommandComposition(t *testing.T) {
})

Convey("And the package being tested has been symlinked outside the $GOAPTH", func() {
result := runWithCoverage(buildSucceeded, errorGoConvey, yesCoverage, "reportsPath", "/directory", "go", "1s", "-tags=", nil)
result := runWithCoverage(errorGoConvey, yesCoverage, "reportsPath", "/directory", "go", "1s", "-tags=", nil)

Convey("The returned command should be the compilation command", func() {
So(result, ShouldResemble, buildSucceeded)
Convey("The returned command should be empty", func() {
So(result, ShouldResemble, Command{})
})
})

Convey("And the package being tested specifies an alternate covermode", func() {
result := runWithCoverage(buildSucceeded, noGoConvey, yesCoverage, "reportsPath", "/directory", "go", "1s", "-tags=", []string{"-covermode=atomic"})
result := runWithCoverage(noGoConvey, yesCoverage, "reportsPath", "/directory", "go", "1s", "-tags=", []string{"-covermode=atomic"})

Convey("The returned command should allow the alternate value", func() {
So(result, ShouldResemble, Command{
Expand All @@ -93,7 +85,7 @@ func TestShellCommandComposition(t *testing.T) {
})

Convey("And the package being tested specifies an alternate timeout", func() {
result := runWithCoverage(buildSucceeded, noGoConvey, yesCoverage, "reportsPath", "/directory", "go", "1s", "-tags=", []string{"-timeout=5s"})
result := runWithCoverage(noGoConvey, yesCoverage, "reportsPath", "/directory", "go", "1s", "-tags=", []string{"-timeout=5s"})

Convey("The returned command should allow the alternate value", func() {
So(result, ShouldResemble, Command{
Expand All @@ -108,47 +100,39 @@ func TestShellCommandComposition(t *testing.T) {

Convey("When attempting to run tests without the coverage flags", t, func() {
Convey("And tests already succeeded with coverage", func() {
result := runWithoutCoverage(buildSucceeded, coveragePassed, goConvey, "/directory", "go", "1s", "-tags=", []string{"-arg1", "-arg2"})
result := runWithoutCoverage(coveragePassed, goConvey, "/directory", "go", "1s", "-tags=", []string{"-arg1", "-arg2"})

Convey("Then no action should be taken", func() {
So(result, ShouldResemble, coveragePassed)
})
})

Convey("And tests already failed (legitimately) with coverage", func() {
result := runWithoutCoverage(buildSucceeded, coverageFailed, goConvey, "/directory", "go", "1s", "-tags=", []string{"-arg1", "-arg2"})
result := runWithoutCoverage(coverageFailed, goConvey, "/directory", "go", "1s", "-tags=", []string{"-arg1", "-arg2"})

Convey("Then no action should be taken", func() {
So(result, ShouldResemble, coverageFailed)
})
})

Convey("And tests already failed (timeout) with coverage", func() {
result := runWithoutCoverage(buildSucceeded, coverageFailedTimeout, goConvey, "/directory", "go", "1s", "-tags=", []string{"-arg1", "-arg2"})
result := runWithoutCoverage(coverageFailedTimeout, goConvey, "/directory", "go", "1s", "-tags=", []string{"-arg1", "-arg2"})

Convey("Then no action should be taken", func() {
So(result, ShouldResemble, coverageFailedTimeout)
})
})

Convey("And the build failed earlier", func() {
result := runWithoutCoverage(buildFailed, Command{}, goConvey, "/directory", "go", "1s", "-tags=", []string{"-arg1", "-arg2"})

Convey("Then no action should be taken", func() {
So(result, ShouldResemble, buildFailed)
})
})

Convey("And the goconvey dsl command failed (probably because of symlinks)", func() {
result := runWithoutCoverage(buildSucceeded, Command{}, errorGoConvey, "", "", "", "-tags=", nil)
result := runWithoutCoverage(Command{}, errorGoConvey, "", "", "", "-tags=", nil)

Convey("Then no action should be taken", func() {
So(result, ShouldResemble, errorGoConvey)
})
})

Convey("And the package being tested uses the GoConvey DSL (`convey` package)", func() {
result := runWithoutCoverage(buildSucceeded, buildSucceeded, goConvey, "/directory", "go", "1s", "-tags=", []string{"-arg1", "-arg2"})
result := runWithoutCoverage(buildSucceeded, goConvey, "/directory", "go", "1s", "-tags=", []string{"-arg1", "-arg2"})

Convey("Then the returned command should be well formed (and include the -json flag)", func() {
So(result, ShouldResemble, Command{
Expand All @@ -160,7 +144,7 @@ func TestShellCommandComposition(t *testing.T) {
})

Convey("And the package being tested does NOT use the GoConvey DSL", func() {
result := runWithoutCoverage(buildSucceeded, noCoveragePassed, noGoConvey, "/directory", "go", "1s", "-tags=", []string{"-arg1", "-arg2"})
result := runWithoutCoverage(noCoveragePassed, noGoConvey, "/directory", "go", "1s", "-tags=", []string{"-arg1", "-arg2"})

Convey("Then the returned command should be well formed (and NOT include the -json flag)", func() {
So(result, ShouldResemble, Command{
Expand All @@ -172,7 +156,7 @@ func TestShellCommandComposition(t *testing.T) {
})

Convey("And the package being tested specifies an alternate timeout", func() {
result := runWithoutCoverage(buildSucceeded, buildSucceeded, noGoConvey, "/directory", "go", "1s", "-tags=", []string{"-timeout=5s"})
result := runWithoutCoverage(buildSucceeded, noGoConvey, "/directory", "go", "1s", "-tags=", []string{"-timeout=5s"})

Convey("The returned command should allow the alternate value", func() {
So(result, ShouldResemble, Command{
Expand Down

0 comments on commit 6f7d522

Please sign in to comment.