Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateFlagArgs(flags GinkgoFlags, bindings interface{}) ([]string, error)
- func GenerateGoTestCompileArgs(goFlagsConfig GoFlagsConfig, destination string, packageToBuild string) ([]string, error)
- func GenerateTestRunArgs(suiteConfig SuiteConfig, reporterConfig ReporterConfig, ...) ([]string, error)
- func PruneStack(fullStackTrace string, skip int) string
- func VetAndInitializeCLIAndGoConfig(cliConfig CLIConfig, goFlagsConfig GoFlagsConfig) (CLIConfig, GoFlagsConfig, []error)
- func VetConfig(flagSet GinkgoFlagSet, suiteConfig SuiteConfig, reporterConfig ReporterConfig) []error
- type CLIConfig
- type CodeLocation
- type DeprecatedSetupSummary
- type DeprecatedSpecFailure
- type DeprecatedSpecMeasurement
- type DeprecatedSpecSummary
- func (s DeprecatedSpecSummary) Failed() bool
- func (s DeprecatedSpecSummary) HasFailureState() bool
- func (s DeprecatedSpecSummary) Panicked() bool
- func (s DeprecatedSpecSummary) Passed() bool
- func (s DeprecatedSpecSummary) Pending() bool
- func (s DeprecatedSpecSummary) Skipped() bool
- func (s DeprecatedSpecSummary) TimedOut() bool
- type DeprecatedSuiteSummary
- type Deprecation
- type DeprecationTracker
- type Failure
- type FailureNodeContext
- type GinkgoError
- type GinkgoFlag
- type GinkgoFlagSection
- type GinkgoFlagSections
- type GinkgoFlagSet
- func BuildBuildCommandFlagSet(cliConfig *CLIConfig, goFlagsConfig *GoFlagsConfig) (GinkgoFlagSet, error)
- func BuildRunCommandFlagSet(suiteConfig *SuiteConfig, reporterConfig *ReporterConfig, cliConfig *CLIConfig, ...) (GinkgoFlagSet, error)
- func BuildTestSuiteFlagSet(suiteConfig *SuiteConfig, reporterConfig *ReporterConfig) (GinkgoFlagSet, error)
- func BuildWatchCommandFlagSet(suiteConfig *SuiteConfig, reporterConfig *ReporterConfig, cliConfig *CLIConfig, ...) (GinkgoFlagSet, error)
- func NewAttachedGinkgoFlagSet(flagSet *flag.FlagSet, flags GinkgoFlags, bindings interface{}, ...) (GinkgoFlagSet, error)
- func NewGinkgoFlagSet(flags GinkgoFlags, bindings interface{}, sections GinkgoFlagSections) (GinkgoFlagSet, error)
- type GinkgoFlags
- type GoFlagsConfig
- type NodeType
- type PreRunStats
- type Report
- type ReporterConfig
- type SetupSummary
- type SpecComponentType
- type SpecFailure
- type SpecMeasurement
- type SpecReport
- func (report SpecReport) CombinedOutput() string
- func (report SpecReport) Failed() bool
- func (report SpecReport) FailureLocation() CodeLocation
- func (report SpecReport) FailureMessage() string
- func (report SpecReport) FileName() string
- func (report SpecReport) FullText() string
- func (report SpecReport) LineNumber() int
- func (report SpecReport) MarshalJSON() ([]byte, error)
- type SpecReports
- type SpecState
- type SpecSummary
- type SuiteConfig
- type SuiteSummary
Constants ¶
const GINKGO_FOCUS_EXIT_CODE = 197
const VERSION = "2.1.1"
Variables ¶
var ( SpecComponentTypeInvalid = NodeTypeInvalid SpecComponentTypeContainer = NodeTypeContainer SpecComponentTypeIt = NodeTypeIt SpecComponentTypeBeforeEach = NodeTypeBeforeEach SpecComponentTypeJustBeforeEach = NodeTypeJustBeforeEach SpecComponentTypeAfterEach = NodeTypeAfterEach SpecComponentTypeJustAfterEach = NodeTypeJustAfterEach SpecComponentTypeBeforeSuite = NodeTypeBeforeSuite SpecComponentTypeSynchronizedBeforeSuite = NodeTypeSynchronizedBeforeSuite SpecComponentTypeAfterSuite = NodeTypeAfterSuite SpecComponentTypeSynchronizedAfterSuite = NodeTypeSynchronizedAfterSuite )
var Deprecations = deprecations{}
var FlagSections = GinkgoFlagSections{ {Key: "multiple-suites", Style: "{{dark-green}}", Heading: "Running Multiple Test Suites"}, {Key: "order", Style: "{{green}}", Heading: "Controlling Test Order"}, {Key: "parallel", Style: "{{yellow}}", Heading: "Controlling Test Parallelism"}, {Key: "low-level-parallel", Style: "{{yellow}}", Heading: "Controlling Test Parallelism", Description: "These are set by the Ginkgo CLI, {{red}}{{bold}}do not set them manually{{/}} via go test.\nUse ginkgo -p or ginkgo -nodes=N instead."}, {Key: "filter", Style: "{{cyan}}", Heading: "Filtering Tests"}, {Key: "failure", Style: "{{red}}", Heading: "Failure Handling"}, {Key: "output", Style: "{{magenta}}", Heading: "Controlling Output Formatting"}, {Key: "code-and-coverage-analysis", Style: "{{orange}}", Heading: "Code and Coverage Analysis"}, {Key: "performance-analysis", Style: "{{coral}}", Heading: "Performance Analysis"}, {Key: "debug", Style: "{{blue}}", Heading: "Debugging Tests"}, {Key: "watch", Style: "{{light-yellow}}", Heading: "Controlling Ginkgo Watch"}, {Key: "misc", Style: "{{light-gray}}", Heading: "Miscellaneous"}, {Key: "go-build", Style: "{{light-gray}}", Heading: "Go Build Flags", Succinct: true, Description: "These flags are inherited from go build. Run {{bold}}ginkgo help build{{/}} for more detailed flag documentation."}, }
Flags sections used by both the CLI and the Ginkgo test process
var GinkgoCLIRunAndWatchFlags = GinkgoFlags{
{KeyPath: "C.Nodes", Name: "nodes", SectionKey: "parallel", UsageDefaultValue: "1 (run in series)",
Usage: "The number of parallel test nodes to run."},
{KeyPath: "C.Parallel", Name: "p", SectionKey: "parallel",
Usage: "If set, ginkgo will run in parallel with an auto-detected number of nodes."},
{KeyPath: "C.AfterRunHook", Name: "after-run-hook", SectionKey: "misc", DeprecatedName: "afterSuiteHook", DeprecatedDocLink: "changed-command-line-flags",
Usage: "Command to run when a test suite completes."},
{KeyPath: "C.OutputDir", Name: "output-dir", SectionKey: "output", UsageArgument: "directory", DeprecatedName: "outputdir", DeprecatedDocLink: "improved-profiling-support",
Usage: "A location to place all generated profiles and reports."},
{KeyPath: "C.KeepSeparateCoverprofiles", Name: "keep-separate-coverprofiles", SectionKey: "code-and-coverage-analysis",
Usage: "If set, Ginkgo does not merge coverprofiles into one monolithic coverprofile. The coverprofiles will remain in their respective package directories or in -output-dir if set."},
{KeyPath: "C.KeepSeparateReports", Name: "keep-separate-reports", SectionKey: "output",
Usage: "If set, Ginkgo does not merge per-suite reports (e.g. -json-report) into one monolithic report for the entire testrun. The reports will remain in their respective package directories or in -output-dir if set."},
{KeyPath: "D.Stream", DeprecatedName: "stream", DeprecatedDocLink: "removed--stream"},
{KeyPath: "D.Notify", DeprecatedName: "notify", DeprecatedDocLink: "removed--notify"},
}
GinkgoCLIRunAndWatchFlags provides flags shared by the Ginkgo CLI's build and watch commands (but not run)
var GinkgoCLIRunFlags = GinkgoFlags{
{KeyPath: "C.KeepGoing", Name: "keep-going", SectionKey: "multiple-suites", DeprecatedName: "keepGoing", DeprecatedDocLink: "changed-command-line-flags",
Usage: "If set, failures from earlier test suites do not prevent later test suites from running."},
{KeyPath: "C.UntilItFails", Name: "until-it-fails", SectionKey: "debug", DeprecatedName: "untilItFails", DeprecatedDocLink: "changed-command-line-flags",
Usage: "If set, ginkgo will keep rerunning test suites until a failure occurs."},
{KeyPath: "C.Repeat", Name: "repeat", SectionKey: "debug", UsageArgument: "n", UsageDefaultValue: "0 - i.e. no repetition, run only once",
Usage: "The number of times to re-run a test-suite. Useful for debugging flaky tests. If set to N the suite will be run N+1 times and will be required to pass each time."},
{KeyPath: "C.RandomizeSuites", Name: "randomize-suites", SectionKey: "order", DeprecatedName: "randomizeSuites", DeprecatedDocLink: "changed-command-line-flags",
Usage: "If set, ginkgo will randomize the order in which test suites run."},
}
GinkgoCLIRunFlags provides flags for Ginkgo CLI's run command that aren't shared by any other commands
{KeyPath: "C.Recurse", Name: "r", SectionKey: "multiple-suites",
Usage: "If set, ginkgo finds and runs test suites under the current directory recursively."},
{KeyPath: "C.SkipPackage", Name: "skip-package", SectionKey: "multiple-suites", DeprecatedName: "skipPackage", DeprecatedDocLink: "changed-command-line-flags",
UsageArgument: "comma-separated list of packages",
Usage: "A comma-separated list of package names to be skipped. If any part of the package's path matches, that package is ignored."},
{KeyPath: "C.RequireSuite", Name: "require-suite", SectionKey: "failure", DeprecatedName: "requireSuite", DeprecatedDocLink: "changed-command-line-flags",
Usage: "If set, Ginkgo fails if there are ginkgo tests in a directory but no invocation of RunSpecs."},
{KeyPath: "C.NumCompilers", Name: "compilers", SectionKey: "multiple-suites", UsageDefaultValue: "0 (will autodetect)",
Usage: "When running multiple packages, the number of concurrent compilations to perform."},
}
GinkgoCLISharedFlags provides flags shared by the Ginkgo CLI's build, watch, and run commands
var GinkgoCLIWatchFlags = GinkgoFlags{
{KeyPath: "C.Depth", Name: "depth", SectionKey: "watch",
Usage: "Ginkgo will watch dependencies down to this depth in the dependency tree."},
{KeyPath: "C.WatchRegExp", Name: "watch-regexp", SectionKey: "watch", DeprecatedName: "watchRegExp", DeprecatedDocLink: "changed-command-line-flags",
UsageArgument: "Regular Expression",
UsageDefaultValue: `\.go$`,
Usage: "Only files matching this regular expression will be watched for changes."},
}
GinkgoCLIRunFlags provides flags for Ginkgo CLI's watch command that aren't shared by any other commands
var GinkgoErrors = ginkgoErrors{}
var GoBuildFlags = GinkgoFlags{
{KeyPath: "Go.Race", Name: "race", SectionKey: "code-and-coverage-analysis",
Usage: "enable data race detection. Supported only on linux/amd64, freebsd/amd64, darwin/amd64, windows/amd64, linux/ppc64le and linux/arm64 (only for 48-bit VMA)."},
{KeyPath: "Go.Vet", Name: "vet", UsageArgument: "list", SectionKey: "code-and-coverage-analysis",
Usage: `Configure the invocation of "go vet" during "go test" to use the comma-separated list of vet checks. If list is empty, "go test" runs "go vet" with a curated list of checks believed to be always worth addressing. If list is "off", "go test" does not run "go vet" at all. Available checks can be found by running 'go doc cmd/vet'`},
{KeyPath: "Go.Cover", Name: "cover", SectionKey: "code-and-coverage-analysis",
Usage: "Enable coverage analysis. Note that because coverage works by annotating the source code before compilation, compilation and test failures with coverage enabled may report line numbers that don't correspond to the original sources."},
{KeyPath: "Go.CoverMode", Name: "covermode", UsageArgument: "set,count,atomic", SectionKey: "code-and-coverage-analysis",
Usage: `Set the mode for coverage analysis for the package[s] being tested. 'set': does this statement run? 'count': how many times does this statement run? 'atomic': like count, but correct in multithreaded tests and more expensive (must use atomic with -race). Sets -cover`},
{KeyPath: "Go.CoverPkg", Name: "coverpkg", UsageArgument: "pattern1,pattern2,pattern3", SectionKey: "code-and-coverage-analysis",
Usage: "Apply coverage analysis in each test to packages matching the patterns. The default is for each test to analyze only the package being tested. See 'go help packages' for a description of package patterns. Sets -cover."},
{KeyPath: "Go.A", Name: "a", SectionKey: "go-build",
Usage: "force rebuilding of packages that are already up-to-date."},
{KeyPath: "Go.ASMFlags", Name: "asmflags", UsageArgument: "'[pattern=]arg list'", SectionKey: "go-build",
Usage: "arguments to pass on each go tool asm invocation."},
{KeyPath: "Go.BuildMode", Name: "buildmode", UsageArgument: "mode", SectionKey: "go-build",
Usage: "build mode to use. See 'go help buildmode' for more."},
{KeyPath: "Go.Compiler", Name: "compiler", UsageArgument: "name", SectionKey: "go-build",
Usage: "name of compiler to use, as in runtime.Compiler (gccgo or gc)."},
{KeyPath: "Go.GCCGoFlags", Name: "gccgoflags", UsageArgument: "'[pattern=]arg list'", SectionKey: "go-build",
Usage: "arguments to pass on each gccgo compiler/linker invocation."},
{KeyPath: "Go.GCFlags", Name: "gcflags", UsageArgument: "'[pattern=]arg list'", SectionKey: "go-build",
Usage: "arguments to pass on each go tool compile invocation."},
{KeyPath: "Go.InstallSuffix", Name: "installsuffix", SectionKey: "go-build",
Usage: "a suffix to use in the name of the package installation directory, in order to keep output separate from default builds. If using the -race flag, the install suffix is automatically set to raceor, if set explicitly, has _race appended to it. Likewise for the -msan flag. Using a -buildmode option that requires non-default compile flags has a similar effect."},
{KeyPath: "Go.LDFlags", Name: "ldflags", UsageArgument: "'[pattern=]arg list'", SectionKey: "go-build",
Usage: "arguments to pass on each go tool link invocation."},
{KeyPath: "Go.LinkShared", Name: "linkshared", SectionKey: "go-build",
Usage: "build code that will be linked against shared libraries previously created with -buildmode=shared."},
{KeyPath: "Go.Mod", Name: "mod", UsageArgument: "mode (readonly, vendor, or mod)", SectionKey: "go-build",
Usage: "module download mode to use: readonly, vendor, or mod. See 'go help modules' for more."},
{KeyPath: "Go.ModCacheRW", Name: "modcacherw", SectionKey: "go-build",
Usage: "leave newly-created directories in the module cache read-write instead of making them read-only."},
{KeyPath: "Go.ModFile", Name: "modfile", UsageArgument: "file", SectionKey: "go-build",
Usage: `in module aware mode, read (and possibly write) an alternate go.mod file instead of the one in the module root directory. A file named go.mod must still be present in order to determine the module root directory, but it is not accessed. When -modfile is specified, an alternate go.sum file is also used: its path is derived from the -modfile flag by trimming the ".mod" extension and appending ".sum".`},
{KeyPath: "Go.MSan", Name: "msan", SectionKey: "go-build",
Usage: "enable interoperation with memory sanitizer. Supported only on linux/amd64, linux/arm64 and only with Clang/LLVM as the host C compiler. On linux/arm64, pie build mode will be used."},
{KeyPath: "Go.N", Name: "n", SectionKey: "go-build",
Usage: "print the commands but do not run them."},
{KeyPath: "Go.PkgDir", Name: "pkgdir", UsageArgument: "dir", SectionKey: "go-build",
Usage: "install and load all packages from dir instead of the usual locations. For example, when building with a non-standard configuration, use -pkgdir to keep generated packages in a separate location."},
{KeyPath: "Go.Tags", Name: "tags", UsageArgument: "tag,list", SectionKey: "go-build",
Usage: "a comma-separated list of build tags to consider satisfied during the build. For more information about build tags, see the description of build constraints in the documentation for the go/build package. (Earlier versions of Go used a space-separated list, and that form is deprecated but still recognized.)"},
{KeyPath: "Go.TrimPath", Name: "trimpath", SectionKey: "go-build",
Usage: `remove all file system paths from the resulting executable. Instead of absolute file system paths, the recorded file names will begin with either "go" (for the standard library), or a module path@version (when using modules), or a plain import path (when using GOPATH).`},
{KeyPath: "Go.ToolExec", Name: "toolexec", UsageArgument: "'cmd args'", SectionKey: "go-build",
Usage: "a program to use to invoke toolchain programs like vet and asm. For example, instead of running asm, the go command will run cmd args /path/to/asm <arguments for asm>'."},
{KeyPath: "Go.Work", Name: "work", SectionKey: "go-build",
Usage: "print the name of the temporary work directory and do not delete it when exiting."},
{KeyPath: "Go.X", Name: "x", SectionKey: "go-build",
Usage: "print the commands."},
}
GoBuildFlags provides flags for the Ginkgo CLI build, run, and watch commands that capture go's build-time flags. These are passed to go test -c by the ginkgo CLI
var GoRunFlags = GinkgoFlags{
{KeyPath: "Go.CoverProfile", Name: "coverprofile", UsageArgument: "file", SectionKey: "code-and-coverage-analysis",
Usage: `Write a coverage profile to the file after all tests have passed. Sets -cover.`},
{KeyPath: "Go.BlockProfile", Name: "blockprofile", UsageArgument: "rile", SectionKey: "performance-analysis",
Usage: `Write a goroutine blocking profile to the specified file when all tests are complete. Preserves test binary.`},
{KeyPath: "Go.BlockProfileRate", Name: "blockprofilerate", UsageArgument: "rate", SectionKey: "performance-analysis",
Usage: `Control the detail provided in goroutine blocking profiles by calling runtime.SetBlockProfileRate with rate. See 'go doc runtime.SetBlockProfileRate'. The profiler aims to sample, on average, one blocking event every n nanoseconds the program spends blocked. By default, if -test.blockprofile is set without this flag, all blocking events are recorded, equivalent to -test.blockprofilerate=1.`},
{KeyPath: "Go.CPUProfile", Name: "cpuprofile", UsageArgument: "file", SectionKey: "performance-analysis",
Usage: `Write a CPU profile to the specified file before exiting. Preserves test binary.`},
{KeyPath: "Go.MemProfile", Name: "memprofile", UsageArgument: "file", SectionKey: "performance-analysis",
Usage: `Write an allocation profile to the file after all tests have passed. Preserves test binary.`},
{KeyPath: "Go.MemProfileRate", Name: "memprofilerate", UsageArgument: "rate", SectionKey: "performance-analysis",
Usage: `Enable more precise (and expensive) memory allocation profiles by setting runtime.MemProfileRate. See 'go doc runtime.MemProfileRate'. To profile all memory allocations, use -test.memprofilerate=1.`},
{KeyPath: "Go.MutexProfile", Name: "mutexprofile", UsageArgument: "file", SectionKey: "performance-analysis",
Usage: `Write a mutex contention profile to the specified file when all tests are complete. Preserves test binary.`},
{KeyPath: "Go.MutexProfileFraction", Name: "mutexprofilefraction", UsageArgument: "n", SectionKey: "performance-analysis",
Usage: `if >= 0, calls runtime.SetMutexProfileFraction() Sample 1 in n stack traces of goroutines holding a contended mutex.`},
{KeyPath: "Go.Trace", Name: "execution-trace", UsageArgument: "file", ExportAs: "trace", SectionKey: "performance-analysis",
Usage: `Write an execution trace to the specified file before exiting.`},
}
GoRunFlags provides flags for the Ginkgo CLI run, and watch commands that capture go's run-time flags. These are passed to the compiled test binary by the ginkgo CLI
var NodeTypesForContainerAndIt = []NodeType{NodeTypeContainer, NodeTypeIt}
var NodeTypesForSuiteLevelNodes = []NodeType{NodeTypeBeforeSuite, NodeTypeSynchronizedBeforeSuite, NodeTypeAfterSuite, NodeTypeSynchronizedAfterSuite, NodeTypeReportAfterSuite}
var ParallelConfigFlags = GinkgoFlags{
{KeyPath: "S.ParallelNode", Name: "parallel.node", SectionKey: "low-level-parallel", UsageDefaultValue: "1",
Usage: "This worker node's (one-indexed) node number. For running specs in parallel."},
{KeyPath: "S.ParallelTotal", Name: "parallel.total", SectionKey: "low-level-parallel", UsageDefaultValue: "1",
Usage: "The total number of worker nodes. For running specs in parallel."},
{KeyPath: "S.ParallelHost", Name: "parallel.host", SectionKey: "low-level-parallel", UsageDefaultValue: "set by Ginkgo CLI",
Usage: "The address for the server that will synchronize the running nodes."},
}
ParallelConfigFlags provides flags for the Ginkgo test process (not the CLI)
var ReporterConfigFlags = GinkgoFlags{
{KeyPath: "R.NoColor", Name: "no-color", SectionKey: "output", DeprecatedName: "noColor", DeprecatedDocLink: "changed-command-line-flags",
Usage: "If set, suppress color output in default reporter."},
{KeyPath: "R.SlowSpecThreshold", Name: "slow-spec-threshold", SectionKey: "output", UsageArgument: "duration", UsageDefaultValue: "5s",
Usage: "Specs that take longer to run than this threshold are flagged as slow by the default reporter."},
{KeyPath: "R.Verbose", Name: "v", SectionKey: "output",
Usage: "If set, default reporter print out all specs as they begin."},
{KeyPath: "R.Succinct", Name: "succinct", SectionKey: "output",
Usage: "If set, default reporter prints out a very succinct report"},
{KeyPath: "R.FullTrace", Name: "trace", SectionKey: "output",
Usage: "If set, default reporter prints out the full stack trace when a failure occurs"},
{KeyPath: "R.ReportPassed", Name: "report-passed", SectionKey: "output", DeprecatedName: "reportPassed", DeprecatedDocLink: "changed-command-line-flags",
Usage: "If set, default reporter prints out captured output of passed tests."},
{KeyPath: "R.JSONReport", Name: "json-report", UsageArgument: "filename.json", SectionKey: "output",
Usage: "If set, Ginkgo will generate a JSON-formatted test report at the specified location."},
{KeyPath: "R.JUnitReport", Name: "junit-report", UsageArgument: "filename.xml", SectionKey: "output", DeprecatedName: "reportFile", DeprecatedDocLink: "improved-reporting-infrastructure",
Usage: "If set, Ginkgo will generate a conformant junit test report in the specified file."},
{KeyPath: "R.TeamcityReport", Name: "teamcity-report", UsageArgument: "filename", SectionKey: "output",
Usage: "If set, Ginkgo will generate a Teamcity-formatted test report at the specified location."},
{KeyPath: "D.SlowSpecThresholdWithFLoatUnits", DeprecatedName: "slowSpecThreshold", DeprecatedDocLink: "changed--slowspecthreshold",
Usage: "use --slow-spec-threshold instead and pass in a duration string (e.g. '5s', not '5.0')"},
{KeyPath: "D.NoisyPendings", DeprecatedName: "noisyPendings", DeprecatedDocLink: "removed--noisypendings-and--noisyskippings"},
{KeyPath: "D.NoisySkippings", DeprecatedName: "noisySkippings", DeprecatedDocLink: "removed--noisypendings-and--noisyskippings"},
}
ReporterConfigFlags provides flags for the Ginkgo test process, and CLI
var SpecStateFailureStates = []SpecState{SpecStateFailed, SpecStatePanicked, SpecStateInterrupted}
var SuiteConfigFlags = GinkgoFlags{
{KeyPath: "S.RandomSeed", Name: "seed", SectionKey: "order", UsageDefaultValue: "randomly generated by Ginkgo",
Usage: "The seed used to randomize the spec suite."},
{KeyPath: "S.RandomizeAllSpecs", Name: "randomize-all", SectionKey: "order", DeprecatedName: "randomizeAllSpecs", DeprecatedDocLink: "changed-command-line-flags",
Usage: "If set, ginkgo will randomize all specs together. By default, ginkgo only randomizes the top level Describe, Context and When containers."},
{KeyPath: "S.FailOnPending", Name: "fail-on-pending", SectionKey: "failure", DeprecatedName: "failOnPending", DeprecatedDocLink: "changed-command-line-flags",
Usage: "If set, ginkgo will mark the test suite as failed if any specs are pending."},
{KeyPath: "S.FailFast", Name: "fail-fast", SectionKey: "failure", DeprecatedName: "failFast", DeprecatedDocLink: "changed-command-line-flags",
Usage: "If set, ginkgo will stop running a test suite after a failure occurs."},
{KeyPath: "S.FlakeAttempts", Name: "flake-attempts", SectionKey: "failure", UsageDefaultValue: "0 - failed tests are not retried", DeprecatedName: "flakeAttempts", DeprecatedDocLink: "changed-command-line-flags",
Usage: "Make up to this many attempts to run each spec. If any of the attempts succeed, the suite will not be failed."},
{KeyPath: "S.DryRun", Name: "dry-run", SectionKey: "debug", DeprecatedName: "dryRun", DeprecatedDocLink: "changed-command-line-flags",
Usage: "If set, ginkgo will walk the test hierarchy without actually running anything. Best paired with -v."},
{KeyPath: "S.EmitSpecProgress", Name: "progress", SectionKey: "debug",
Usage: "If set, ginkgo will emit progress information as each spec runs to the GinkgoWriter."},
{KeyPath: "S.Timeout", Name: "timeout", SectionKey: "debug", UsageDefaultValue: "1h",
Usage: "Test suite fails if it does not complete within the specified timeout."},
{KeyPath: "S.FocusStrings", Name: "focus", SectionKey: "filter",
Usage: "If set, ginkgo will only run specs that match this regular expression. Can be specified multiple times, values are ORed."},
{KeyPath: "S.SkipStrings", Name: "skip", SectionKey: "filter",
Usage: "If set, ginkgo will only run specs that do not match this regular expression. Can be specified multiple times, values are ORed."},
{KeyPath: "S.RegexScansFilePath", Name: "regex-scans-filepath", SectionKey: "filter", DeprecatedName: "regexScansFilePath", DeprecatedDocLink: "changed-command-line-flags",
Usage: "If set, ginkgo regex matching also will look at the file path (code location)."},
{KeyPath: "D.DebugParallel", DeprecatedName: "debug", DeprecatedDocLink: "removed--debug"},
}
SuiteConfigFlags provides flags for the Ginkgo test process, and CLI
Functions ¶
func GenerateFlagArgs ¶
func GenerateFlagArgs(flags GinkgoFlags, bindings interface{}) ([]string, error)
given a set of GinkgoFlags and bindings, generate flag arguments suitable to be passed to an application with that set of flags configured.
func GenerateGoTestCompileArgs ¶
func GenerateGoTestCompileArgs(goFlagsConfig GoFlagsConfig, destination string, packageToBuild string) ([]string, error)
GenerateGoTestCompileArgs is used by the Ginkgo CLI to generate command line arguments to pass to the go test -c command when compiling the test
func GenerateTestRunArgs ¶
func GenerateTestRunArgs(suiteConfig SuiteConfig, reporterConfig ReporterConfig, goFlagsConfig GoFlagsConfig) ([]string, error)
GenerateTestRunArgs is used by the Ginkgo CLI to generate command line arguments to pass to the compiled test binary
func PruneStack ¶
PruneStack removes references to functions that are internal to Ginkgo and the Go runtime from a stack string and a certain number of stack entries at the beginning of the stack. The stack string has the format as returned by runtime/debug.Stack. The leading goroutine information is optional and always removed if present. Beware that runtime/debug.Stack adds itself as first entry, so typically skip must be >= 1 to remove that entry.
func VetAndInitializeCLIAndGoConfig ¶
func VetAndInitializeCLIAndGoConfig(cliConfig CLIConfig, goFlagsConfig GoFlagsConfig) (CLIConfig, GoFlagsConfig, []error)
VetAndInitializeCLIAndGoConfig validates that the Ginkgo CLI's configuration is sound It returns a potentially mutated copy of the config that rationalizes the configuraiton to ensure consistency for downstream consumers
func VetConfig ¶
func VetConfig(flagSet GinkgoFlagSet, suiteConfig SuiteConfig, reporterConfig ReporterConfig) []error
VetConfig validates that the Ginkgo test process' configuration is sound
Types ¶
type CLIConfig ¶
type CLIConfig struct {
//for build, run, and watch
Recurse bool
SkipPackage string
RequireSuite bool
NumCompilers int
//for run and watch only
Nodes int
Parallel bool
AfterRunHook string
OutputDir string
KeepSeparateCoverprofiles bool
KeepSeparateReports bool
//for run only
KeepGoing bool
UntilItFails bool
Repeat int
RandomizeSuites bool
//for watch only
Depth int
WatchRegExp string
}
Configuration for the Ginkgo CLI
func NewDefaultCLIConfig ¶
func NewDefaultCLIConfig() CLIConfig
func (CLIConfig) ComputedNodes ¶
type CodeLocation ¶
type CodeLocation struct {
FileName string `json:",omitempty"`
LineNumber int `json:",omitempty"`
FullStackTrace string `json:",omitempty"`
CustomMessage string `json:",omitempty"`
}
func NewCodeLocation ¶
func NewCodeLocation(skip int) CodeLocation
func NewCodeLocationWithStackTrace ¶
func NewCodeLocationWithStackTrace(skip int) CodeLocation
func NewCustomCodeLocation ¶
func NewCustomCodeLocation(message string) CodeLocation
func (CodeLocation) String ¶
func (codeLocation CodeLocation) String() string
type DeprecatedSetupSummary ¶
type DeprecatedSetupSummary struct {
ComponentType SpecComponentType
CodeLocation CodeLocation
State SpecState
RunTime time.Duration
Failure SpecFailure
CapturedOutput string
SuiteID string
}
type DeprecatedSpecFailure ¶
type DeprecatedSpecFailure struct {
Message string
Location CodeLocation
ForwardedPanic string
ComponentIndex int
ComponentType SpecComponentType
ComponentCodeLocation CodeLocation
}
type DeprecatedSpecMeasurement ¶
type DeprecatedSpecMeasurement struct {
Name string
Info interface{}
Order int
Results []float64
Smallest float64
Largest float64
Average float64
StdDeviation float64
SmallestLabel string
LargestLabel string
AverageLabel string
Units string
Precision int
}
func (DeprecatedSpecMeasurement) PrecisionFmt ¶
func (s DeprecatedSpecMeasurement) PrecisionFmt() string
type DeprecatedSpecSummary ¶
type DeprecatedSpecSummary struct {
ComponentTexts []string
ComponentCodeLocations []CodeLocation
State SpecState
RunTime time.Duration
Failure SpecFailure
IsMeasurement bool
NumberOfSamples int
Measurements map[string]*DeprecatedSpecMeasurement
CapturedOutput string
SuiteID string
}
func (DeprecatedSpecSummary) Failed ¶
func (s DeprecatedSpecSummary) Failed() bool
func (DeprecatedSpecSummary) HasFailureState ¶
func (s DeprecatedSpecSummary) HasFailureState() bool
func (DeprecatedSpecSummary) Panicked ¶
func (s DeprecatedSpecSummary) Panicked() bool
func (DeprecatedSpecSummary) Passed ¶
func (s DeprecatedSpecSummary) Passed() bool
func (DeprecatedSpecSummary) Pending ¶
func (s DeprecatedSpecSummary) Pending() bool
func (DeprecatedSpecSummary) Skipped ¶
func (s DeprecatedSpecSummary) Skipped() bool
func (DeprecatedSpecSummary) TimedOut ¶
func (s DeprecatedSpecSummary) TimedOut() bool
type DeprecatedSuiteSummary ¶
type DeprecatedSuiteSummary struct {
SuiteDescription string
SuiteSucceeded bool
SuiteID string
NumberOfSpecsBeforeParallelization int
NumberOfTotalSpecs int
NumberOfSpecsThatWillBeRun int
NumberOfPendingSpecs int
NumberOfSkippedSpecs int
NumberOfPassedSpecs int
NumberOfFailedSpecs int
NumberOfFlakedSpecs int
RunTime time.Duration
}
type Deprecation ¶
type DeprecationTracker ¶
type DeprecationTracker struct {
// contains filtered or unexported fields
}
func NewDeprecationTracker ¶
func NewDeprecationTracker() *DeprecationTracker
func (*DeprecationTracker) DeprecationsReport ¶
func (d *DeprecationTracker) DeprecationsReport() string
func (*DeprecationTracker) DidTrackDeprecations ¶
func (d *DeprecationTracker) DidTrackDeprecations() bool
func (*DeprecationTracker) TrackDeprecation ¶
func (d *DeprecationTracker) TrackDeprecation(deprecation Deprecation, cl ...CodeLocation)
type Failure ¶
type Failure struct {
// Message - the failure message passed into Fail(...). When using a matcher library
// like Gomega, this will contain the failure message generated by Gomega.
Message string
// Location - the CodeLocation where the failure occurred
// This CodeLocation will include a fully-populated StackTrace
Location CodeLocation
// ForwardedPanic - if the failure represents a captured panic (i.e. Summary.State == SpecStatePanicked)
// then ForwardedPanic will be populated with a string representation of the captured panic.
ForwardedPanic string `json:",omitempty"`
// FailureNodeContext - one of three contexts describing the node in which the failure occured:
// FailureNodeIsLeafNode means the failure occured in the leaf node of the associated SpecReport. None of the other FailureNode fields will be populated
// FailureNodeAtTopLevel means the failure occured in a non-leaf node that is defined at the top-level of the spec (i.e. not in a container). FailureNodeType and FailureNodeLocation will be populated.
// FailureNodeInContainer means the failure occured in a non-leaf node that is defined within a container. FailureNodeType, FailureNodeLocaiton, and FailureNodeContainerIndex will be populated.
//
// FailureNodeType will contain the NodeType of the node in which the failure occurred.
// FailureNodeLocation will contain the CodeLocation of the node in which the failure occurred.
// If populated, FailureNodeContainerIndex will be the index into SpecReport.ContainerHierarchyTexts and SpecReport.ContainerHierarchyLocations that represents the parent container of the node in which the failure occurred.
FailureNodeContext FailureNodeContext
FailureNodeType NodeType
FailureNodeLocation CodeLocation
FailureNodeContainerIndex int
}
Failure captures failure information for an individual test
type FailureNodeContext ¶
type FailureNodeContext uint
FailureNodeContext captures the location context for the node containing the failing line of code
const ( FailureNodeContextInvalid FailureNodeContext = iota FailureNodeIsLeafNode FailureNodeAtTopLevel FailureNodeInContainer )
func (FailureNodeContext) MarshalJSON ¶
func (fnc FailureNodeContext) MarshalJSON() ([]byte, error)
func (*FailureNodeContext) UnmarshalJSON ¶
func (fnc *FailureNodeContext) UnmarshalJSON(b []byte) error
type GinkgoError ¶
type GinkgoError struct {
Heading string
Message string
DocLink string
CodeLocation CodeLocation
}
func (GinkgoError) Error ¶
func (g GinkgoError) Error() string
type GinkgoFlag ¶
type GinkgoFlagSection ¶
type GinkgoFlagSections ¶
type GinkgoFlagSections []GinkgoFlagSection
func (GinkgoFlagSections) Lookup ¶
func (gfs GinkgoFlagSections) Lookup(key string) (GinkgoFlagSection, bool)
type GinkgoFlagSet ¶
type GinkgoFlagSet struct {
// contains filtered or unexported fields
}
func BuildBuildCommandFlagSet ¶
func BuildBuildCommandFlagSet(cliConfig *CLIConfig, goFlagsConfig *GoFlagsConfig) (GinkgoFlagSet, error)
BuildWatchCommandFlagSet builds the FlagSet for the `ginkgo build` command
func BuildRunCommandFlagSet ¶
func BuildRunCommandFlagSet(suiteConfig *SuiteConfig, reporterConfig *ReporterConfig, cliConfig *CLIConfig, goFlagsConfig *GoFlagsConfig) (GinkgoFlagSet, error)
BuildRunCommandFlagSet builds the FlagSet for the `ginkgo run` command
func BuildTestSuiteFlagSet ¶
func BuildTestSuiteFlagSet(suiteConfig *SuiteConfig, reporterConfig *ReporterConfig) (GinkgoFlagSet, error)
BuildTestSuiteFlagSet attaches to the CommandLine flagset and provides flags for the Ginkgo test process
func BuildWatchCommandFlagSet ¶
func BuildWatchCommandFlagSet(suiteConfig *SuiteConfig, reporterConfig *ReporterConfig, cliConfig *CLIConfig, goFlagsConfig *GoFlagsConfig) (GinkgoFlagSet, error)
BuildWatchCommandFlagSet builds the FlagSet for the `ginkgo watch` command
func NewAttachedGinkgoFlagSet ¶
func NewAttachedGinkgoFlagSet(flagSet *flag.FlagSet, flags GinkgoFlags, bindings interface{}, sections GinkgoFlagSections, extraGoFlagsSection GinkgoFlagSection) (GinkgoFlagSet, error)
Call NewGinkgoFlagSet to create GinkgoFlagSet that extends an existing *flag.FlagSet
func NewGinkgoFlagSet ¶
func NewGinkgoFlagSet(flags GinkgoFlags, bindings interface{}, sections GinkgoFlagSections) (GinkgoFlagSet, error)
Call NewGinkgoFlagSet to create GinkgoFlagSet that creates and binds to it's own *flag.FlagSet
func (GinkgoFlagSet) IsZero ¶
func (f GinkgoFlagSet) IsZero() bool
func (GinkgoFlagSet) Usage ¶
func (f GinkgoFlagSet) Usage() string
func (GinkgoFlagSet) ValidateDeprecations ¶
func (f GinkgoFlagSet) ValidateDeprecations(deprecationTracker *DeprecationTracker)
func (GinkgoFlagSet) WasSet ¶
func (f GinkgoFlagSet) WasSet(name string) bool
type GinkgoFlags ¶
type GinkgoFlags []GinkgoFlag
func (GinkgoFlags) CopyAppend ¶
func (f GinkgoFlags) CopyAppend(flags ...GinkgoFlag) GinkgoFlags
func (GinkgoFlags) WithPrefix ¶
func (f GinkgoFlags) WithPrefix(prefix string) GinkgoFlags
type GoFlagsConfig ¶
type GoFlagsConfig struct {
//build-time flags for code-and-performance analysis
Race bool
Cover bool
CoverMode string
CoverPkg string
Vet string
//run-time flags for code-and-performance analysis
BlockProfile string
BlockProfileRate int
CoverProfile string
CPUProfile string
MemProfile string
MemProfileRate int
MutexProfile string
MutexProfileFraction int
Trace string
//build-time flags for building
A bool
ASMFlags string
BuildMode string
Compiler string
GCCGoFlags string
GCFlags string
InstallSuffix string
LDFlags string
Mod string
N bool
ModFile string
ModCacheRW bool
MSan bool
PkgDir string
Tags string
TrimPath bool
ToolExec string
Work bool
X bool
}
Configuration for the Ginkgo CLI capturing available go flags A subset of Go flags are exposed by Ginkgo. Some are avaiable at compile time (e.g. ginkgo build) and others only at run time (e.g. ginkgo run - which has both build and run time flags). More details can be found at: https://docs.google.com/spreadsheets/d/1zkp-DS4hU4sAJl5eHh1UmgwxCPQhf3s5a8fbiOI8tJU/
func NewDefaultGoFlagsConfig ¶
func NewDefaultGoFlagsConfig() GoFlagsConfig
func (GoFlagsConfig) BinaryMustBePreserved ¶
func (g GoFlagsConfig) BinaryMustBePreserved() bool
type NodeType ¶
type NodeType uint
NodeType captures the type of a given Ginkgo Node
const ( NodeTypeInvalid NodeType = iota NodeTypeContainer NodeTypeIt NodeTypeBeforeEach NodeTypeJustBeforeEach NodeTypeAfterEach NodeTypeJustAfterEach NodeTypeBeforeSuite NodeTypeSynchronizedBeforeSuite NodeTypeAfterSuite NodeTypeSynchronizedAfterSuite NodeTypeReportAfterEach NodeTypeReportAfterSuite )
func (NodeType) MarshalJSON ¶
func (*NodeType) UnmarshalJSON ¶
type PreRunStats ¶
PreRunStats contains a set of stats captured before the test run begins. This is primarily used by Ginkgo's reporter to tell the user how many specs are in the current suite (PreRunStats.TotalSpecs) and how many it intends to run (PreRunStats.SpecsThatWillRun) after applying any relevant focus or skip filters.
type Report ¶
type Report struct {
//SuitePath captures the absolute path to the test suite
SuitePath string
//SuiteDescription cpatures the description string passed to the DSL's RunSpecs() command
SuiteDescription string
//SuiteSucceeded captures the success or failure status of the test run
//If true, the test run is considered successful.
//If false, the test run is considered unsucccessful
SuiteSucceeded bool
//SuiteHasProgrammaticFocus captures whether the test suite has a test or set of tests that are programatically focused
//(i.e an `FIt` or an `FDescribe`
SuiteHasProgrammaticFocus bool
//SpecialSuiteFailureReasons may contain special failure reasons
//For example, a test suite might be considered "failed" even if none of the individual specs
//have a failure state. For example, if the user has configured --fail-on-pending the test suite
//will have failed if there are pending tests even though all non-pending tests may have passed. In such
//cases, Ginkgo populates SpecialSuiteFailureReasons with a clear message indicating the reason for the failure.
//SpecialSuiteFailureReasons is also populated if the test suite is interrupted by the user.
//Since multiple special failure reasons can occur, this field is a slice.
SpecialSuiteFailureReasons []string
//PreRunStats contains a set of stats captured before the test run begins. This is primarily used
//by Ginkgo's reporter to tell the user how many specs are in the current suite (PreRunStats.TotalSpecs)
//and how many it intends to run (PreRunStats.SpecsThatWillRun) after applying any relevant focus or skip filters.
PreRunStats PreRunStats
//StartTime and EndTime capture the start and end time of the test run
StartTime time.Time
EndTime time.Time
//RunTime captures the duration of the test run
RunTime time.Duration
//SuiteConfig captures the Ginkgo configuration governing this test run
//SuiteConfig includes information necessary for reproducing an identical test run,
//such as the random seed and any filters applied during the test run
SuiteConfig SuiteConfig
//SpecReports is a list of all SpecReports generated by this test run
SpecReports SpecReports
}
Report captures information about a Ginkgo test run
type ReporterConfig ¶
type ReporterConfig struct {
NoColor bool
SlowSpecThreshold time.Duration
Succinct bool
Verbose bool
FullTrace bool
ReportPassed bool
JSONReport string
JUnitReport string
TeamcityReport string
}
Configuration for Ginkgo's reporter
func NewDefaultReporterConfig ¶
func NewDefaultReporterConfig() ReporterConfig
func (ReporterConfig) WillGenerateReport ¶
func (rc ReporterConfig) WillGenerateReport() bool
type SetupSummary ¶
type SetupSummary = DeprecatedSetupSummary
type SpecComponentType ¶
type SpecComponentType = NodeType
type SpecFailure ¶
type SpecFailure = DeprecatedSpecFailure
type SpecMeasurement ¶
type SpecMeasurement = DeprecatedSpecMeasurement
type SpecReport ¶
type SpecReport struct {
// ContainerHierarchyTexts is a slice containing the text strings of
// all Describe/Context/When containers in this spec's hierarchy.
ContainerHierarchyTexts []string
// ContainerHierarchyLocations is a slice containing the CodeLocations of
// all Describe/Context/When containers in this spec's hirerachy.
ContainerHierarchyLocations []CodeLocation
// LeafNodeType, LeadNodeLocation, and LeafNodeText capture the NodeType, CodeLocation, and text
// of the Ginkgo node being tested (typically an NodeTypeIt node, though this can also be
// one of the NodeTypesForSuiteLevelNodes node types)
LeafNodeType NodeType
LeafNodeLocation CodeLocation
LeafNodeText string
// State captures whether the spec has passed, failed, etc.
State SpecState
// StartTime and EndTime capture the start and end time of the spec
StartTime time.Time
EndTime time.Time
// RunTime captures the duration of the spec
RunTime time.Duration
// GinkgoParallelNode captures the parallel node that this spec ran on
GinkgoParallelNode int
//Failure is populated if a spec has failed, panicked, been interrupted, or skipped by the user (e.g. calling Skip())
//It includes detailed information about the Failure
Failure Failure
// NumAttempts captures the number of times this Spec was run. Flakey specs can be retried with
// ginkgo --flake-attempts=N
NumAttempts int
// CapturedGinkgoWriterOutput contains text printed to the GinkgoWriter
CapturedGinkgoWriterOutput string
// CapturedStdOutErr contains text printed to stdout/stderr (when running in parallel)
// This is always empty when running in series or calling CurrentSpecReport()
// It is used internally by Ginkgo's reporter
CapturedStdOutErr string
}
SpecReport captures information about a Ginkgo spec.
func (SpecReport) CombinedOutput ¶
func (report SpecReport) CombinedOutput() string
CombinedOutput returns a single string representation of both CapturedStdOutErr and CapturedGinkgoWriterOutput Note that both are empty when using CurrentSpecReport() so CurrentSpecReport().CombinedOutput() will always be empty. CombinedOutput() is used internally by Ginkgo's reporter.
func (SpecReport) Failed ¶
func (report SpecReport) Failed() bool
Failed returns true if report.State is one of the SpecStateFailureStates (SpecStateFAiled, SpecStatePanicked, SpecStateinterrupted)
func (SpecReport) FailureLocation ¶
func (report SpecReport) FailureLocation() CodeLocation
FailureLocation() returns the location of the failure (or an empty CodeLocation if the test hasn't failed)
func (SpecReport) FailureMessage ¶
func (report SpecReport) FailureMessage() string
FailureMessage() returns the failure message (or empty string if the test hasn't failed)
func (SpecReport) FileName ¶
func (report SpecReport) FileName() string
FileName() returns the name of the file containing the spec
func (SpecReport) FullText ¶
func (report SpecReport) FullText() string
FullText returns a concatenation of all the report.NodeTexts
func (SpecReport) LineNumber ¶
func (report SpecReport) LineNumber() int
LineNumber() returns the line number of the leaf node
func (SpecReport) MarshalJSON ¶
func (report SpecReport) MarshalJSON() ([]byte, error)
type SpecReports ¶
type SpecReports []SpecReport
func (SpecReports) CountOfFlakedSpecs ¶
func (reports SpecReports) CountOfFlakedSpecs() int
CountWithState returns the number of SpecReports that passed after multiple attempts
func (SpecReports) CountWithState ¶
func (reports SpecReports) CountWithState(states ...SpecState) int
CountWithState returns the number of SpecReports with State matching one of the requested SpecStates
func (SpecReports) WithLeafNodeType ¶
func (reports SpecReports) WithLeafNodeType(nodeType ...NodeType) SpecReports
WithLeafNodeType returns the subset of SpecReports with LeafNodeType matching one of the requested NodeTypes
func (SpecReports) WithState ¶
func (reports SpecReports) WithState(states ...SpecState) SpecReports
WithState returns the subset of SpecReports with State matching one of the requested SpecStates
type SpecState ¶
type SpecState uint
SpecState captures the state of a spec To determine if a given `state` represents a failure state, use `state.Is(SpecStateFailureStates...)`
func (SpecState) MarshalJSON ¶
func (*SpecState) UnmarshalJSON ¶
type SpecSummary ¶
type SpecSummary = DeprecatedSpecSummary
type SuiteConfig ¶
type SuiteConfig struct {
RandomSeed int64
RandomizeAllSpecs bool
RegexScansFilePath bool
FocusStrings []string
SkipStrings []string
FailOnPending bool
FailFast bool
FlakeAttempts int
EmitSpecProgress bool
DryRun bool
Timeout time.Duration
ParallelNode int
ParallelTotal int
ParallelHost string
}
Configuration controlling how an individual test suite is run
func NewDefaultSuiteConfig ¶
func NewDefaultSuiteConfig() SuiteConfig
type SuiteSummary ¶
type SuiteSummary = DeprecatedSuiteSummary