Repository navigation
feat: explicit declaration phases, clearer diagnostics, CI - #6
Merged
Merged
Conversation
Suite and ScenarioSpec track their declaration order as one phase value instead of independent flags. Enclosing Suites are now suspended while a nested Rule builder runs, so a declaration on an outer Suite inside a Rule builder fails instead of being filed outside the Rule. Diagnostics: - ordering errors state the legal order - a stopped scenario logs the operation it stopped in, its declaration site, and the operations that did not run - scenario log lines are attributed to the Feature call site - sealed-scope panics name the call site, the call, and the fix - Compose errors name the Compose call site ScenarioChain and BackgroundChain are exported so go doc lists their methods and helpers can accept and return a chain. Tests share a runSelf helper for subprocess runs and run in parallel. Add a CI workflow (gofmt, vet, race tests, govulncheck) and ARCHITECTURE.md.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes for callers
Two behaviour changes that can fail existing tests:
Rulebuilder runs now fails withthis Suite is suspended while its nested Rule builder runs. Previouslyf.Scenario,f.Outlineandf.Rulecalled insidef.Rule(..., func(r) { ... })were accepted and filed outside the Rule, without its tags, hooks or Background, and an otherwise empty Rule passed its non-empty check.bdd: Suite builder has returnedandbdd: ScenarioSpec builder has returnedare replaced by a message naming the call site, the call and the fix, for examplebdd: <file>:<line>: Suite.Before called on a sealed Suite: .... Code that matches the old strings will no longer match. Nil and zero receiver panics are unchanged.Additions:
ScenarioChainandBackgroundChainare exported (previously unexported return types).go docnow lists their methods, and helpers can accept and return a chain.Error,Fatal,Skipor panic during setup, a hook or an operation logs one line: the operation it stopped in, where that operation was declared, and the operations that did not run.bdd.Featurecall line instead ofsuite.go:N.Composeerrors include theCompose(...)call site.Exported signatures other than the two chain type names, generated test names, and lifecycle order are unchanged.
Why
The declaration order was enforced by three independent booleans on
Suiteand bysealedpluslen(steps) > 0onScenarioSpec, spread across every method and documented nowhere. That left the nested-Rule hole above.Suitenow has one phase value and one pure transition function (suitePhase.next);ScenarioSpechas one phase value.Also in this PR
runSelfhelper and run in parallel.gofmt,go vet,go test -race,govulncheck, with actions pinned by commit SHA (actions/checkoutv7.0.1,actions/setup-gov7.0.0).ARCHITECTURE.md, a "Declaration order" section in the README and package doc, and a README and comment clean-up.Verification
Run locally on Go 1.27.3, darwin/arm64:
gofmt -l .reports nothing;go vet ./...is clean.go test -race -count=1 ./...passes; three consecutive race runs passed after parallelising. The race run takes about 5.5s, down from about 19s.govulncheck ./...reports no vulnerabilities.Helpercall, reorder the operation sequence) each failed a test.The CI workflow is new in this PR; this PR is its first run.
Where to look
suite.go:suitePhase.next,Suite.Rule(suspend and resume),featurePlan.runLeaf(operation sequence and stop report).t.Cleanup, so it appears after the scenario's own cleanups.t.Helper()now has its failure attributed to thebdd.Featureline rather thansuite.go:N; the stop report names the operation.Not done
suite.go:Norscenario.go:Nprefix; the message itself contains the call site.