Artifact 14ed5205640399d7794bc0c605d0b1ef659f653ca4a52aa0478fb473efc849c7:
- File
conformance/repostate_verify_test.go
— part of check-in
[a6a1038b60]
at
2026-10-20 01:40:54
on branch fix/verify-leaf-rule
— fix(verify): accept fossil's leaf tables and reparented plink
leaf.Audit reads same-branch both as the draft does (active branch rows, the main-branch setting) and as fossil 2.28's leaf_check does (any branch row, the literal trunk). A row is stale only when both read a child as same-branch, and missing only when neither does, so Verify accepts the tables fossil writes when main-branch is not trunk or a branch tag was cancelled, and a go-built table after main-branch changes.
checkPlink no longer reports a P-card parent missing from plink when the check-in carries a parent tag, which replaces those rows in fossil. (user: [email protected], size: 3569) [annotate] [blame] [check-ins using] [more...]
package conformance import ( "fmt" "slices" "github.com/danmestas/go-libfossil/internal/repo" "github.com/danmestas/go-libfossil/internal/verify" ) // verify.Verify against the leaf table. Section 7.3 lets the table depend on // the order artifacts arrived in, so Verify must accept every table a load // derives -- goConforms runs it on every case that compares leaf, including // repostate.7.3.recheck-untagged-child -- and must still report what the // Section 7.2 test decides whatever the order. // verifyLeafIssues runs verify.Verify on the repository at path and returns // the check-ins its leaf issues name, by label. func verifyLeafIssues(path string, labels map[string]string) ([]string, error) { r, err := repo.Open(path) if err != nil { return nil, err } defer r.Close() report, err := verify.Verify(r) if err != nil { return nil, fmt.Errorf("verify.Verify: %w", err) } var named []string for _, iss := range report.Issues { if iss.Kind != verify.IssueLeafIncorrect { continue } var uuid string if err := r.DB().QueryRow("SELECT uuid FROM blob WHERE rid=?", iss.RID).Scan(&uuid); err != nil { return nil, fmt.Errorf("leaf issue rid=%d: %w", iss.RID, err) } label, ok := labels[uuid] if !ok { label = uuid } named = append(named, label) } slices.Sort(named) return named, nil } // verifyFossilLeaves runs verifyLeafIssues on a repository fossil(1) derived, // for a case comparing leaf: Verify must accept the tables fossil itself // writes, those of a case whose fossil field records fossil departing from // the draft included. It returns one problem naming how fossil derived it, or // none. func verifyFossilLeaves(c rsCase, path, how string, labels map[string]string) ([]string, error) { if !slices.Contains(c.tables, "leaf") { return nil, nil } issues, err := verifyLeafIssues(path, labels) if err != nil { return nil, fmt.Errorf("%s: %w", how, err) } if len(issues) == 0 { return nil, nil } return []string{fmt.Sprintf("%s: leaf issues on %v", how, issues)}, nil } func verifyLeafCases() []rsAPICase { return []rsAPICase{{ // b1, merged into trunk by m, and m are the leaves of merged(); b1's // only child is on another branch. Verify accepts that table, then // reports b1 once its row is dropped and c1 once one is planted: c1's // child c2 is on trunk with it, by a branch row propagated along the // link, so the recheck that row scheduled removed c1. Case: Case{ID: "repostate.7.2.verify-leaf-table", Req: "RS-7.2-1"}, arts: merged(), run: verifyLeafTable, }} } func verifyLeafTable(e *rsEnv) error { steps := []struct { sql string want []string }{ {"", nil}, {"DELETE FROM leaf WHERE rid=(SELECT rid FROM blob WHERE uuid='%[1]s')", []string{"b1"}}, {"INSERT INTO leaf(rid) SELECT rid FROM blob WHERE uuid='%[2]s'", []string{"b1", "c1"}}, } for _, s := range steps { if s.sql != "" { if err := e.goExec(fmt.Sprintf(s.sql, e.script.hashes["b1"], e.script.hashes["c1"])); err != nil { return err } } got, err := verifyLeafIssues(e.goPath, e.script.labels) if err != nil { return err } if !slices.Equal(got, s.want) { return expectf("after %q: Verify leaf issues %v, want %v", s.sql, got, s.want) } } return nil } // goExec runs one statement against the go-libfossil repository. func (e *rsEnv) goExec(query string) error { r, err := repo.Open(e.goPath) if err != nil { return err } defer r.Close() if _, err := r.DB().Exec(query); err != nil { return fmt.Errorf("%s: %w", query, err) } return nil }