Skip to content

Commit

Permalink
Fix for Go 1.18 (#532)
Browse files Browse the repository at this point in the history
  • Loading branch information
BooleanCat authored Mar 25, 2022
1 parent b607941 commit 56d2a29
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,26 @@ name: test
on: [push, pull_request]

jobs:
mod:
runs-on: ubuntu-latest
name: Check modules
steps:
- uses: actions/setup-go@v2
with:
go-version: '1.17'
- uses: actions/checkout@v3
- run: go mod tidy && git diff --exit-code go.mod go.sum
build:
runs-on: ubuntu-latest
strategy:
matrix:
version: [ '1.16', '1.17' ]
version: [ '1.17', '1.18' ]
name: Go ${{ matrix.version }}
steps:
- uses: actions/setup-go@v2
with:
go-version: ${{ matrix.version }}
- uses: actions/checkout@v2
- run: go mod tidy && git diff --exit-code go.mod go.sum
- uses: actions/checkout@v3
- run: go vet ./...
- run: mv ./tools ./tools.go
- run: go get github.com/onsi/ginkgo/v2/ginkgo
Expand Down
12 changes: 6 additions & 6 deletions gexec/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ func CompileTest(packagePath string, args ...string) (compiledPath string, err e
GetAndCompileTest is identical to CompileTest but `go get` the package before compiling tests.
*/
func GetAndCompileTest(packagePath string, args ...string) (compiledPath string, err error) {
if err := getForTest(build.Default.GOPATH, packagePath, nil); err != nil {
if err := getForTest(build.Default.GOPATH, packagePath, []string{"GO111MODULE=off"}); err != nil {
return "", err
}

return doCompileTest(build.Default.GOPATH, packagePath, nil, args...)
return doCompileTest(build.Default.GOPATH, packagePath, []string{"GO111MODULE=off"}, args...)
}

/*
Expand All @@ -101,11 +101,11 @@ func CompileTestWithEnvironment(packagePath string, env []string, args ...string
GetAndCompileTestWithEnvironment is identical to GetAndCompileTest but allows you to specify env vars to be set at build time.
*/
func GetAndCompileTestWithEnvironment(packagePath string, env []string, args ...string) (compiledPath string, err error) {
if err := getForTest(build.Default.GOPATH, packagePath, env); err != nil {
if err := getForTest(build.Default.GOPATH, packagePath, append(env, "GO111MODULE=off")); err != nil {
return "", err
}

return doCompileTest(build.Default.GOPATH, packagePath, env, args...)
return doCompileTest(build.Default.GOPATH, packagePath, append(env, "GO111MODULE=off"), args...)
}

/*
Expand All @@ -119,11 +119,11 @@ func CompileTestIn(gopath string, packagePath string, args ...string) (compiledP
GetAndCompileTestIn is identical to GetAndCompileTest but allows you to specify a custom $GOPATH (the first argument).
*/
func GetAndCompileTestIn(gopath string, packagePath string, args ...string) (compiledPath string, err error) {
if err := getForTest(gopath, packagePath, nil); err != nil {
if err := getForTest(gopath, packagePath, []string{"GO111MODULE=off"}); err != nil {
return "", err
}

return doCompileTest(gopath, packagePath, nil, args...)
return doCompileTest(gopath, packagePath, []string{"GO111MODULE=off"}, args...)
}

func isLocalPackage(packagePath string) bool {
Expand Down
11 changes: 4 additions & 7 deletions gexec/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ var _ = Describe(".BuildIn", func() {

var _ = Describe(".CompileTest", func() {
Context("a remote package", func() {
const remotePackage = "github.com/onsi/ginkgo/v2/types"
const remotePackage = "github.com/onsi/ginkgo/types"

It("compiles the specified test package", func() {
compiledPath, err := gexec.GetAndCompileTest(remotePackage)
Expand Down Expand Up @@ -200,7 +200,7 @@ var _ = Describe(".CompileTestWithEnvironment", func() {
}

Context("a remote package", func() {
const remotePackage = "github.com/onsi/ginkgo/v2/types"
const remotePackage = "github.com/onsi/ginkgo/types"

It("compiles the specified test package with the specified env vars", func() {
compiledPath, err := gexec.GetAndCompileTestWithEnvironment(remotePackage, env)
Expand All @@ -223,9 +223,7 @@ var _ = Describe(".CompileTestWithEnvironment", func() {
})

var _ = Describe(".CompiledTestIn", func() {
const (
target = "github.com/onsi/gomega/gexec/_fixture/firefly"
)
const target = "github.com/onsi/gomega/gexec/_fixture/firefly"

var (
original string
Expand All @@ -237,7 +235,6 @@ var _ = Describe(".CompiledTestIn", func() {
original = os.Getenv("GOPATH")
gopath, err = gutil.MkdirTemp("", "")
Expect(err).NotTo(HaveOccurred())
copyFile(filepath.Join("_fixture", "firefly", "main.go"), filepath.Join(gopath, "src", target), "main.go")
Expect(os.Setenv("GOPATH", filepath.Join(os.TempDir(), "emptyFakeGopath"))).To(Succeed())
Expect(os.Environ()).To(ContainElement(fmt.Sprintf("GOPATH=%s", filepath.Join(os.TempDir(), "emptyFakeGopath"))))
})
Expand All @@ -254,7 +251,7 @@ var _ = Describe(".CompiledTestIn", func() {
})

Context("a remote package", func() {
const remotePackage = "github.com/onsi/ginkgo/v2/types"
const remotePackage = "github.com/onsi/ginkgo/types"

It("compiles the specified test package", func() {
compiledPath, err := gexec.GetAndCompileTestIn(gopath, remotePackage)
Expand Down

0 comments on commit 56d2a29

Please sign in to comment.