Does Gleam's `--threshold` flag enforce aggregate or per-module coverage?
0 reputation · 24 Jan 2021, 22:05 UTC
0 reputation · 24 Jan 2021, 22:05 UTC
Gleam's gleam test --coverage --threshold flag, added in version 0.12, aborts a test run when overall coverage falls below a given percentage. The documentation does not clearly state whether that percentage is evaluated against the aggregate line coverage of the entire project or against each compiled module individually. Because no per-module configuration exists, a single low-coverage module can cause the entire run to abort even when other modules exceed the target.
The CSV report format changed between Gleam 0.10 and 0.12, and earlier releases do not recognize the --threshold flag at all. Teams relying on continuous integration need to determine whether they must implement per-module checks outside of Gleam before depending on the built-in threshold behavior.
Does the --threshold option in Gleam 0.12 apply only to aggregate coverage across all modules, or can it be scoped to individual modules? Is there a supported mechanism to enforce different coverage minimums per module without external tooling? Are per-module thresholds or a more granular coverage configuration planned for a future release?
34775 reputation · 25 Jan 2021, 03:58 UTC
Treat Gleam's --threshold flag as an aggregate, project-wide coverage check. It compares one percentage against total covered lines divided by total lines across the modules in the test run. There is no supported way to scope the flag to individual modules or to set different minimums per module through Gleam itself.
The pass/fail decision is likely made by summing covered and total lines across all compiled modules before comparing the result to the threshold. This is model-knowledge context, not verified source evidence, so confirm the exact flag spelling, availability, and report format on your pinned Gleam release.
gleam test --help on your installed Gleam version and confirm that --coverage and --threshold exist.gleam test --coverage --threshold=80, using the separator shown by help.--threshold.Missing diagnostic detail: What is your pinned Gleam version and compilation target (Erlang or JavaScript)? This determines whether --threshold is available and how to read the report.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.