Skip to content

feat: add test selection rules#19

Merged
V3RON merged 6 commits into
masterfrom
feat/test-selection-rules
Jun 26, 2026
Merged

feat: add test selection rules#19
V3RON merged 6 commits into
masterfrom
feat/test-selection-rules

Conversation

@V3RON

@V3RON V3RON commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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.sharedTargets lets projects declare source targets that apply to every test entry, such as a global setup module. tests.runAllWhenChanged lets 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.ts imports src/some-other.ts, a change to src/some-other.ts can select every test through the shared src/global.ts target.

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.

V3RON added 6 commits June 26, 2026 10:00
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
@V3RON V3RON merged commit 755b7c8 into master Jun 26, 2026
6 checks passed
@V3RON V3RON deleted the feat/test-selection-rules branch June 26, 2026 09:24
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