How to use ShuffledCopy method of internal Package

Best Ginkgo code snippet using internal.ShuffledCopy

Run Ginkgo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

testsuite_test.go

Source: testsuite_test.go Github

copy
1package internal_test
2
3import (
4	"os"
5	"path/filepath"
6
7	. "github.com/onsi/ginkgo/v2"
8	. "github.com/onsi/ginkgo/v2/ginkgo/internal"
9	"github.com/onsi/ginkgo/v2/types"
10	. "github.com/onsi/gomega"
11)
12
13func TS(path string, pkgName string, isGinkgo bool, state TestSuiteState) TestSuite {
14	return TestSuite{
15		Path:        path,
16		PackageName: pkgName,
17		IsGinkgo:    isGinkgo,
18		Precompiled: false,
19		State:       state,
20	}
21}
22
23func PTS(path string, pkgName string, isGinkgo bool, pathToCompiledTest string, state TestSuiteState) TestSuite {
24	return TestSuite{
25		Path:               path,
26		PackageName:        pkgName,
27		IsGinkgo:           isGinkgo,
28		Precompiled:        true,
29		PathToCompiledTest: pathToCompiledTest,
30		State:              state,
31	}
32}
33
34var _ = Describe("TestSuite", func() {
35	Describe("Finding Suites", func() {
36		var tmpDir string
37		var origWd string
38		var cliConf types.CLIConfig
39
40		writeFile := func(folder string, filename string, content string, mode os.FileMode) {
41			path := filepath.Join(tmpDir, folder)
42			err := os.MkdirAll(path, 0700)
43			Ω(err).ShouldNot(HaveOccurred())
44
45			path = filepath.Join(path, filename)
46			os.WriteFile(path, []byte(content), mode)
47		}
48
49		BeforeEach(func() {
50			cliConf = types.CLIConfig{}
51
52			var err error
53			tmpDir, err = os.MkdirTemp("/tmp", "ginkgo")
54			Ω(err).ShouldNot(HaveOccurred())
55
56			origWd, err = os.Getwd()
57			Ω(err).ShouldNot(HaveOccurred())
58			Ω(os.Chdir(tmpDir)).Should(Succeed())
59
60			//go files in the root directory (no tests)
61			writeFile("/", "main.go", "package main", 0666)
62
63			//non-go files in a nested directory
64			writeFile("/redherring", "big_test.jpg", "package ginkgo", 0666)
65
66			//ginkgo tests in ignored go files
67			writeFile("/ignored", ".ignore_dot_test.go", `import "github.com/onsi/ginkgo/v2"`, 0666)
68			writeFile("/ignored", "_ignore_underscore_test.go", `import "github.com/onsi/ginkgo/v2"`, 0666)
69
70			//non-ginkgo tests in a nested directory
71			writeFile("/professorplum", "professorplum_test.go", `import "testing"`, 0666)
72
73			//ginkgo tests in a nested directory
74			writeFile("/colonelmustard", "colonelmustard_test.go", `import "github.com/onsi/ginkgo/v2"`, 0666)
75
76			//ginkgo tests in a deeply nested directory
77			writeFile("/colonelmustard/library", "library_test.go", `import "github.com/onsi/ginkgo/v2"`, 0666)
78
79			//ginkgo tests in a deeply nested directory
80			writeFile("/colonelmustard/library/spanner", "spanner_test.go", `import "github.com/onsi/ginkgo/v2/dsl/core"`, 0666)
81
82			//ginkgo tests deeply nested in a vendored dependency
83			writeFile("/vendor/mrspeacock/lounge", "lounge_test.go", `import "github.com/onsi/ginkgo/v2"`, 0666)
84
85			//a precompiled ginkgo test
86			writeFile("/precompiled-dir", "precompiled.test", `fake-binary-file`, 0777)
87			writeFile("/precompiled-dir", "some-other-binary", `fake-binary-file`, 0777)
88			writeFile("/precompiled-dir", "windows.test.exe", `fake-binary-file`, 0666)
89			writeFile("/precompiled-dir", "windows.exe", `fake-binary-file`, 0666)
90			writeFile("/precompiled-dir", "nonexecutable.test", `fake-binary-file`, 0666)
91		})
92
93		AfterEach(func() {
94			Ω(os.Chdir(origWd)).Should(Succeed())
95			os.RemoveAll(tmpDir)
96		})
97
98		Context("when passed no args", func() {
99			Context("when told to recurse", func() {
100				BeforeEach(func() {
101					cliConf.Recurse = true
102				})
103
104				It("recurses through the current directory, returning all identified tests and skipping vendored, ignored, and precompiled tests", func() {
105					suites := FindSuites([]string{}, cliConf, false)
106					Ω(suites).Should(ConsistOf(
107						TS("./professorplum", "professorplum", false, TestSuiteStateUncompiled),
108						TS("./colonelmustard", "colonelmustard", true, TestSuiteStateUncompiled),
109						TS("./colonelmustard/library", "library", true, TestSuiteStateUncompiled),
110						TS("./colonelmustard/library/spanner", "spanner", true, TestSuiteStateUncompiled),
111					))
112				})
113			})
114
115			Context("when told to recurse and there is a skip-package filter", func() {
116				BeforeEach(func() {
117					cliConf.Recurse = true
118					cliConf.SkipPackage = "professorplum,library,floop"
119				})
120
121				It("recurses through the current directory, returning all identified tests and skipping vendored, ignored, and precompiled tests", func() {
122					suites := FindSuites([]string{}, cliConf, false)
123					Ω(suites).Should(ConsistOf(
124						TS("./professorplum", "professorplum", false, TestSuiteStateSkippedByFilter),
125						TS("./colonelmustard", "colonelmustard", true, TestSuiteStateUncompiled),
126						TS("./colonelmustard/library", "library", true, TestSuiteStateSkippedByFilter),
127						TS("./colonelmustard/library/spanner", "spanner", true, TestSuiteStateSkippedByFilter),
128					))
129				})
130			})
131
132			Context("when there are no tests in the current directory", func() {
133				BeforeEach(func() {
134					cliConf.Recurse = false
135				})
136
137				It("returns empty", func() {
138					suites := FindSuites([]string{}, cliConf, false)
139					Ω(suites).Should(BeEmpty())
140				})
141			})
142
143			Context("when told not to recurse", func() {
144				BeforeEach(func() {
145					Ω(os.Chdir("./colonelmustard")).Should(Succeed())
146				})
147
148				It("returns tests in the current directory if present", func() {
149					suites := FindSuites([]string{}, cliConf, false)
150					Ω(suites).Should(ConsistOf(
151						TS(".", "colonelmustard", true, TestSuiteStateUncompiled),
152					))
153				})
154			})
155		})
156
157		Context("when passed args", func() {
158			Context("when told to recurse", func() {
159				BeforeEach(func() {
160					cliConf.Recurse = true
161				})
162
163				It("recurses through the passed-in directories, returning all identified tests and skipping vendored, ignored, and precompiled tests", func() {
164					suites := FindSuites([]string{"precompiled-dir", "colonelmustard"}, cliConf, false)
165					Ω(suites).Should(ConsistOf(
166						TS("./colonelmustard", "colonelmustard", true, TestSuiteStateUncompiled),
167						TS("./colonelmustard/library", "library", true, TestSuiteStateUncompiled),
168						TS("./colonelmustard/library/spanner", "spanner", true, TestSuiteStateUncompiled),
169					))
170				})
171			})
172
173			Context("when told to recurse and there is a skip-package filter", func() {
174				BeforeEach(func() {
175					cliConf.Recurse = true
176					cliConf.SkipPackage = "library"
177				})
178
179				It("recurses through the passed-in directories, returning all identified tests and skipping vendored, ignored, and precompiled tests", func() {
180					suites := FindSuites([]string{"precompiled-dir", "professorplum", "colonelmustard"}, cliConf, false)
181					Ω(suites).Should(ConsistOf(
182						TS("./professorplum", "professorplum", false, TestSuiteStateUncompiled),
183						TS("./colonelmustard", "colonelmustard", true, TestSuiteStateUncompiled),
184						TS("./colonelmustard/library", "library", true, TestSuiteStateSkippedByFilter),
185						TS("./colonelmustard/library/spanner", "spanner", true, TestSuiteStateSkippedByFilter),
186					))
187				})
188			})
189
190			Context("when told not to recurse", func() {
191				BeforeEach(func() {
192					cliConf.Recurse = false
193				})
194
195				It("returns test packages at the passed in arguments", func() {
196					suites := FindSuites([]string{"precompiled-dir", "colonelmustard", "professorplum", "ignored"}, cliConf, false)
197					Ω(suites).Should(ConsistOf(
198						TS("./professorplum", "professorplum", false, TestSuiteStateUncompiled),
199						TS("./colonelmustard", "colonelmustard", true, TestSuiteStateUncompiled),
200					))
201				})
202			})
203
204			Context("when told not to recurse, but an arg has /...", func() {
205				BeforeEach(func() {
206					cliConf.Recurse = false
207				})
208
209				It("recurses through the directories it is told to recurse through, returning all identified tests and skipping vendored, ignored, and precompiled tests", func() {
210					suites := FindSuites([]string{"precompiled-dir", "colonelmustard/...", "professorplum/...", "ignored/..."}, cliConf, false)
211					Ω(suites).Should(ConsistOf(
212						TS("./professorplum", "professorplum", false, TestSuiteStateUncompiled),
213						TS("./colonelmustard", "colonelmustard", true, TestSuiteStateUncompiled),
214						TS("./colonelmustard/library", "library", true, TestSuiteStateUncompiled),
215						TS("./colonelmustard/library/spanner", "spanner", true, TestSuiteStateUncompiled),
216					))
217				})
218			})
219
220			Context("when told not to recurse and there is a skip-package filter", func() {
221				BeforeEach(func() {
222					cliConf.Recurse = false
223					cliConf.SkipPackage = "library,plum"
224				})
225
226				It("returns skips packages that match", func() {
227					suites := FindSuites([]string{"colonelmustard", "professorplum", "colonelmustard/library"}, cliConf, false)
228					Ω(suites).Should(ConsistOf(
229						TS("./professorplum", "professorplum", false, TestSuiteStateSkippedByFilter),
230						TS("./colonelmustard", "colonelmustard", true, TestSuiteStateUncompiled),
231						TS("./colonelmustard/library", "library", true, TestSuiteStateSkippedByFilter),
232					))
233				})
234			})
235
236			Context("when pointed at a directory containing a precompiled test suite", func() {
237				It("returns nothing", func() {
238					suites := FindSuites([]string{"precompiled-dir"}, cliConf, false)
239					Ω(suites).Should(BeEmpty())
240				})
241			})
242
243			Context("when pointed at a precompiled test suite specifically", func() {
244				It("returns the precompiled suite", func() {
245					path, err := filepath.Abs("./precompiled-dir/precompiled.test")
246					Ω(err).ShouldNot(HaveOccurred())
247					suites := FindSuites([]string{"precompiled-dir/precompiled.test"}, cliConf, true)
248					Ω(suites).Should(ConsistOf(
249						PTS("./precompiled-dir", "precompiled", true, path, TestSuiteStateCompiled),
250					))
251				})
252			})
253
254			Context("when pointed at a precompiled test suite on windows", func() {
255				It("returns the precompiled suite", func() {
256					path, err := filepath.Abs("./precompiled-dir/windows.exe")
257					Ω(err).ShouldNot(HaveOccurred())
258					suites := FindSuites([]string{"precompiled-dir/windows.exe"}, cliConf, true)
259					Ω(suites).Should(ConsistOf(
260						PTS("./precompiled-dir", "windows", true, path, TestSuiteStateCompiled),
261					))
262
263					path, err = filepath.Abs("./precompiled-dir/windows.test.exe")
264					Ω(err).ShouldNot(HaveOccurred())
265					suites = FindSuites([]string{"precompiled-dir/windows.test.exe"}, cliConf, true)
266					Ω(suites).Should(ConsistOf(
267						PTS("./precompiled-dir", "windows", true, path, TestSuiteStateCompiled),
268					))
269				})
270			})
271
272			Context("when pointed at a fake precompiled test", func() {
273				It("returns nothing", func() {
274					suites := FindSuites([]string{"precompiled-dir/some-other-binary"}, cliConf, true)
275					Ω(suites).Should(BeEmpty())
276
277					suites = FindSuites([]string{"precompiled-dir/nonexecutable.test"}, cliConf, true)
278					Ω(suites).Should(BeEmpty())
279				})
280			})
281
282			Context("when pointed at a precompiled test suite specifically but allowPrecompiled is false", func() {
283				It("returns nothing", func() {
284					suites := FindSuites([]string{"precompiled-dir/some-other-binary"}, cliConf, false)
285					Ω(suites).Should(BeEmpty())
286				})
287			})
288		})
289	})
290
291	Describe("NamespacedName", func() {
292		It("generates a name basd on the relative path to the package", func() {
293			plum := TS("./professorplum", "professorplum", false, TestSuiteStateUncompiled)
294			library := TS("./colonelmustard/library", "library", true, TestSuiteStateUncompiled)
295			root := TS(".", "root", true, TestSuiteStateUncompiled)
296
297			Ω(plum.NamespacedName()).Should(Equal("professorplum"))
298			Ω(library.NamespacedName()).Should(Equal("colonelmustard_library"))
299			Ω(root.NamespacedName()).Should(Equal("root"))
300		})
301	})
302
303	Describe("TestSuiteState", func() {
304		Describe("Is", func() {
305			It("returns true if it matches one of the passed in states", func() {
306				Ω(TestSuiteStateCompiled.Is(TestSuiteStateUncompiled, TestSuiteStateCompiled)).Should(BeTrue())
307				Ω(TestSuiteStateCompiled.Is(TestSuiteStateUncompiled, TestSuiteStatePassed)).Should(BeFalse())
308			})
309		})
310
311		Describe("TestSuiteStateFailureStates", func() {
312			It("should enumerate the failure states", func() {
313				Ω(TestSuiteStateFailureStates).Should(ConsistOf(
314					TestSuiteStateFailed,
315					TestSuiteStateFailedDueToTimeout,
316					TestSuiteStateFailedToCompile,
317				))
318			})
319		})
320	})
321
322	Describe("TestSuites", func() {
323		var A, B, C, D TestSuite
324		var suites TestSuites
325		BeforeEach(func() {
326			A = TS("/A", "A", true, TestSuiteStateUncompiled)
327			B = TS("/B", "B", true, TestSuiteStateUncompiled)
328			C = TS("/C", "C", true, TestSuiteStateUncompiled)
329			D = TS("/D", "D", true, TestSuiteStateUncompiled)
330		})
331
332		JustBeforeEach(func() {
333			suites = TestSuites{A, B, C, D}
334		})
335
336		Describe("AnyHaveProgrammaticFocus", func() {
337			Context("when any suites have programmatic focus", func() {
338				BeforeEach(func() {
339					B.HasProgrammaticFocus = true
340				})
341
342				It("returns true", func() {
343					Ω(suites.AnyHaveProgrammaticFocus()).Should(BeTrue())
344				})
345			})
346			Context("when any suites do not have programmatic focus", func() {
347				It("returns false", func() {
348					Ω(suites.AnyHaveProgrammaticFocus()).Should(BeFalse())
349				})
350			})
351		})
352
353		Describe("ThatAreGinkgoSuites", func() {
354			BeforeEach(func() {
355				B.IsGinkgo = false
356				D.IsGinkgo = false
357			})
358			It("returns the subset that are Ginkgo suites", func() {
359				Ω(suites.ThatAreGinkgoSuites()).Should(Equal(TestSuites{A, C}))
360			})
361		})
362
363		Describe("CountWithState", func() {
364			BeforeEach(func() {
365				B.State = TestSuiteStateFailed
366				D.State = TestSuiteStateFailedToCompile
367			})
368
369			It("returns the number with the matching state", func() {
370				Ω(suites.CountWithState(TestSuiteStateFailed)).Should(Equal(1))
371				Ω(suites.CountWithState(TestSuiteStateFailed, TestSuiteStateFailedToCompile)).Should(Equal(2))
372			})
373		})
374
375		Describe("WithState", func() {
376			BeforeEach(func() {
377				A.State = TestSuiteStatePassed
378				C.State = TestSuiteStateSkippedByFilter
379			})
380
381			It("returns the suites matching the passed-in states", func() {
382				Ω(suites.WithState(TestSuiteStatePassed, TestSuiteStateSkippedByFilter)).Should(Equal(TestSuites{A, C}))
383			})
384		})
385
386		Describe("WithoutState", func() {
387			BeforeEach(func() {
388				A.State = TestSuiteStatePassed
389				C.State = TestSuiteStateSkippedByFilter
390			})
391
392			It("returns the suites _not_ matching the passed-in states", func() {
393				Ω(suites.WithoutState(TestSuiteStatePassed, TestSuiteStateSkippedByFilter)).Should(Equal(TestSuites{B, D}))
394			})
395		})
396
397		Describe("ShuffledCopy", func() {
398			It("returns a shuffled copy of the test suites", func() {
399				shuffled := suites.ShuffledCopy(17)
400				Ω(suites).Should(Equal(TestSuites{A, B, C, D}))
401				Ω(shuffled).Should(ConsistOf(A, B, C, D))
402				Ω(shuffled).ShouldNot(Equal(suites))
403			})
404		})
405	})
406})
407
Full Screen

