@@ -14,29 +14,22 @@ import (
1414var packagePath = "./_fixture/firefly"
1515
1616var _ = Describe (".Build" , func () {
17- When ("there have been previous calls to CompileTest" , func () {
17+ It ("compiles the specified package" , func () {
18+ compiledPath , err := gexec .Build (packagePath )
19+ Expect (err ).ShouldNot (HaveOccurred ())
20+ Expect (compiledPath ).Should (BeAnExistingFile ())
21+ Expect (filepath .Base (compiledPath )).Should (MatchRegexp (`firefly(|.exe)$` ))
22+ })
23+
24+ Context ("and CleanupBuildArtifacts has been called" , func () {
1825 BeforeEach (func () {
19- _ , err := gexec .CompileTest (packagePath )
20- Expect (err ).ShouldNot (HaveOccurred ())
26+ gexec .CleanupBuildArtifacts ()
2127 })
2228
2329 It ("compiles the specified package" , func () {
24- compiledPath , err := gexec .Build (packagePath )
30+ fireflyPath , err := gexec .Build (packagePath )
2531 Expect (err ).ShouldNot (HaveOccurred ())
26- Expect (compiledPath ).Should (BeAnExistingFile ())
27- Expect (filepath .Base (compiledPath )).Should (MatchRegexp (`firefly(|.exe)$` ))
28- })
29-
30- Context ("and CleanupBuildArtifacts has been called" , func () {
31- BeforeEach (func () {
32- gexec .CleanupBuildArtifacts ()
33- })
34-
35- It ("compiles the specified package" , func () {
36- fireflyPath , err := gexec .Build (packagePath )
37- Expect (err ).ShouldNot (HaveOccurred ())
38- Expect (fireflyPath ).Should (BeAnExistingFile ())
39- })
32+ Expect (fireflyPath ).Should (BeAnExistingFile ())
4033 })
4134 })
4235
@@ -130,149 +123,6 @@ var _ = Describe(".BuildIn", func() {
130123 })
131124})
132125
133- var _ = Describe (".CompileTest" , func () {
134- Context ("a remote package" , Label ("network" ), func () {
135- const remotePackage = "github.com/onsi/ginkgo/types"
136-
137- It ("compiles the specified test package" , func () {
138- compiledPath , err := gexec .GetAndCompileTest (remotePackage )
139- Expect (err ).ShouldNot (HaveOccurred ())
140- Expect (compiledPath ).Should (BeAnExistingFile ())
141- })
142- })
143-
144- When ("there have been previous calls to CompileTest" , func () {
145- BeforeEach (func () {
146- _ , err := gexec .CompileTest (packagePath )
147- Expect (err ).ShouldNot (HaveOccurred ())
148- })
149-
150- It ("compiles the specified test package" , func () {
151- compiledPath , err := gexec .CompileTest (packagePath )
152- Expect (err ).ShouldNot (HaveOccurred ())
153- Expect (compiledPath ).Should (BeAnExistingFile ())
154- })
155-
156- Context ("and CleanupBuildArtifacts has been called" , func () {
157- BeforeEach (func () {
158- gexec .CleanupBuildArtifacts ()
159- })
160-
161- It ("compiles the specified test package" , func () {
162- fireflyTestPath , err := gexec .CompileTest (packagePath )
163- Expect (err ).ShouldNot (HaveOccurred ())
164- Expect (fireflyTestPath ).Should (BeAnExistingFile ())
165- })
166- })
167- })
168-
169- When ("there have been previous calls to Build" , func () {
170- BeforeEach (func () {
171- _ , err := gexec .Build (packagePath )
172- Expect (err ).ShouldNot (HaveOccurred ())
173- })
174-
175- It ("compiles the specified test package" , func () {
176- compiledPath , err := gexec .CompileTest (packagePath )
177- Expect (err ).ShouldNot (HaveOccurred ())
178- Expect (compiledPath ).Should (BeAnExistingFile ())
179- })
180-
181- Context ("and CleanupBuildArtifacts has been called" , func () {
182- BeforeEach (func () {
183- gexec .CleanupBuildArtifacts ()
184- })
185-
186- It ("compiles the specified test package" , func () {
187- fireflyTestPath , err := gexec .CompileTest (packagePath )
188- Expect (err ).ShouldNot (HaveOccurred ())
189- Expect (fireflyTestPath ).Should (BeAnExistingFile ())
190- })
191- })
192- })
193- })
194-
195- var _ = Describe (".CompileTestWithEnvironment" , func () {
196- var err error
197- env := []string {
198- "GOOS=linux" ,
199- "GOARCH=amd64" ,
200- }
201-
202- Context ("a remote package" , Label ("network" ), func () {
203- const remotePackage = "github.com/onsi/ginkgo/types"
204-
205- It ("compiles the specified test package with the specified env vars" , func () {
206- compiledPath , err := gexec .GetAndCompileTestWithEnvironment (remotePackage , env )
207- Expect (err ).ShouldNot (HaveOccurred ())
208- Expect (compiledPath ).Should (BeAnExistingFile ())
209- })
210- })
211-
212- It ("compiles the specified test package with the specified env vars" , func () {
213- compiledPath , err := gexec .CompileTestWithEnvironment (packagePath , env )
214- Expect (err ).ShouldNot (HaveOccurred ())
215- Expect (compiledPath ).Should (BeAnExistingFile ())
216- })
217-
218- It ("returns the environment to a good state" , func () {
219- _ , err = gexec .CompileTestWithEnvironment (packagePath , env )
220- Expect (err ).ShouldNot (HaveOccurred ())
221- Expect (os .Environ ()).ShouldNot (ContainElement ("GOOS=linux" ))
222- })
223- })
224-
225- var _ = Describe (".CompiledTestIn" , func () {
226- const target = "github.com/onsi/gomega/gexec/_fixture/firefly"
227-
228- var (
229- original string
230- gopath string
231- )
232-
233- BeforeEach (func () {
234- var err error
235- original = os .Getenv ("GOPATH" )
236- gopath , err = gutil .MkdirTemp ("" , "" )
237- Expect (err ).NotTo (HaveOccurred ())
238- Expect (os .Setenv ("GOPATH" , filepath .Join (os .TempDir (), "emptyFakeGopath" ))).To (Succeed ())
239- Expect (os .Environ ()).To (ContainElement (fmt .Sprintf ("GOPATH=%s" , filepath .Join (os .TempDir (), "emptyFakeGopath" ))))
240- })
241-
242- AfterEach (func () {
243- if original == "" {
244- Expect (os .Unsetenv ("GOPATH" )).To (Succeed ())
245- } else {
246- Expect (os .Setenv ("GOPATH" , original )).To (Succeed ())
247- }
248- if gopath != "" {
249- os .RemoveAll (gopath )
250- }
251- })
252-
253- Context ("a remote package" , Label ("network" ), func () {
254- const remotePackage = "github.com/onsi/ginkgo/types"
255-
256- It ("compiles the specified test package" , func () {
257- compiledPath , err := gexec .GetAndCompileTestIn (gopath , remotePackage )
258- Expect (err ).ShouldNot (HaveOccurred ())
259- Expect (compiledPath ).Should (BeAnExistingFile ())
260- })
261- })
262-
263- It ("appends the gopath env var" , func () {
264- compiledPath , err := gexec .CompileTestIn (gopath , target )
265- Expect (err ).NotTo (HaveOccurred ())
266- Expect (compiledPath ).Should (BeAnExistingFile ())
267- })
268-
269- It ("resets GOPATH to its original value" , func () {
270- _ , err := gexec .CompileTestIn (gopath , target )
271- Expect (err ).NotTo (HaveOccurred ())
272- Expect (os .Getenv ("GOPATH" )).To (Equal (filepath .Join (os .TempDir (), "emptyFakeGopath" )))
273- })
274- })
275-
276126func copyFile (source , directory , basename string ) {
277127 Expect (os .MkdirAll (directory , 0755 )).To (Succeed ())
278128 content , err := gutil .ReadFile (source )
0 commit comments