From 1382c2efd5f3e50932ba9ec603b1f1981bc5afd4 Mon Sep 17 00:00:00 2001 From: achmad Date: Thu, 14 May 2026 21:02:45 +0700 Subject: [PATCH] fix: silent default test output; verbose controlled by SOURCETEST_VERBOSE env var go test -json implicitly sets testing.Verbose()=true, so the old guard always printed manga lists through the script. Switched to an env var (SOURCETEST_VERBOSE=1) set by the script only when -v is passed. --- internal/sourcetest/sourcetest.go | 7 +++++-- scripts/test-sources.sh | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/internal/sourcetest/sourcetest.go b/internal/sourcetest/sourcetest.go index 93c577c..766d7db 100644 --- a/internal/sourcetest/sourcetest.go +++ b/internal/sourcetest/sourcetest.go @@ -3,11 +3,14 @@ package sourcetest import ( + "os" "testing" "goyomi/internal/source" ) +var verboseOutput = os.Getenv("SOURCETEST_VERBOSE") == "1" + // Run verifies source metadata and, unless -short is set, calls GetPopularManga // and GetLatestUpdates (when supported) against the live site. func Run(t *testing.T, s source.CatalogueSource, wantName, wantLang string) { @@ -39,7 +42,7 @@ func Run(t *testing.T, s source.CatalogueSource, wantName, wantLang string) { if len(page.Mangas) == 0 { t.Fatal("GetPopularManga returned 0 results") } - if testing.Verbose() { + if verboseOutput { t.Logf("--- GetPopularManga (%d results) ---", len(page.Mangas)) for i, m := range page.Mangas { t.Logf(" [%d] %-60s %s", i, m.Title, m.URL) @@ -67,7 +70,7 @@ func Run(t *testing.T, s source.CatalogueSource, wantName, wantLang string) { if len(page.Mangas) == 0 { t.Fatal("GetLatestUpdates returned 0 results") } - if testing.Verbose() { + if verboseOutput { t.Logf("--- GetLatestUpdates (%d results) ---", len(page.Mangas)) for i, m := range page.Mangas { t.Logf(" [%d] %-60s %s", i, m.Title, m.URL) diff --git a/scripts/test-sources.sh b/scripts/test-sources.sh index 547ade9..0ec7a63 100755 --- a/scripts/test-sources.sh +++ b/scripts/test-sources.sh @@ -232,11 +232,12 @@ ok "Network $NETWORK exists" SHORT_FLAG="" VERBOSE_FLAG="" +VERBOSE_ENV="" FLAGS="" while [ $# -gt 0 ]; do case "$1" in -short) SHORT_FLAG="-short"; FLAGS="$FLAGS -short"; shift ;; - -v) VERBOSE_FLAG="-v"; FLAGS="$FLAGS -v"; shift ;; + -v) VERBOSE_FLAG="-v"; FLAGS="$FLAGS -v"; VERBOSE_ENV="-e SOURCETEST_VERBOSE=1"; shift ;; *) break ;; esac done @@ -262,6 +263,7 @@ set +e docker run --rm \ --network "$NETWORK" \ -e FLARESOLVERR_URL=http://flaresolverr:8191 \ + $VERBOSE_ENV \ -v "$REPO_ROOT":/workspace \ -v goyomi_go_mod_cache:/go/pkg/mod \ -v goyomi_go_build_cache:/root/.cache/go-build \