r/devtools • • 3d ago

Polyguard: fail-closed test verification across ten languages, because exit code 0 is not evidence

Repo: https://github.com/Furox-Art/polyglot-code-guard - PyPI polyglot-code-guard 0.5.0, Python 3.11+. Command: polyguard verify.

It discovers the project types in a repo, checks that a test suite exists, runs the relevant build and test commands, and prints one word: PASS or FAIL.

The design decision that matters: a zero exit code is not evidence. Polyguard also requires a positive test-success summary parsed from a recognized runner output format. A zero-test run fails. An all-skipped suite fails. Output with no recognized summary fails. Inconsistent report counters fail. A stale native report fails.

Covered today: Python (compileall + pytest), Rust (cargo test), Go (go test -json), JavaScript and TypeScript (Vitest/Jest/Mocha/TAP when declared, otherwise node --test with the file list taken from a pre-execution snapshot), Java (Maven/Gradle JUnit XML), C# (TRX counters), PHP (PHPUnit --log-junit), Ruby (RSpec/Minitest), Swift (swift test summary), C (CMake + CTest per-test records).

How it was built: each language's evidence requirement is a parser for that runner's own report format, not a guess from the exit code. When a project declares a runner, that runner's CLI is invoked and its summary parsed. TypeScript additionally runs tsc --noEmit when configured, but type checking is not substituted for running tests.

One honest limit: this verifies test execution, not correctness. Green tests on a wrong implementation pass, and a project whose runner emits a report format Polyguard does not recognize fails closed - annoying, and the intended behaviour.

1 Upvotes

0 comments sorted by