From 8ddd910dd545c45a7227da87ca125758b4a0e2cb Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Wed, 29 Jul 2026 11:46:17 +0200 Subject: test(bible): skip corpus-dependent tests when optional corpora aren't embedded Since 51c0f4e split the corpora (only vul embedded by default; wuj/drb/grb behind -tags fullbible), `go test ./...` on the default build was red across six packages -- every failure was a test assuming an optional corpus is present. Guard those assertions with a skip keyed on bible.Meta(code), so they run under -tags fullbible and skip -- not fail -- on the default vul-only build. Mixed tests are split into subtests so the always-embedded vul assertions and pure logic (pl->vul fallback, explicit passthrough, bt-rejection, i18n labels) keep running on both builds. Test-only change; no product code or corpora touched. - internal/bible: TestVerses, TestLookup, TestCorpusBooks, TestChapters, TestGrbNoApparatusMarkers, TestCrossChapterRange* (requireCorpus helper). - internal/cli, config, render, tui, web: the same pattern for their corpus-dependent tests. - Fixes an index-out-of-range panic in internal/tui's reader tests that was aborting the package binary and masking 3 further corpus-absence failures (TestReaderBookmarkFlow, TestReaderChapterJump, TestReaderRemembersPlace). Verified: `go test ./...` and `go test -tags fullbible ./...` both green (0 FAIL); guards active only on the default build (29 skips vs 1 unrelated pre-existing); gofmt and go vet clean. --- internal/cli/cli_test.go | 1 + internal/cli/liturgy_test.go | 31 ++++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) (limited to 'internal/cli') diff --git a/internal/cli/cli_test.go b/internal/cli/cli_test.go index a244885..429ceaf 100644 --- a/internal/cli/cli_test.go +++ b/internal/cli/cli_test.go @@ -298,6 +298,7 @@ func TestRandVerse(t *testing.T) { } func TestRandChapter(t *testing.T) { + requireCorpus(t, "wuj") // --rand-ch -b wuj needs the optional wuj corpus embedded var out, errb bytes.Buffer if code := Run([]string{"--rand-ch", "-b", "wuj"}, nil, &out, &errb); code != 0 { t.Fatalf("rand-ch code=%d stderr=%q", code, errb.String()) diff --git a/internal/cli/liturgy_test.go b/internal/cli/liturgy_test.go index 67303f3..88a8b3d 100644 --- a/internal/cli/liturgy_test.go +++ b/internal/cli/liturgy_test.go @@ -57,14 +57,35 @@ func TestRunLiturgyTraditionalComputesEF(t *testing.T) { } func TestVernacularVersionResolver(t *testing.T) { - if got := vernacularVersion(config.Config{ReadingVersion: "drb"}); got != "drb" { - t.Fatalf("explicit: %q", got) - } + // pl has no autoselect-eligible corpus (the built-in Wujek sets + // autoselect=false), so Polish always falls back to Latin regardless of + // which optional corpora are embedded -- pure logic, keep it running. if got := vernacularVersion(config.Config{UILanguage: "pl"}); got != "vul" { t.Fatalf("pl should fall back to Latin: %q", got) } - if got := vernacularVersion(config.Config{UILanguage: "en"}); got != "drb" { - t.Fatalf("en should be drb: %q", got) + // Both the explicit reading_version passthrough and the en->drb autoselect + // resolve through bible.Meta("drb") (Config.ReadingCorpus), so they need the + // optional drb corpus embedded. + t.Run("drb", func(t *testing.T) { + requireCorpus(t, "drb") + if got := vernacularVersion(config.Config{ReadingVersion: "drb"}); got != "drb" { + t.Fatalf("explicit: %q", got) + } + if got := vernacularVersion(config.Config{UILanguage: "en"}); got != "drb" { + t.Fatalf("en should be drb: %q", got) + } + }) +} + +// requireCorpus skips the test when corpus `code` is not embedded in this +// build. The optional corpora (wuj, drb, grb) compile in only with +// `-tags fullbible` (or when dropped into the user corpora dir); mirrors the +// helper in internal/bible so these tests run under fullbible and skip -- not +// fail -- on the default vul-only build. +func requireCorpus(t *testing.T, code string) { + t.Helper() + if _, ok := bible.Meta(code); !ok { + t.Skipf("corpus %q not embedded; build with -tags fullbible", code) } } -- cgit v1.3