#3165

Print the active section/generator selection

OpenShivaPriyanShanmugawants to merge intofrom

Description

When a section/generator selection (-c/--section, -g/--generator-index, or -p/--path-filter) is in effect, the console and compact reporters now print the active path filters on a Path filters: line, right below the existing Filters: line and using the same highlight colour:

Filters: "foo"
Path filters: c:"A" g:0

Section filters are serialized as c:"<filter>" and generator filters as g:<filter>, mirroring the -p/--path-filter syntax. The line is only printed when path filters are present, so default runs are unaffected.

The motivation: Catch2 currently gives no feedback about what was actually selected, which makes it hard to tell what went wrong when a filter combination ends up running no assertions, e.g.:

Filters: "Scenario: Create and train model on entire dataset"
Randomness seeded to: 3221299838
===============================================================================
test cases: 1 | 1 passed
assertions: - none -

Implementation notes:

  • Added a serializePathFilters() helper in catch_reporter_helpers, alongside the existing serializeFilters().
  • Wired it into ConsoleReporter::testRunStarting and CompactReporter::testRunStarting.
  • Documented the printout in docs/filtering-execution-path.md.
  • Tests: a unit test for serializePathFilters (format + ordering) and two CTest integration tests verifying both reporters emit the line. Baselines were updated to account for the new self-test case.

Structured reporters (XML/JSON/JUnit/TAP/SonarQube) are intentionally left out of scope; this could be a follow-up if desired.

GitHub Issues

Implements the request in #3099.

Activity

4
codecov[bot]4mo ago

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 91.21%. Comparing base (0809213) to head (3b96584).

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #3165      +/-   ##
==========================================
+ Coverage   91.18%   91.21%   +0.03%     
==========================================
  Files         205      205              
  Lines        9101     9121      +20     
==========================================
+ Hits         8298     8319      +21     
+ Misses        803      802       -1     
:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
rajpratham1approved changes3mo ago
rajpratham13mo ago

Nice usability improvement. Printing the active section/generator path filters makes it much easier to understand why a filtered run produced a particular result, especially when no assertions execute. I also like that the formatting logic is centralized in serializePathFilters and backed by both unit and integration tests. The documentation and baseline updates look comprehensive as well. LGTM.

ShivaPriyanShanmuga7d ago

Rebased onto latest devel and resolved the conflicts. Could you approve the CI workflows and take a look when you get a chance? Thanks!