From 02a3514457e2dd665ca6377f1b5912bc4570faa9 Mon Sep 17 00:00:00 2001 From: tannevaled Date: Mon, 21 Sep 2026 13:26:26 +0200 Subject: [PATCH] test: install qpdf so the independent oracle actually runs TestObjectStreamsQPDF is described in its own comment as "a second, independent oracle when it is installed": qpdf must find no syntax or stream encoding error, and its cross-reference must list every link annotation as compressed and every stream as not. It had never run. The test skips when qpdf is absent and the lane installs nothing, so the only check a stranger performs on what this package emits skipped on every push, under a green lane and a gate asserting exactly 100% statement coverage. Both numbers were honest. Coverage counts lines that executed, and the object-stream writer executes under the other tests too. What a coverage gate cannot express is that the one test comparing our output against another implementation did nothing. Install qpdf in the lane, and set PDFKIT_REQUIRE_QPDF=1 so that "qpdf not installed" is a failure there rather than a skip. Verified both ways on this machine, which has qpdf 12.4.1: PDFKIT_REQUIRE_QPDF=1 go test -run TestObjectStreamsQPDF --- PASS PATH=/usr/bin:/bin, flag still set --- FAIL Found with judgescan, which reports repositories whose tests look for a tool their CI never installs: 29 of the 134 that name one. Co-Authored-By: Claude Opus 5 --- .github/workflows/ci.yml | 8 ++++++++ objstm_test.go | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d999a11..7de8c32 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,10 +26,18 @@ jobs: check-latest: true cache: true + # qpdf is a second, independent oracle: it reads back what we wrote and + # says whether it is well formed. Without it TestObjectStreamsQPDF skips + # and the lane is green over the one test a stranger performs. + - name: qpdf, the independent oracle for what we write + run: sudo apt-get update -qq && sudo apt-get install -y -qq qpdf + - name: go vet run: go vet ./... - name: Test with coverage + env: + PDFKIT_REQUIRE_QPDF: "1" run: go test -covermode=set -coverprofile=coverage.out ./... - name: Assert exact 100% statement coverage diff --git a/objstm_test.go b/objstm_test.go index 387da05..7276d73 100644 --- a/objstm_test.go +++ b/objstm_test.go @@ -343,6 +343,12 @@ func TestObjectStreamsRichDocument(t *testing.T) { func TestObjectStreamsQPDF(t *testing.T) { qpdf, err := exec.LookPath("qpdf") if err != nil { + // A skipped oracle reads exactly like a passing one. The lane that + // installs qpdf sets this, so its absence there is a broken lane and + // not a reason to go quietly green. + if os.Getenv("PDFKIT_REQUIRE_QPDF") != "" { + t.Fatalf("PDFKIT_REQUIRE_QPDF is set but qpdf is not installed: %v", err) + } t.Skip("qpdf not installed") } dir := t.TempDir()