Artifact af8aee82948e25b2194fb8918f3a87138f9dc1e4fcd9d33cf9731b22198772aa:
- File
internal/manifest/fossilbin_test.go
— part of check-in
[f804878bd3]
at
2026-07-22 23:58:46
on branch trunk
— test: route every fossil-binary gate through one REQUIRE_FOSSIL_BIN helper (#125)
* test: route fossil-binary tests through one REQUIRE_FOSSIL_BIN helper
REQUIRE_FOSSIL_BIN=1 turns a missing fossil binary into a test failure instead of an invisible skip, but only internal/manifest honored it. The six other fossil-dependent sites each did their own exec.LookPath + unconditional t.Skip, so on those a run with no fossil was byte-identical to a passing one.
Add testutil.RequireFossilBin, which resolves the binary the same way FossilBinary does (FOSSIL_BIN override, then PATH) and either skips or fails based on REQUIRE_FOSSIL_BIN. Route testutil.NewTestRepo, both internal/delta CLI round-trips, the four internal/merge validation tests, the internal/xfer sanity check, and the ls-branch-tip repro through it, deleting their bespoke lookup+skip logic. CI already sets REQUIRE_FOSSIL_BIN=1 on the unit-test steps, so this makes all seven sites fail loud on absence while local runs without fossil stay opt-in.
* test: route every fossil-binary gate through RequireFossilBin
The first pass left six sites still deciding for themselves whether a missing fossil binary is a skip or a failure. Three of them (internal/sync's startFossilServer and its two integration tests, manifest's two rebuild tests, the root TestPhaseB_Integration, and hash's TestSHA1_FossilValidation) skipped unconditionally, so with REQUIRE_FOSSIL_BIN=1 and no fossil on PATH those packages still reported ok -- the exact silent pass the flag exists to prevent. The other three had hand-rolled copies of the flag check, which is the duplication that let the original drift happen.
All of them now call testutil.RequireFossilBin, and HasFossil is gone: it was a second, skip-only way to ask the same question, and it is what produced the sites that ignored the flag.
Also validate the FOSSIL_BIN override with LookPath, so a stale path reports "fossil not found" instead of surfacing later as a raw fork/exec error.
* test: resolve fossil binary via RequireFossilBin at remaining call sites
* fix: correct stale module path missed by rebase auto-merge
Three imports added by earlier commits in this branch predated the rebase target and had no corresponding line on main to conflict against, so git's auto-merge carried the old module path through verbatim. (user: [email protected], size: 2222) [annotate] [blame] [check-ins using]
package manifest import ( "os/exec" "path/filepath" "strings" "testing" "github.com/danmestas/go-libfossil/internal/repo" "github.com/danmestas/go-libfossil/simio" "github.com/danmestas/go-libfossil/testutil" ) // TestFossilBinaryReadsDeltifiedRepo is the acceptance check that our own // tests cannot provide: a repository we wrote, with delta chains produced by // the commit path, must be readable by canonical Fossil. `fossil rebuild` // re-derives every table from the blob content, so it expands every artifact // and re-verifies each against its UUID -- if any delta we wrote were // malformed or linked wrongly, it fails there. func TestFossilBinaryReadsDeltifiedRepo(t *testing.T) { bin := testutil.RequireFossilBin(t) path := filepath.Join(t.TempDir(), "deltified.fossil") r, err := repo.Create(path, "testuser", simio.CryptoRand{}, "") if err != nil { t.Fatalf("repo.Create: %v", err) } incrementalHistory(t, r, 4, 12, 400) s := collectStorageStats(t, r) if s.deltaEncoded == 0 { t.Fatal("no deltas were produced; this test would prove nothing") } if err := r.Close(); err != nil { t.Fatalf("repo.Close: %v", err) } run := func(args ...string) string { t.Helper() out, err := exec.Command(bin, args...).CombinedOutput() t.Logf("fossil %s:\n%s", strings.Join(args, " "), out) if err != nil { t.Fatalf("fossil %s failed: %v", strings.Join(args, " "), err) } return string(out) } // test-integrity expands every non-phantom blob and compares the result // against its UUID. Run it before rebuild, while the file still holds // exactly the bytes we wrote. integrity := run("test-integrity", "-R", path) if !strings.Contains(integrity, "0 errors") { t.Fatalf("fossil test-integrity did not report 0 errors") } if !strings.Contains(integrity, "low-level database integrity-check: ok") { t.Fatalf("fossil reported a low-level database problem") } // rebuild re-derives every table from blob content, which means walking // each delta chain we produced. It verifies the BLOB table unless // --noverify is given. stats := run("rebuild", path, "--stats") if !strings.Contains(stats, "Artifacts:") { t.Fatalf("fossil rebuild produced no statistics") } }