fixturetest

package
v0.23.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fixturetest runs each rule against its fire/pass fixture trees and asserts findings match declared expectations exactly (spec §7).

isolate.go — a fixture for a process-bound rule is judged in its own repository (#28).

The {{root}}/{{repo}} tokens stop a rule NAMING a tree outside itself. They do not stop git. Git discovers a repository by walking UP from the working directory, and a fixture tree has no .git, so a detector that runs `git rev-parse` inside one finds whatever repository encloses the corpus — and a `--default-range` arm then judges the real branch's commits, which is how a pass fixture came to fail for a commit that was never in it. No argv mentions that channel, so no argv rule can close it.

It closes here instead: the arm is copied into a temp directory, that copy is `git init`-ed with one commit, and the copy is what the engine evaluates. Discovery stops at the fixture, and a `..` from the fixture root lands in an empty temp parent rather than in a repository.

Only rules that SPAWN A PROCESS are isolated. A declarative rule reads the files the walk handed it and cannot ask git anything, so copying its fixtures would buy nothing and cost a tree copy per arm across a corpus where those are almost all of them.

Index

Constants

View Source
const (
	StatusOK   = "ok"
	StatusFail = "fail"
	StatusSkip = "skip"

	KindFire = "fire"
	KindPass = "pass"
)

Result statuses and arm kinds.

Variables

This section is empty.

Functions

func EvalIn

func EvalIn(r *config.Rule, dir, repo string, workers int) ([]finding.Finding, *scan.FileSet, error)

EvalIn evaluates one rule over the fixture tree rooted at dir, returning its findings together with the walked FileSet. The caller passes a rule whose checker is already the one it wants exercised (see runFixture's Fresh below); EvalIn owns only what a fixture run must not inherit from the repo, so that policy lives in exactly one place rather than once per caller.

scan.ignore is repo-scoped: its globs are repo-root-relative, but this walk's root is the fixture dir, an unrelated path namespace. Applying them here would be a namespace collision — a fixture that happens to contain vendor/ must still be checked. The same holds for scan.gitignore, and more sharply: the paths a consumer's .gitignore covers (build/, .dart_tool/, node_modules/) are exactly the ones fixture trees like to use, so a repo-level prune would blind fire fixtures that live there — and a fire fixture that stops firing reports as a passing rule. Pinned by TestFixtureRunsAreScanIgnoreFree + TestFixtureRunsAreGitignoreFree.

Second consumer: lint's prefilter-load-bearing fixture differential (#133), which evaluates a rule and its prefilter-stripped twin over these same trees. It needs the identical walk semantics — a repo-level prune there would hide exactly the fire fixture that proves a prefilter load-bearing.

func Run

func Run(cfg *config.Config, allRuleIDs []string, root string, workers int, w io.Writer) (int, error)

Run evaluates every rule's fixtures under root/.formwork/fixtures and writes verdicts to w. It returns the number of failing verdicts (rules whose fixtures misbehaved, plus fixture dirs matching no rule id). Infrastructure problems (unreadable dirs, bad manifests, un-refreshable rules, symlinked fixture trees) return an error instead — never a silent pass. The text is rendered from Results, so the two cannot disagree.

Types

type ArmResult added in v0.17.0

type ArmResult struct {
	Arm      string   `json:"arm"`  // fixture dir name, e.g. "pass-clean"
	Kind     string   `json:"kind"` // "fire" | "pass"
	Path     string   `json:"path"` // repo-relative fixture dir, slash-separated
	OK       bool     `json:"ok"`
	Problems []string `json:"problems,omitempty"` // the same strings the human output prints
	// Vacuity is set for kind "pass" arms whose base run was OK, and only
	// those: "judged" | "vacuous" | "blind" | "not-judged". vacuous and blind
	// fail the arm; not-judged (a rule outside the verdicts' reach) never does.
	Vacuity       string `json:"vacuity,omitempty"`
	VacuityReason string `json:"vacuity_reason,omitempty"`
}

ArmResult is one fixture arm's outcome.

type RuleResult added in v0.17.0

type RuleResult struct {
	Rule   string      `json:"rule"`
	Status string      `json:"status"`           // "ok" | "fail" | "skip"
	Reason string      `json:"reason,omitempty"` // why skip / orphan
	Arms   []ArmResult `json:"arms"`             // sorted by Arm name; [] never null
}

RuleResult is one rule's fixture outcome. An orphan fixture dir (#9) is a RuleResult with Status "fail", a Reason and no arms.

func Results added in v0.17.0

func Results(cfg *config.Config, allRuleIDs []string, root string, workers int) ([]RuleResult, error)

Results evaluates every rule's fixtures and returns one RuleResult per rule in cfg order (rule-id sorted), then one per orphan fixture dir, sorted.

allRuleIDs is the FULL corpus id set, collected before any --rule scoping narrows cfg: the orphan check must know every legitimate fixture-dir name, or a scoped run would read sibling rules' fixtures as orphans (#58). A dir matching no id in that full set is still a FAIL result; it does not abort the run (#9).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL