Skip to content

fix: Skip untargeted tests when --target is specified#23

Open
germainh512 wants to merge 1 commit intogvsoc:mainfrom
germainh512:fix/target-filtering
Open

fix: Skip untargeted tests when --target is specified#23
germainh512 wants to merge 1 commit intogvsoc:mainfrom
germainh512:fix/target-filtering

Conversation

@germainh512
Copy link

Problem

When --target X is specified on the CLI, tests without any target definition (no targets: in their gvtest.yaml) still run with the default target. This means gvtest --target X runs both targeted tests for X and all untargeted tests, which is not the expected behavior.

Expected Behavior

  • gvtest --target X → runs only tests belonging to target X
  • gvtest (no --target) → runs everything (targeted + untargeted)

Fix

Two changes in the testset loading path:

  1. Runner.add_testset(): When --target is specified and the testset directory has no YAML targets, skip loading it entirely (instead of falling back to the default target).

  2. TestsetImpl.import_testset(): Same logic for sub-testsets — only inherit the parent target if either no --target filter was specified, or the parent already carries a real (non-default) target from higher up.

Tests

Added 4 new tests:

  • test_cli_target_skips_untargeted_tests--target X skips testsets with no targets
  • test_no_cli_target_runs_all — no --target runs untargeted tests
  • test_cli_target_runs_only_matching--target target_a runs only target_a, not target_b
  • test_no_cli_target_runs_all_yaml_targets — no --target runs all YAML targets

All 140 tests pass.

When --target X is given on the CLI, only tests that belong to
a real target (defined in gvtest.yaml) should run. Tests without
any target definition are silently excluded.

The filtering happens at enqueue time in TestCommon.enqueue():
targets resolved from gvtest.yaml are real targets; the fallback
target (used when no gvtest.yaml defines targets) is marked with
_is_fallback=True and filtered out when --target is active.

This approach ensures the full testset hierarchy is still loaded
(so sub-testsets with their own targets are discovered), while
untargeted tests at any level are excluded.

New behavior:
- gvtest --target X: runs only tests with target X from
  gvtest.yaml. Untargeted tests are silently excluded.
- gvtest (no --target): runs everything.

Added 5 tests covering target filtering behavior.
@germainh512 germainh512 force-pushed the fix/target-filtering branch from 337842b to 855422c Compare March 14, 2026 21:31
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.

2 participants