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.
This commit is contained in:
achmad
2026-05-14 21:02:45 +07:00
parent c2f8c1f0f1
commit 1382c2efd5
2 changed files with 8 additions and 3 deletions
+5 -2
View File
@@ -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)
+3 -1
View File
@@ -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 \