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 2f317e5
Show file tree
Hide file tree
Showing 12 changed files with 661 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.

8 changes: 5 additions & 3 deletions go.mod
@@ -1,8 +1,10 @@
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
golang.org/x/tools v0.1.7
)
582 changes: 579 additions & 3 deletions go.sum

Large diffs are not rendered by default.

Binary file added goconvey
Binary file not shown.
50 changes: 50 additions & 0 deletions goconvey.go
Expand Up @@ -19,6 +19,8 @@ import (
"strings"
"time"

"golang.org/x/tools/go/packages"

"github.com/smartystreets/goconvey/web/server/api"
"github.com/smartystreets/goconvey/web/server/contract"
"github.com/smartystreets/goconvey/web/server/executor"
Expand Down Expand Up @@ -316,3 +318,51 @@ 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 {
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]
}
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.

0 comments on commit 2f317e5

Please sign in to comment.