r/softwaredevelopment • u/Emergency-Tutor-7 • 1d ago
A fail-closed test gate: exit code 0 is not enough, it wants positive test-pass evidence
Repo: https://github.com/Furox-Art/polyglot-code-guard - 0.5.0, pip name polyglot-code-guard, the command is polyguard.
It discovers which project type is in front of it, looks for a test suite, runs the build/test plan, and prints one word: PASS or FAIL. The part that matters is what counts as a pass. A zero exit code is not enough: it parses the runner's own output for a positive test-execution summary - pytest's passed-line, cargo test result blocks, Go test events in the JSON stream, JUnit/Surefire/TRX counters, Swift Testing or XCTest summaries, CTest per-test Passed records. Missing tests, a missing toolchain, invalid config, a timeout, or no positive evidence all return FAIL. A project-defined npm test script is never accepted as evidence.
Built-in plans cover eleven language identifiers: Python, Rust, Go, JavaScript/TypeScript, Java, C#, PHP, Ruby, Swift, C and C++. Monorepos get discovered recursively - Maven modules, Gradle includes, Cargo workspaces, npm workspaces, .sln - and each aggregator is delegated to its native workspace command once instead of being run twice, with every independently found package reported separately.
Install:
python -m pip install --upgrade polyglot-code-guard
polyguard verifyExit 0 for PASS, 1 for FAIL. Captured output is capped at the final 256 KiB per command, and on timeout it kills the process tree so test-runner children do not survive.
One honest limit: PASS means the built-in plan succeeded and positive test-pass evidence was recognised, not that the code is correct or that coverage is adequate. And because it runs your build scripts and package managers, an untrusted repository belongs in a disposable container - polyguard provides no operating-system isolation itself.
1
u/Discordbothost 1d ago
The workspace case seems worth exposing in the report. If a filter change takes one package from 80 tests to zero while a sibling still runs tests, the workspace can look healthy. Would you consider reporting counts per member where the runner provides them? A drop warning could be useful even when the overall gate passes.