Skip to content

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

Merged
haugoug merged 1 commit intogvsoc:mainfrom
germainh512:fix/target-filtering
Mar 15, 2026
Merged

fix: Skip untargeted tests when --target is specified#23
haugoug merged 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.

@germainh512 germainh512 force-pushed the fix/target-filtering branch from 337842b to 855422c Compare March 14, 2026 21:31
Two issues fixed:

1. When --target is specified, untargeted tests (from testsets
   without a targets section in gvtest.yaml) were still running.
   Now they are silently excluded at enqueue time by checking
   the _is_fallback flag on the target.

2. When multiple --target values are specified and they come
   from different gvtest.yaml files in different sub-directories,
   only targets from the first matching yaml were discovered.

   Root cause: import_testset() only fanned out to a sub-testset's
   targets if the parent's target matched the sub's targets.
   When targets come from different scopes (e.g. root has spatz,
   sub has pulp-open), the parent's spatz didn't match the sub's
   pulp-open, so the sub was skipped.

   Fix: sub-testsets with their own targets section always fan out
   independently of the parent's target. A _fanned_out set on the
   runner prevents duplication when multiple parent targets import
   the same sub-testset.

Behavior:
- gvtest --target X: runs only tests with target X
- gvtest --target X --target Y: runs tests for both, even if
  X and Y come from different gvtest.yaml files
- gvtest (no --target): runs everything

Added 6 tests covering all target filtering scenarios.
@germainh512 germainh512 force-pushed the fix/target-filtering branch from 855422c to 00355ac Compare March 15, 2026 20:18
@haugoug haugoug merged commit e39681e into gvsoc:main Mar 15, 2026
3 checks passed
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