Artifact 48b8a64f32bc3894d3f7f681ed6f8af0c15c488d2267b3c27ccd44d44da9d68a:
- File
conformance/submanifest_guards_test.go
— part of check-in
[43df2fd2c2]
at
2026-10-26 00:59:23
on branch fix/conformance-subtest-t
— test(conformance): hand each case its subtest's t; cancel stale Race runs
check runs each case as a subtest, but the suites passed the case the parent's t, captured in a closure. A fixture that skips or fails, as the fossil-built R-card fixture skips when fossil(1) is absent, then called SkipNow or FailNow on the parent from inside the subtest, which Go fails as "subtest may have called FailNow on a parent test". The Race workflow installs no fossil and failed this way in TestSparseCone. check now hands conforms the subtest's t, and all 150 call sites take it, so a case's skip or failure ends that case alone. TestCheckSkipEndsOnlyTheCase guards the harness.
A Race run takes most of an hour and merges land faster, so a new run on a ref now cancels the older one. (user: [email protected], size: 2423) [annotate] [blame] [check-ins using] [more...]
package conformance import ( "errors" "fmt" "testing" "github.com/danmestas/go-libfossil/internal/content" "github.com/danmestas/go-libfossil/internal/hash" "github.com/danmestas/go-libfossil/internal/manifest" ) // Cryptographic content addressing prevents authoring a real cycle. The probe // primes only walker identity state; its node still goes through real storage, // hash verification, parsing and treeWalk.step's repeated-artifact guard. func smGuardCases() []smCase { return []smCase{ smRepoCase("submanifest.5.1.cycle-guard-boundary", "SM-5.1-5", smCycleGuard), smRepoCase("submanifest.10.cycle-guard-boundary", "SM-10-1", smCycleGuard), smRepoCase("submanifest.10.visit-guard-boundary", "SM-10-1", smVisitGuard), } } func smGuardNode(f *smFixture) (string, error) { refs, err := f.leaves([]string{"guard/a"}) if err != nil { return "", err } uuid := refs[0].UUID rid, held := content.AvailableByUUID(f.r.DB(), uuid) if !held { return "", fmt.Errorf("guard fixture node %s is not held", uuid) } data, err := content.Expand(f.r.DB(), rid) if err != nil { return "", err } if hash.SHA3(data) != uuid { return "", fmt.Errorf("guard fixture node %s failed hash verification", uuid) } return uuid, nil } func smCycleGuard(f *smFixture) error { uuid, err := smGuardNode(f) if err != nil { return err } return smGuardFault(manifest.ProbeTreeCycle(f.r.DB(), uuid), uuid, "the reference closes a cycle") } func smVisitGuard(f *smFixture) error { uuid, err := smGuardNode(f) if err != nil { return err } lastAllowed, firstRefused := manifest.ProbeTreeVisitLimit(f.r.DB(), uuid) if lastAllowed != nil { return fmt.Errorf("last allowed resolution refused: %w", lastAllowed) } return smGuardFault(firstRefused, uuid, "the tree resolves more than 1048576 sub-manifests") } func smGuardFault(err error, uuid, reason string) error { var fault *manifest.SubmanifestError if !errors.As(err, &fault) { return fmt.Errorf("guard error %v, want SubmanifestError", err) } if fault.UUID != uuid { return fmt.Errorf("guard fault UUID %q, want %q", fault.UUID, uuid) } if fault.Missing { return fmt.Errorf("guard classified a held artifact as missing") } return want("guard fault reason", fault.Reason, reason) } func TestSubmanifestGuards(t *testing.T) { for _, c := range smGuardCases() { check(t, c.Case, func(t *testing.T) error { return c.run(t) }) } }