How to use StartCompiling method of internal Package

Best Ginkgo code snippet using internal.StartCompiling

Run Ginkgo automation tests on LambdaTest cloud grid

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

build_command.go

Source: build_command.go Github

copy
1package build
2
3import (
4	"fmt"
5
6	"github.com/onsi/ginkgo/v2/ginkgo/command"
7	"github.com/onsi/ginkgo/v2/ginkgo/internal"
8	"github.com/onsi/ginkgo/v2/types"
9)
10
11func BuildBuildCommand() command.Command {
12	var cliConfig = types.NewDefaultCLIConfig()
13	var goFlagsConfig = types.NewDefaultGoFlagsConfig()
14
15	flags, err := types.BuildBuildCommandFlagSet(&cliConfig, &goFlagsConfig)
16	if err != nil {
17		panic(err)
18	}
19
20	return command.Command{
21		Name:     "build",
22		Flags:    flags,
23		Usage:    "ginkgo build <FLAGS> <PACKAGES>",
24		ShortDoc: "Build the passed in <PACKAGES> (or the package in the current directory if left blank).",
25		DocLink:  "precompiling-suites",
26		Command: func(args []string, _ []string) {
27			var errors []error
28			cliConfig, goFlagsConfig, errors = types.VetAndInitializeCLIAndGoConfig(cliConfig, goFlagsConfig)
29			command.AbortIfErrors("Ginkgo detected configuration issues:", errors)
30
31			buildSpecs(args, cliConfig, goFlagsConfig)
32		},
33	}
34}
35
36func buildSpecs(args []string, cliConfig types.CLIConfig, goFlagsConfig types.GoFlagsConfig) {
37	suites := internal.FindSuites(args, cliConfig, false).WithoutState(internal.TestSuiteStateSkippedByFilter)
38	if len(suites) == 0 {
39		command.AbortWith("Found no test suites")
40	}
41
42	opc := internal.NewOrderedParallelCompiler(cliConfig.ComputedNumCompilers())
43	opc.StartCompiling(suites, goFlagsConfig)
44
45	for {
46		suiteIdx, suite := opc.Next()
47		if suiteIdx >= len(suites) {
48			break
49		}
50		suites[suiteIdx] = suite
51		if suite.State.Is(internal.TestSuiteStateFailedToCompile) {
52			fmt.Println(suite.CompilationError.Error())
53		} else {
54			fmt.Printf("Compiled %s.test\n", suite.PackageName)
55		}
56	}
57
58	if suites.CountWithState(internal.TestSuiteStateFailedToCompile) > 0 {
59		command.AbortWith("Failed to compile all tests")
60	}
61}
62
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 StartCompiling code on LambdaTest Cloud Grid

Execute automation tests with StartCompiling 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)