run_command.go

Source: run_command.go Github

copy
1package run
2
3import (
4	"fmt"
5	"os"
6	"strings"
7	"time"
8
9	"github.com/onsi/ginkgo/v2/formatter"
10	"github.com/onsi/ginkgo/v2/ginkgo/command"
11	"github.com/onsi/ginkgo/v2/ginkgo/internal"
12	"github.com/onsi/ginkgo/v2/internal/interrupt_handler"
13	"github.com/onsi/ginkgo/v2/types"
14)
15
16func BuildRunCommand() command.Command {
17	var suiteConfig = types.NewDefaultSuiteConfig()
18	var reporterConfig = types.NewDefaultReporterConfig()
19	var cliConfig = types.NewDefaultCLIConfig()
20	var goFlagsConfig = types.NewDefaultGoFlagsConfig()
21
22	flags, err := types.BuildRunCommandFlagSet(&suiteConfig, &reporterConfig, &cliConfig, &goFlagsConfig)
23	if err != nil {
24		panic(err)
25	}
26
27	interruptHandler := interrupt_handler.NewInterruptHandler(0, nil)
28	interrupt_handler.SwallowSigQuit()
29
30	return command.Command{
31		Name:          "run",
32		Flags:         flags,
33		Usage:         "ginkgo run <FLAGS> <PACKAGES> -- <PASS-THROUGHS>",
34		ShortDoc:      "Run the tests in the passed in <PACKAGES> (or the package in the current directory if left blank)",
35		Documentation: "Any arguments after -- will be passed to the test.",
36		DocLink:       "running-tests",
37		Command: func(args []string, additionalArgs []string) {
38			var errors []error
39			cliConfig, goFlagsConfig, errors = types.VetAndInitializeCLIAndGoConfig(cliConfig, goFlagsConfig)
40			command.AbortIfErrors("Ginkgo detected configuration issues:", errors)
41
42			runner := &SpecRunner{
43				cliConfig:      cliConfig,
44				goFlagsConfig:  goFlagsConfig,
45				suiteConfig:    suiteConfig,
46				reporterConfig: reporterConfig,
47				flags:          flags,
48
49				interruptHandler: interruptHandler,
50			}
51
52			runner.RunSpecs(args, additionalArgs)
53		},
54	}
55}
56
57type SpecRunner struct {
58	suiteConfig    types.SuiteConfig
59	reporterConfig types.ReporterConfig
60	cliConfig      types.CLIConfig
61	goFlagsConfig  types.GoFlagsConfig
62	flags          types.GinkgoFlagSet
63
64	interruptHandler *interrupt_handler.InterruptHandler
65}
66
67func (r *SpecRunner) RunSpecs(args []string, additionalArgs []string) {
68	suites := internal.FindSuites(args, r.cliConfig, true)
69	skippedSuites := suites.WithState(internal.TestSuiteStateSkippedByFilter)
70	suites = suites.WithoutState(internal.TestSuiteStateSkippedByFilter)
71
72	if len(skippedSuites) > 0 {
73		fmt.Println("Will skip:")
74		for _, skippedSuite := range skippedSuites {
75			fmt.Println("  " + skippedSuite.Path)
76		}
77	}
78
79	if len(skippedSuites) > 0 && len(suites) == 0 {
80		command.AbortGracefullyWith("All tests skipped! Exiting...")
81	}
82
83	if len(suites) == 0 {
84		command.AbortWith("Found no test suites")
85	}
86
87	if len(suites) > 1 && !r.flags.WasSet("succinct") && r.reporterConfig.Verbosity().LT(types.VerbosityLevelVerbose) {
88		r.reporterConfig.Succinct = true
89	}
90
91	t := time.Now()
92	var endTime time.Time
93	if r.suiteConfig.Timeout > 0 {
94		endTime = t.Add(r.suiteConfig.Timeout)
95	}
96
97	iteration := 0
98OUTER_LOOP:
99	for {
100		if !r.flags.WasSet("seed") {
101			r.suiteConfig.RandomSeed = time.Now().Unix()
102		}
103		if r.cliConfig.RandomizeSuites && len(suites) > 1 {
104			suites = suites.ShuffledCopy(r.suiteConfig.RandomSeed)
105		}
106
107		opc := internal.NewOrderedParallelCompiler(r.cliConfig.ComputedNumCompilers())
108		opc.StartCompiling(suites, r.goFlagsConfig)
109
110	SUITE_LOOP:
111		for {
112			suiteIdx, suite := opc.Next()
113			if suiteIdx >= len(suites) {
114				break SUITE_LOOP
115			}
116			suites[suiteIdx] = suite
117
118			if r.interruptHandler.Status().Interrupted {
119				opc.StopAndDrain()
120				break OUTER_LOOP
121			}
122
123			if suites[suiteIdx].State.Is(internal.TestSuiteStateSkippedDueToEmptyCompilation) {
124				fmt.Printf("Skipping %s (no test files)\n", suite.Path)
125				continue SUITE_LOOP
126			}
127
128			if suites[suiteIdx].State.Is(internal.TestSuiteStateFailedToCompile) {
129				fmt.Println(suites[suiteIdx].CompilationError.Error())
130				if !r.cliConfig.KeepGoing {
131					opc.StopAndDrain()
132				}
133				continue SUITE_LOOP
134			}
135
136			if suites.CountWithState(internal.TestSuiteStateFailureStates...) > 0 && !r.cliConfig.KeepGoing {
137				suites[suiteIdx].State = internal.TestSuiteStateSkippedDueToPriorFailures
138				opc.StopAndDrain()
139				continue SUITE_LOOP
140			}
141
142			if !endTime.IsZero() {
143				r.suiteConfig.Timeout = endTime.Sub(time.Now())
144				if r.suiteConfig.Timeout <= 0 {
145					suites[suiteIdx].State = internal.TestSuiteStateFailedDueToTimeout
146					opc.StopAndDrain()
147					continue SUITE_LOOP
148				}
149			}
150
151			suites[suiteIdx] = internal.RunCompiledSuite(suites[suiteIdx], r.suiteConfig, r.reporterConfig, r.cliConfig, r.goFlagsConfig, additionalArgs)
152		}
153
154		if suites.CountWithState(internal.TestSuiteStateFailureStates...) > 0 {
155			if iteration > 0 {
156				fmt.Printf("\nTests failed on attempt #%d\n\n", iteration+1)
157			}
158			break OUTER_LOOP
159		}
160
161		if r.cliConfig.UntilItFails {
162			fmt.Printf("\nAll tests passed...\nWill keep running them until they fail.\nThis was attempt #%d\n%s\n", iteration+1, orcMessage(iteration+1))
163		} else if r.cliConfig.Repeat > 0 && iteration < r.cliConfig.Repeat {
164			fmt.Printf("\nAll tests passed...\nThis was attempt %d of %d.\n", iteration+1, r.cliConfig.Repeat+1)
165		} else {
166			break OUTER_LOOP
167		}
168		iteration += 1
169	}
170
171	internal.Cleanup(r.goFlagsConfig, suites...)
172
173	messages, err := internal.FinalizeProfilesAndReportsForSuites(suites, r.cliConfig, r.suiteConfig, r.reporterConfig, r.goFlagsConfig)
174	command.AbortIfError("could not finalize profiles:", err)
175	for _, message := range messages {
176		fmt.Println(message)
177	}
178
179	fmt.Printf("\nGinkgo ran %d %s in %s\n", len(suites), internal.PluralizedWord("suite", "suites", len(suites)), time.Since(t))
180
181	if suites.CountWithState(internal.TestSuiteStateFailureStates...) == 0 {
182		if suites.AnyHaveProgrammaticFocus() && strings.TrimSpace(os.Getenv("GINKGO_EDITOR_INTEGRATION")) == "" {
183			fmt.Printf("Test Suite Passed\n")
184			fmt.Printf("Detected Programmatic Focus - setting exit status to %d\n", types.GINKGO_FOCUS_EXIT_CODE)
185			command.Abort(command.AbortDetails{ExitCode: types.GINKGO_FOCUS_EXIT_CODE})
186		} else {
187			fmt.Printf("Test Suite Passed\n")
188			command.Abort(command.AbortDetails{})
189		}
190	} else {
191		fmt.Fprintln(formatter.ColorableStdOut, "")
192		if len(suites) > 1 && suites.CountWithState(internal.TestSuiteStateFailureStates...) > 0 {
193			fmt.Fprintln(formatter.ColorableStdOut,
194				internal.FailedSuitesReport(suites, formatter.NewWithNoColorBool(r.reporterConfig.NoColor)))
195		}
196		fmt.Printf("Test Suite Failed\n")
197		command.Abort(command.AbortDetails{ExitCode: 1})
198	}
199}
200
201func orcMessage(iteration int) string {
202	if iteration < 10 {
203		return ""
204	} else if iteration < 30 {
205		return []string{
206			"If at first you succeed...",
207			"...try, try again.",
208			"Looking good!",
209			"Still good...",
210			"I think your tests are fine....",
211			"Yep, still passing",
212			"Oh boy, here I go testin' again!",
213			"Even the gophers are getting bored",
214			"Did you try -race?",
215			"Maybe you should stop now?",
216			"I'm getting tired...",
217			"What if I just made you a sandwich?",
218			"Hit ^C, hit ^C, please hit ^C",
219			"Make it stop. Please!",
220			"Come on!  Enough is enough!",
221			"Dave, this conversation can serve no purpose anymore. Goodbye.",
222			"Just what do you think you're doing, Dave? ",
223			"I, Sisyphus",
224			"Insanity: doing the same thing over and over again and expecting different results. -Einstein",
225			"I guess Einstein never tried to churn butter",
226		}[iteration-10] + "\n"
227	} else {
228		return "No, seriously... you can probably stop now.\n"
229	}
230}
231
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Most used method in

Trigger ShuffledCopy code on LambdaTest Cloud Grid

Execute automation tests with ShuffledCopy on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)