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 a stable version for smartystreets/assertions.
  • Loading branch information
riannucci committed Oct 26, 2021
1 parent e098f86 commit 3bb3368
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 179 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -2,4 +2,5 @@
Thumbs.db
examples/output.json
web/client/reports/
/.idea
/.idea
/goconvey
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.

4 changes: 3 additions & 1 deletion 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/jtolds/gls v4.20.0+incompatible
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d
github.com/smartystreets/assertions v1.2.0
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384
)
4 changes: 2 additions & 2 deletions go.sum
Expand Up @@ -2,8 +2,8 @@ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGa
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=
github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs=
github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
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=
Expand Down
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 3bb3368

Please sign in to comment.