Skip to content

test: use FakeRepository for dynamic-repo cache tests#5003

Draft
arturcic wants to merge 1 commit into
GitTools:mainfrom
arturcic:fix/cache-tests-fakerepo
Draft

test: use FakeRepository for dynamic-repo cache tests#5003
arturcic wants to merge 1 commit into
GitTools:mainfrom
arturcic:fix/cache-tests-fakerepo

Conversation

@arturcic

Copy link
Copy Markdown
Member

Problem

Local timing of GitVersion.Core.Tests (net10.0) showed the suite's two slowest tests by far live in GitVersionExecutorTests:

  • CacheKeySameAfterReNormalizing~115s
  • CacheKeyForWorktree~66s

Both set TargetUrl = https://github.com/GitTools/GitVersion.git and call preparer.Prepare(), which clones the entire GitVersion repo over the network (twice, in the re-normalizing test). That's ~180s of network-bound work and a flaky external dependency on the size/availability of the main repo.

Change

Point the dynamic-repository cache tests at the small, stable GitTools/FakeRepository instead, and hoist the URL and branch into single TargetUrl / TargetBranch constants (FakeRepository's default branch is master, not main). DynamicRepositoryTests is left untouched — it asserts GitVersion-specific versions and must keep cloning the real repo.

Result

GitVersionExecutorTests: ~184s → ~4s (23 tests, all passing on net10.0), with the network/flakiness removed. Behaviour is unchanged — the tests only assert cache-key stability / non-emptiness, which is repo-agnostic.

Build 0/0, dotnet format clean.

🤖 Generated with Claude Code

Replace the heavy https://github.com/GitTools/GitVersion.git clone target
in GitVersionExecutorTests with the small, stable GitTools/FakeRepository,
and hoist the URL and branch into single TargetUrl/TargetBranch constants.
Cuts the suite's two slowest tests (CacheKeySameAfterReNormalizing ~115s,
CacheKeyForWorktree ~66s) so GitVersionExecutorTests drops from ~184s to
~4s, and removes the flaky dependency on cloning the full GitVersion repo.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@arturcic arturcic marked this pull request as draft June 30, 2026 15:28
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