8000 Allow extensions/globals.Reset to support re-running RunSpecs by lawrencejones · Pull Request #1673 · onsi/ginkgo · GitHub
[go: up one dir, main page]

Skip to content

Allow extensions/globals.Reset to support re-running RunSpecs - #1673

Merged
onsi merged 1 commit into
onsi:masterfrom
incident-io:reset-rerun-runspecs
Jun 11, 2026
Merged

onsi merged 1 commit into
onsi:masterfrom
incident-io:reset-rerun-runspecs

Conversation

@lawrencejones
Copy link
Copy Markdown
Contributor

Closes #1672.

What

Programs that drive Ginkgo programmatically (merged test binaries for large monorepos, meta-testing of dynamically generated suites) want to run several suites sequentially in one process: register specs, call RunSpecs, Reset, register the next suite's specs, and call RunSpecs again.

Everything RunSpecs uses is already either reconstructed per run (reporter, output interceptor, parallel client, progress handler) or reset by extensions/globals.Reset (the suite and failer themselves). The one blocker is the suiteDidRun guard, which lives in package ginkgo where Reset cannot reach it, so a second RunSpecs always exits with GinkgoErrors.RerunningSuite.

This moves the flag into internal/global as SuiteDidRun and clears it in InitializeGlobals. Calling RunSpecs twice without an intervening Reset still fails exactly as before — only an explicit Reset arms a fresh run, preserving the accidental-rerun protection. Includes a test in extensions/globals.

Why we want it

At incident.io we compile ~690 monorepo suites into one generated test binary (each per-suite binary was ~350MB of near-identical bytes). With this change, CI worker processes drain a suite queue — Reset, re-register, RunSpecs — paying process boot once per worker instead of once per suite. Per-suite reporting (--ginkgo.junit-report et al) behaves identically to separate processes, and our test phase dropped from ~98s to ~47s. We're currently running this in production CI from a fork pinned via replace, and would love to drop the fork.

Programs that drive Ginkgo programmatically — merged test binaries for large
monorepos, meta-testing of dynamically generated suites — want to run several
suites sequentially in one process: register specs, call RunSpecs, Reset,
register the next suite's specs, and call RunSpecs again. Everything RunSpecs
uses is already either reconstructed per run (reporter, output interceptor,
parallel client, progress handler) or reset by extensions/globals.Reset (the
suite and failer themselves). The one blocker is the suiteDidRun guard, which
lives in package ginkgo where Reset cannot reach it, so a second RunSpecs
always exits with GinkgoErrors.RerunningSuite.

Move the flag into internal/global as SuiteDidRun and clear it in
InitializeGlobals. Calling RunSpecs twice without an intervening Reset still
fails exactly as before — only an explicit Reset arms a fresh run.
@lawrencejones
Copy link
Copy Markdown
Contributor Author

Shout if you need more info on this, I'm hoping it should be an easy one 🙏

@onsi
onsi commented Jun 11, 2026
Copy link
Copy Markdown
Owner

wow what a trivial but impactful change. Do you mind updating (or asking a robot to update) the long-form docs as well?

I'll pull this in for now but a follow-on PR for the docs would be much appreciated.

@onsi
onsi merged commit 800291a into onsi:master Jun 11, 2026
@lawrencejones
lawrencejones deleted the reset-rerun-runspecs branch June 11, 2026 14:21
@lawrencejones
8000 Copy link
Copy Markdown
Contributor Author

Getting a docs PR prepared now, thank you for being so responsive!

@lawrencejones
Copy link
Copy Markdown
Contributor Author

Docs here: #1674

onsi pushed a commit that referenced this pull request Jun 11, 2026
Follow-up to #1673, covering the extensions/globals.Reset + RunSpecs pattern
in the long-form docs: when it applies, how each run behaves, and the caveats
(never Reset inside a running suite; Ginkgo resets its state but not yours;
parallelism stays one process per worker).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support running multiple suites sequentially in one process via extensions/globals.Reset

2 participants

0