Skip to content

Commit 56d2a29

Browse files
authored
Fix for Go 1.18 (#532)
1 parent b607941 commit 56d2a29

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

.github/workflows/test.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,26 @@ name: test
33
on: [push, pull_request]
44

55
jobs:
6+
mod:
7+
runs-on: ubuntu-latest
8+
name: Check modules
9+
steps:
10+
- uses: actions/setup-go@v2
11+
with:
12+
go-version: '1.17'
13+
- uses: actions/checkout@v3
14+
- run: go mod tidy && git diff --exit-code go.mod go.sum
615
build:
716
runs-on: ubuntu-latest
817
strategy:
918
matrix:
10-
version: [ '1.16', '1.17' ]
19+
version: [ '1.17', '1.18' ]
1120
name: Go ${{ matrix.version }}
1221
steps:
1322
- uses: actions/setup-go@v2
1423
with:
1524
go-version: ${{ matrix.version }}
16-
- uses: actions/checkout@v2
17-
- run: go mod tidy && git diff --exit-code go.mod go.sum
25+
- uses: actions/checkout@v3
1826
- run: go vet ./...
1927
- run: mv ./tools ./tools.go
2028
- run: go get github.com/onsi/ginkgo/v2/ginkgo

gexec/build.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ func CompileTest(packagePath string, args ...string) (compiledPath string, err e
8383
GetAndCompileTest is identical to CompileTest but `go get` the package before compiling tests.
8484
*/
8585
func GetAndCompileTest(packagePath string, args ...string) (compiledPath string, err error) {
86-
if err := getForTest(build.Default.GOPATH, packagePath, nil); err != nil {
86+
if err := getForTest(build.Default.GOPATH, packagePath, []string{"GO111MODULE=off"}); err != nil {
8787
return "", err
8888
}
8989

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

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

108-
return doCompileTest(build.Default.GOPATH, packagePath, env, args...)
108+
return doCompileTest(build.Default.GOPATH, packagePath, append(env, "GO111MODULE=off"), args...)
109109
}
110110

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

126-
return doCompileTest(gopath, packagePath, nil, args...)
126+
return doCompileTest(gopath, packagePath, []string{"GO111MODULE=off"}, args...)
127127
}
128128

129129
func isLocalPackage(packagePath string) bool {

gexec/build_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ var _ = Describe(".BuildIn", func() {
132132

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

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

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

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

225225
var _ = Describe(".CompiledTestIn", func() {
226-
const (
227-
target = "github.com/onsi/gomega/gexec/_fixture/firefly"
228-
)
226+
const target = "github.com/onsi/gomega/gexec/_fixture/firefly"
229227

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

256253
Context("a remote package", func() {
257-
const remotePackage = "github.com/onsi/ginkgo/v2/types"
254+
const remotePackage = "github.com/onsi/ginkgo/types"
258255

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

0 commit comments

Comments
 (0)