feat: add test selection rules#19
Merged
Merged
Conversation
Append sharedTargets to every test entry before impact matching and validate config input.
Add opt-in run-all selection for configured changed-file rules. Short-circuit impact analysis before graph and cache work when a matching file changes.
Prevents duplicate shared target reasons when per-test and shared targets differ only by path normalization.
Keeps run-all impact output stable when a test map lists the same test more than once.
# Conflicts: # README.md # docs/config.md # src/config/config-schema.ts # src/config/load-config.ts # tests/config.test.ts
This was referenced Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this?
This PR adds two configurable test selection rules for cases the dependency graph cannot express cleanly or would make test maps repetitive.
tests.sharedTargetslets projects declare source targets that apply to every test entry, such as a global setup module.tests.runAllWhenChangedlets projects declare repo-level files, such as lockfiles, that should immediately select every test when changed.How does it work?
Shared targets are appended to each test-map entry before normal impact matching, so Sniffler still builds and traverses the dependency graph. If
src/global.tsimportssrc/some-other.ts, a change tosrc/some-other.tscan select every test through the sharedsrc/global.tstarget.Run-all rules are checked right after config loading and changed-file resolution. When a changed file matches an exact path or glob in
tests.runAllWhenChanged, Sniffler loads only the test map and returns every unique test with a run-all reason, skipping workspace discovery, TSConfig loading, cache work, source discovery, scanning, graph build, and traversal.Benchmark on the combined branch:
shared-root [1441 files]mean 14.6053ms,deep-branch [1441 files]mean 10.6416ms.Why is this useful?
Projects can model global setup and repo-level invalidation without duplicating targets across every test-map entry. Lockfile-style changes get a cheap short-circuit path, while graph-visible global setup files still benefit from normal dependency analysis and precise reasoning.