Skip to content

Fix formatting in quiet mode #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 15, 2025
Merged

Fix formatting in quiet mode #116

merged 5 commits into from
Apr 15, 2025

Conversation

pks-t
Copy link
Member

@pks-t pks-t commented Mar 27, 2025

The quiet mode activated via "-q" is quite broken:

  • We print all failures twice with clap formatting, so we effectively increase verbosity.
  • We don't print individual test status indicators ("...FF..F"), but print the legend to explain what the symbols mean.
  • We don't print any "ok/not ok" lines at all with TAP formatting, which breaks the specification.

This PR fixes all of those issues.

pks-t added 5 commits March 27, 2025 12:31
The clar understands both "-v" and "-q". Both of these arguments
effectively increase or decrease verbosity, but right now their
respective effects are somewhat different from one another. While "-v"
makes us print more information, "-q" only skips over successful tests
without modifying the verbosity itself.

This behaviour is somewhat inconsistent and confusing, and the resulting
implementation is more complex than it really ought to be. This is
demonstrated by the fact that we have several bugs when it comes to the
verbosity, all of which seem to be consequences of this complexity.

Refactor the code so that we only have a single "verbosity". "-v"
increases verbosity, whereas "-q" decreases verbosity. When verbosity is
negative, we start to reduce our verbosity, whereas positive values will
start to increase our verbosity.

This refactoring is a first step towards improving quiet output over the
next couple of commits.
The "-q" option is supposed to decrease verbosity. Funny enough though
the end result is that we have _increased_ verbosity because we now end
up printing every failing test twice: once via `clar_report_errors()`,
and once via `clar_report_all()` via `clar_print_clap_shutdown()`.

Fix this by dropping the call to `clar_report_errors()` so that failing
tests will only be printed on shutdown.
Both `clar_print_ontest()` and `clar_print_onsuite()` are only called
when we aren't asked to be quiet. This results in buggy behaviour
though, where we for example don't print tests at all with the TAP
format, which is invalid.

Refactor the code so that the format implementations themselves can
decide whether or not to skip writing output based on verbosity. For now
the behaviour remains the same, but we will iterate on the respective
formats over the next couple of commits.
The TAP format we print when asked to be quiet is broken because we
don't the "ok/not ok" line for any of the individual tests. This does
not follow the specification and would thus confuse parsers.

Fix the issue by printing tests even when asked to be quiet. To have the
"-q" flag still have an effect we instead skip the reason why the test
has failed.
When asked to be quiet we don't print the status for each of the
individual tests (the "...FF..F" indicator). But we still end up
printing the legend explaining what each of the indicator means as well
as how many test suites we have loaded, both of which feel unnecessarily
verbose.

Stop printing this information in quiet mode. The end result is that we
only end up printing failures, but nothing else.
@pks-t
Copy link
Member Author

pks-t commented Apr 15, 2025

Merging, as this has been open for review for a couple weeks by now.

@pks-t pks-t merged commit 4c9fa6d into clar-test:main Apr 15, 2025
6 checks passed
@pks-t pks-t deleted the pks-fix-quiet branch April 15, 2025 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant