Skip to content

feat(cli): --changed to run only the tests touched since a git ref - #1038

Merged
Chemaclass merged 1 commit into
mainfrom
feat/1010-changed-run-only-tests-touched-since-git-ref
Aug 10, 2026
Merged

feat(cli): --changed to run only the tests touched since a git ref#1038
Chemaclass merged 1 commit into
mainfrom
feat/1010-changed-run-only-tests-touched-since-git-ref

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #1010

The fastest feedback loop on a large suite is "run only what my branch touched", and bashunit could not express it. --rerun-failed needs a previous red run, and a hand-rolled git diff | xargs ./bashunit breaks on renames, deletions and quoting.

💡 Changes

  • --changed [<ref>] selects only the test files git reports as touched since the ref, defaulting to origin/HEAD and falling back to HEAD.
  • Committed, staged, unstaged and untracked changes all count. Deletions are dropped so a removed file never reaches discovery, and a rename selects its new path alone.
  • An empty selection reports No tests found and exits 1, matching an empty shard, instead of the "path is required" help dump.
  • Outside a git work tree, or with a ref that does not resolve, the run fails with a clear message rather than quietly selecting nothing.

Selects test files from git instead of from a previous red run, so the
fast loop works on the first run of a fresh branch.

The selection merges three sources, because none of them sees the
others: the commit range <ref>...HEAD, the staged and unstaged edits on
top of HEAD, and untracked new files. Deletions are dropped so a removed
test file never reaches discovery, and rename detection selects the new
path alone.

Narrowing happens in exec_tests next to the shard split, after the "at
least one path" guard: reaching zero files there is a real answer, so
the run reports "No tests found" and exits 1 rather than dumping the
help text. Outside a work tree, or with a ref that does not resolve,
validate_config_or_exit fails the run instead of silently selecting
nothing.

Closes #1010
@Chemaclass Chemaclass added the enhancement New feature or request label Aug 10, 2026
@Chemaclass Chemaclass self-assigned this Aug 10, 2026
@Chemaclass
Chemaclass merged commit e8548c2 into main Aug 10, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the feat/1010-changed-run-only-tests-touched-since-git-ref branch August 10, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant