diff --git a/go.mod b/go.mod index 3f59a58464..a4654f7342 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( github.com/linuxkit/virtsock v0.0.0-20220523201153-1a23e78aa7a2 github.com/mattn/go-colorable v0.1.15 github.com/mdlayher/vsock v1.3.0 - github.com/onsi/ginkgo/v2 v2.31.0 + github.com/onsi/ginkgo/v2 v2.32.0 github.com/onsi/gomega v1.42.0 github.com/opencontainers/image-spec v1.1.1 github.com/openshift/api v0.0.0-20260105191300-d1c4dc4fd37b diff --git a/go.sum b/go.sum index d8a5bbec50..0b3fd7259b 100644 --- a/go.sum +++ b/go.sum @@ -288,8 +288,8 @@ github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY= github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.31.0 h1:GtuJos5DFUV9EerYJo8RhYxosYNGvOdDE5haKq6Grfs= -github.com/onsi/ginkgo/v2 v2.31.0/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44= +github.com/onsi/ginkgo/v2 v2.32.0 h1:Hw7s2pVrQo/8Yz5N77qdnpHaoc+c6cC9WIV1Jce+J6E= +github.com/onsi/ginkgo/v2 v2.32.0/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44= github.com/onsi/gomega v1.42.0 h1:CJby8u36xb7v34W78F8WKvqTQP7PCMIPB78IVDB73l4= github.com/onsi/gomega v1.42.0/go.mod h1:M/Uqpu/8qTjtzCLUA2zJHX9Iilrau25x1PdoSRbWh5A= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= diff --git a/vendor/github.com/onsi/ginkgo/v2/CHANGELOG.md b/vendor/github.com/onsi/ginkgo/v2/CHANGELOG.md index fe25998c6d..10e608564c 100644 --- a/vendor/github.com/onsi/ginkgo/v2/CHANGELOG.md +++ b/vendor/github.com/onsi/ginkgo/v2/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.32.0 + +`-fd` generate RSpec-style documentation output. Thank @woodie ! +--sleep-on-failure pauses a failed spec before teardown. Thanks @qinqon ! + ## 2.31.0 Add a bunch of Claude Skills via the marketplace: diff --git a/vendor/github.com/onsi/ginkgo/v2/ginkgo/run/run_command.go b/vendor/github.com/onsi/ginkgo/v2/ginkgo/run/run_command.go index c5091e6de8..7b6c2cc226 100644 --- a/vendor/github.com/onsi/ginkgo/v2/ginkgo/run/run_command.go +++ b/vendor/github.com/onsi/ginkgo/v2/ginkgo/run/run_command.go @@ -39,6 +39,10 @@ func BuildRunCommand() command.Command { cliConfig, goFlagsConfig, errors = types.VetAndInitializeCLIAndGoConfig(cliConfig, goFlagsConfig) command.AbortIfErrors("Ginkgo detected configuration issues:", errors) + if types.ReconcileFdOutputConfiguration(reporterConfig, &suiteConfig, &cliConfig) { + fmt.Println("--fd is incompatible with parallel runs (-p/-procs) and -randomize-all; ignoring those flags and running specs in series, in declaration order.") + } + runner := &SpecRunner{ cliConfig: cliConfig, goFlagsConfig: goFlagsConfig, diff --git a/vendor/github.com/onsi/ginkgo/v2/ginkgo/watch/watch_command.go b/vendor/github.com/onsi/ginkgo/v2/ginkgo/watch/watch_command.go index fe1ca30519..c60d7115fa 100644 --- a/vendor/github.com/onsi/ginkgo/v2/ginkgo/watch/watch_command.go +++ b/vendor/github.com/onsi/ginkgo/v2/ginkgo/watch/watch_command.go @@ -37,6 +37,10 @@ func BuildWatchCommand() command.Command { cliConfig, goFlagsConfig, errors = types.VetAndInitializeCLIAndGoConfig(cliConfig, goFlagsConfig) command.AbortIfErrors("Ginkgo detected configuration issues:", errors) + if types.ReconcileFdOutputConfiguration(reporterConfig, &suiteConfig, &cliConfig) { + fmt.Println("--fd is incompatible with parallel runs (-p/-procs) and -randomize-all; ignoring those flags and running specs in series, in declaration order.") + } + watcher := &SpecWatcher{ cliConfig: cliConfig, goFlagsConfig: goFlagsConfig, diff --git a/vendor/github.com/onsi/ginkgo/v2/internal/suite.go b/vendor/github.com/onsi/ginkgo/v2/internal/suite.go index 57c1cffe71..6c879855e8 100644 --- a/vendor/github.com/onsi/ginkgo/v2/internal/suite.go +++ b/vendor/github.com/onsi/ginkgo/v2/internal/suite.go @@ -996,6 +996,7 @@ func (suite *Suite) runNode(node Node, specDeadline time.Time, text string) (typ } else { failure.Message, failure.Location, failure.ForwardedPanic, failure.TimelineLocation = failureFromRun.Message, failureFromRun.Location, failureFromRun.ForwardedPanic, failureFromRun.TimelineLocation suite.reporter.EmitFailure(outcomeFromRun, failure) + suite.pauseOnFailureIfRequested(node) return outcomeFromRun, failure } case <-gracePeriodChannel: @@ -1079,6 +1080,42 @@ func (suite *Suite) runNode(node Node, specDeadline time.Time, text string) (typ } } +// pauseOnFailureIfRequested pauses the suite at the moment a failure is identified, +// when the user has set --sleep-on-failure. This hooks directly into runNode's failure +// path so the pause happens immediately at the point of failure - before any teardown +// or cleanup runs - leaving the system live for inspection. +// +// We only pause for failures in setup and subject nodes (It, Before*, BeforeSuite...), +// i.e. nodes that run before teardown. Pausing on a failure in a teardown/cleanup or +// reporting node would be pointless (the system is already being torn down) and could +// interfere with interrupt handling, so those are skipped. +// +// The pause is interruptible: pressing ^C (or any interrupt) ends the pause early and +// the suite proceeds to run cleanup as usual. It is a no-op if the feature is disabled. +func (suite *Suite) pauseOnFailureIfRequested(node Node) { + if suite.config.SleepOnFailure <= 0 { + return + } + // only pause before teardown - skip teardown/cleanup/reporting nodes + if node.NodeType.Is(types.NodeTypesAllowedDuringCleanupInterrupt | types.NodeTypesAllowedDuringReportInterrupt) { + return + } + + duration := suite.config.SleepOnFailure + report := suite.generateProgressReport(false) + report.Message = fmt.Sprintf("{{bold}}{{orange}}Paused on failure for up to %s.{{/}}\nThe spec failed and Ginkgo has paused before running any teardown so you can inspect the live system.\nPress {{bold}}^C{{/}} to end the pause and proceed to cleanup.", duration) + suite.emitProgressReport(report) + + timer := time.NewTimer(duration) + defer timer.Stop() + // wait for the pause to elapse, or for the user to interrupt - in which case we end + // the pause early and let runNode return so cleanup can proceed + select { + case <-timer.C: + case <-suite.interruptHandler.Status().Channel: + } +} + // TODO: search for usages and consider if reporter.EmitFailure() is necessary func (suite *Suite) failureForLeafNodeWithMessage(node Node, message string) types.Failure { return types.Failure{ diff --git a/vendor/github.com/onsi/ginkgo/v2/reporters/default_reporter.go b/vendor/github.com/onsi/ginkgo/v2/reporters/default_reporter.go index be5719a8ef..f3e15a913e 100644 --- a/vendor/github.com/onsi/ginkgo/v2/reporters/default_reporter.go +++ b/vendor/github.com/onsi/ginkgo/v2/reporters/default_reporter.go @@ -31,6 +31,7 @@ type DefaultReporter struct { specDenoter string retryDenoter string formatter formatter.Formatter + fdHierarchy []string runningInParallel bool lock *sync.Mutex @@ -82,6 +83,8 @@ func (r *DefaultReporter) SuiteWillBegin(report types.Report) { if report.SuiteConfig.ParallelTotal > 1 { r.emit(r.f("- %d procs ", report.SuiteConfig.ParallelTotal)) } + } else if r.conf.FdOutput { + return } else { banner := r.f("Running Suite: %s - %s", report.SuiteDescription, report.SuitePath) r.emitBlock(banner) @@ -124,7 +127,7 @@ func (r *DefaultReporter) SuiteWillBegin(report types.Report) { func (r *DefaultReporter) SuiteDidEnd(report types.Report) { failures := report.SpecReports.WithState(types.SpecStateFailureStates) - if len(failures) > 0 { + if !r.conf.FdOutput && len(failures) > 0 { r.emitBlock("\n") if len(failures) > 1 { r.emitBlock(r.f("{{red}}{{bold}}Summarizing %d Failures:{{/}}", len(failures))) @@ -227,6 +230,10 @@ func (r *DefaultReporter) DidRun(report types.SpecReport) { return } + if r.conf.FdOutput { + r.didRunFd(report) + return + } header := r.specDenoter if report.LeafNodeType.Is(types.NodeTypesForSuiteLevelNodes) { header = fmt.Sprintf("[%s]", report.LeafNodeType) @@ -358,6 +365,51 @@ func (r *DefaultReporter) DidRun(report types.SpecReport) { r.emitDelimiter(0) } +func (r *DefaultReporter) didRunFd(report types.SpecReport) { + r.lock.Lock() + defer r.lock.Unlock() + + if !report.LeafNodeType.Is(types.NodeTypeIt) { + return + } + + hierarchy := report.ContainerHierarchyTexts + + // blank line when top-level container changes + if len(r.fdHierarchy) > 0 && + (len(hierarchy) == 0 || hierarchy[0] != r.fdHierarchy[0]) { + fmt.Fprintln(r.writer) + } + + // emit newly-diverged container lines + divergeAt := 0 + for divergeAt < len(r.fdHierarchy) && divergeAt < len(hierarchy) && + r.fdHierarchy[divergeAt] == hierarchy[divergeAt] { + divergeAt++ + } + for i := divergeAt; i < len(hierarchy); i++ { + fmt.Fprintf(r.writer, "%s%s\n", strings.Repeat(" ", i), hierarchy[i]) + } + + // leaf label + depth := len(hierarchy) + indent := strings.Repeat(" ", depth) + label := report.LeafNodeText + + switch report.State { + case types.SpecStateFailed, types.SpecStatePanicked: + label = fmt.Sprintf("%s (FAILED)", label) + case types.SpecStatePending: + label = fmt.Sprintf("%s (PENDING)", label) + case types.SpecStateSkipped: + label = fmt.Sprintf("%s (SKIPPED)", label) + } + + color := r.highlightColorForState(report.State) + fmt.Fprintf(r.writer, "%s%s\n", indent, r.f(color+"%s{{/}}", label)) + r.fdHierarchy = hierarchy +} + func (r *DefaultReporter) highlightColorForState(state types.SpecState) string { switch state { case types.SpecStatePassed: diff --git a/vendor/github.com/onsi/ginkgo/v2/types/config.go b/vendor/github.com/onsi/ginkgo/v2/types/config.go index ca64acb27a..854fec6a39 100644 --- a/vendor/github.com/onsi/ginkgo/v2/types/config.go +++ b/vendor/github.com/onsi/ginkgo/v2/types/config.go @@ -38,6 +38,7 @@ type SuiteConfig struct { OutputInterceptorMode string SourceRoots []string GracePeriod time.Duration + SleepOnFailure time.Duration ParallelProcess int ParallelTotal int @@ -94,6 +95,7 @@ type ReporterConfig struct { GithubOutput bool SilenceSkips bool ForceNewlines bool + FdOutput bool JSONReport string GoJSONReport string @@ -293,6 +295,8 @@ var SuiteConfigFlags = GinkgoFlags{ 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.FailOnEmpty", Name: "fail-on-empty", SectionKey: "failure", Usage: "If set, ginkgo will mark the test suite as failed if no specs are run."}, + {KeyPath: "S.SleepOnFailure", Name: "sleep-on-failure", SectionKey: "failure", UsageDefaultValue: "0 - disabled", + Usage: "If set, ginkgo will pause for this duration after a spec fails - before its teardown (AfterEach/JustAfterEach/DeferCleanup) runs - so you can inspect the live system. Press ^C to end the pause early and proceed to cleanup. Serial only: cannot be combined with -p/--procs."}, {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."}, @@ -358,7 +362,8 @@ var ReporterConfigFlags = GinkgoFlags{ Usage: "If set, default reporter will not print out skipped tests."}, {KeyPath: "R.ForceNewlines", Name: "force-newlines", SectionKey: "output", Usage: "If set, default reporter will ensure a newline appears after each test."}, - + {KeyPath: "R.FdOutput", Name: "fd", SectionKey: "output", + Usage: "If set, emits RSpec-style 'format documentation' output instead of Ginkgo's default output. --fd is exclusive: it overrides -p/-procs and -randomize-all, forcing specs to run serially in declaration order, since fd's hierarchical output can't be rendered sensibly when specs are parallelized or randomized."}, {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.GoJSONReport", Name: "gojson-report", UsageArgument: "filename.json", SectionKey: "output", @@ -429,6 +434,14 @@ func VetConfig(flagSet GinkgoFlagSet, suiteConfig SuiteConfig, reporterConfig Re errors = append(errors, GinkgoErrors.GracePeriodCannotBeZero()) } + if suiteConfig.SleepOnFailure < 0 { + errors = append(errors, GinkgoErrors.InvalidSleepOnFailureConfiguration()) + } + + if suiteConfig.SleepOnFailure > 0 && suiteConfig.ParallelTotal > 1 { + errors = append(errors, GinkgoErrors.SleepOnFailureInParallelConfiguration()) + } + if len(suiteConfig.FocusFiles) > 0 { _, err := ParseFileFilters(suiteConfig.FocusFiles) if err != nil { @@ -476,6 +489,30 @@ func VetConfig(flagSet GinkgoFlagSet, suiteConfig SuiteConfig, reporterConfig Re return errors } +// ReconcileFdOutputConfiguration forces serial, in-order execution when --fd is combined with +// -p, -procs (>1), or -randomize-all. fd's RSpec-style hierarchical output assumes specs run +// one at a time, in declaration order -- parallelism and randomization both break that assumption +// and produce fragmented, hard-to-read output. Rather than refusing to run, Ginkgo ignores those +// flags and runs in series instead. suiteConfig and cliConfig are mutated in place; the return +// value is true if anything was overridden, so callers can let the user know what was ignored. +func ReconcileFdOutputConfiguration(reporterConfig ReporterConfig, suiteConfig *SuiteConfig, cliConfig *CLIConfig) bool { + if !reporterConfig.FdOutput { + return false + } + + changed := false + if cliConfig.ComputedProcs() > 1 { + cliConfig.Procs = 1 + cliConfig.Parallel = false + changed = true + } + if suiteConfig.RandomizeAllSpecs { + suiteConfig.RandomizeAllSpecs = false + changed = true + } + return changed +} + // GinkgoCLISharedFlags provides flags shared by the Ginkgo CLI's build, watch, and run commands var GinkgoCLISharedFlags = GinkgoFlags{ {KeyPath: "C.Recurse", Name: "r", SectionKey: "multiple-suites", diff --git a/vendor/github.com/onsi/ginkgo/v2/types/errors.go b/vendor/github.com/onsi/ginkgo/v2/types/errors.go index 623e54b66e..636070c124 100644 --- a/vendor/github.com/onsi/ginkgo/v2/types/errors.go +++ b/vendor/github.com/onsi/ginkgo/v2/types/errors.go @@ -455,7 +455,7 @@ func (g ginkgoErrors) InvalidEmptyComponentForSemVerConstraint(cl CodeLocation) Heading: "Invalid Empty Component for ComponentSemVerConstraint", Message: "ComponentSemVerConstraint requires a non-empty component name", CodeLocation: cl, - DocLink: "spec-semantic-version-filtering", + DocLink: "spec-semantic-version-filtering", } } @@ -621,6 +621,21 @@ func (g ginkgoErrors) GracePeriodCannotBeZero() error { } } +func (g ginkgoErrors) InvalidSleepOnFailureConfiguration() error { + return GinkgoError{ + Heading: "Ginkgo requires a non-negative --sleep-on-failure.", + Message: "Please set --sleep-on-failure to a positive duration (e.g. 5m), or 0 to disable it.", + } +} + +func (g ginkgoErrors) SleepOnFailureInParallelConfiguration() error { + return GinkgoError{ + Heading: "Ginkgo only supports --sleep-on-failure in serial mode.", + Message: "--sleep-on-failure pauses a failed spec on a live system for inspection, which only makes sense when the suite runs serially. Please run again without -p or --procs, or unset --sleep-on-failure.", + DocLink: "spec-timeouts-and-interruptible-nodes", + } +} + func (g ginkgoErrors) ConflictingVerbosityConfiguration() error { return GinkgoError{ Heading: "Conflicting reporter verbosity settings.", diff --git a/vendor/github.com/onsi/ginkgo/v2/types/version.go b/vendor/github.com/onsi/ginkgo/v2/types/version.go index 1b43092c22..dc28324c1d 100644 --- a/vendor/github.com/onsi/ginkgo/v2/types/version.go +++ b/vendor/github.com/onsi/ginkgo/v2/types/version.go @@ -1,3 +1,3 @@ package types -const VERSION = "2.31.0" +const VERSION = "2.32.0" diff --git a/vendor/modules.txt b/vendor/modules.txt index 10d8ec9aea..d902dd539d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -437,7 +437,7 @@ github.com/modern-go/reflect2 github.com/munnerz/goautoneg # github.com/nxadm/tail v1.4.11 ## explicit; go 1.13 -# github.com/onsi/ginkgo/v2 v2.31.0 +# github.com/onsi/ginkgo/v2 v2.32.0 ## explicit; go 1.25.0 github.com/onsi/ginkgo/v2 github.com/onsi/ginkgo/v2/config