Skip to content

Test-only speedup: Shave 2 mins off test runtime#1219

Merged
computermode merged 3 commits into
mainfrom
test-speedups
May 15, 2026
Merged

Test-only speedup: Shave 2 mins off test runtime#1219
computermode merged 3 commits into
mainfrom
test-speedups

Conversation

@computermode
Copy link
Copy Markdown
Contributor

@computermode computermode commented May 14, 2026

https://entire.io/gh/entireio/cli/trails/382

Removes t.Parallel() in two slow tests in favor of t.Chdir(...).

For these two tests specifically, the working directory mattered because the code under test shells out to git without -C . The tests create temp repos, but without t.Chdir(tempRepo), those fallback git calls run from the real project checkout, hit its partial-clone promisor remotes, and burned about a minute.

Before:

➜  cli git:(main) ✗ go test -run '^TestV2ReadSessionMetadata_FetchesMissingMetadataBlob$' -v -count=1 ./cmd/entire/cli/checkpoint
=== RUN   TestV2ReadSessionMetadata_FetchesMissingMetadataBlob
=== PAUSE TestV2ReadSessionMetadata_FetchesMissingMetadataBlob
=== CONT  TestV2ReadSessionMetadata_FetchesMissingMetadataBlob
2026/05/14 15:54:01 WARN FetchingTree.readFileViaGit: cat-file failed path=metadata.json hash=7fbc2440559c error="exit status 128"
--- PASS: TestV2ReadSessionMetadata_FetchesMissingMetadataBlob (58.68s)
PASS
ok  	github.com/entireio/cli/cmd/entire/cli/checkpoint	59.071s

After:

➜  cli git:(test-speedups) ✗ go test -run '^TestV2ReadSessionMetadata_FetchesMissingMetadataBlob$' -v -count=1 ./cmd/entire/cli/checkpoint
=== RUN   TestV2ReadSessionMetadata_FetchesMissingMetadataBlob
2026/05/14 15:52:33 WARN FetchingTree.readFileViaGit: cat-file failed path=metadata.json hash=28e8b85d8618 error="exit status 128"
--- PASS: TestV2ReadSessionMetadata_FetchesMissingMetadataBlob (0.15s)
PASS
ok  	github.com/entireio/cli/cmd/entire/cli/checkpoint	0.554s

Before:

➜  cli git:(main) ✗ go test -run '^TestCheckV2CheckpointCounts_ReturnsErrorForCorruptRef$' -v -count=1 ./cmd/entire/cli
=== RUN   TestCheckV2CheckpointCounts_ReturnsErrorForCorruptRef
=== PAUSE TestCheckV2CheckpointCounts_ReturnsErrorForCorruptRef
=== CONT  TestCheckV2CheckpointCounts_ReturnsErrorForCorruptRef
--- PASS: TestCheckV2CheckpointCounts_ReturnsErrorForCorruptRef (62.24s)
PASS
ok  	github.com/entireio/cli/cmd/entire/cli	62.754s

After:

➜  cli git:(test-speedups) ✗ go test -run '^TestCheckV2CheckpointCounts_ReturnsErrorForCorruptRef$' -v -count=1 ./cmd/entire/cli
=== RUN   TestCheckV2CheckpointCounts_ReturnsErrorForCorruptRef
--- PASS: TestCheckV2CheckpointCounts_ReturnsErrorForCorruptRef (0.05s)
PASS
ok  	github.com/entireio/cli/cmd/entire/cli	0.520s

Note

Low Risk
Test-only changes that adjust working-directory and parallelism; low functional risk but could slightly reduce overall test concurrency.

Overview
Speeds up two previously slow tests by removing t.Parallel() and explicitly t.Chdir(...) into the temp repo root so any shell-outs to git run against the intended fixture repo.

This avoids accidental interaction with the developer checkout (e.g., partial-clone promisor remotes) and keeps the tests focused on corrupt/missing-object scenarios (TestV2ReadSessionMetadata_FetchesMissingMetadataBlob and TestCheckV2CheckpointCounts_ReturnsErrorForCorruptRef).

Reviewed by Cursor Bugbot for commit d5b684d. Configure here.

@computermode computermode requested a review from a team as a code owner May 14, 2026 22:58
Copilot AI review requested due to automatic review settings May 14, 2026 22:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes t.Parallel() in two slow tests and adds t.Chdir(...) so that git subprocesses invoked by the code under test run inside the test's temp repo rather than the project checkout, eliminating expensive promisor remote fetches.

Changes:

  • Replaces t.Parallel() with t.Chdir(dir) in TestCheckV2CheckpointCounts_ReturnsErrorForCorruptRef.
  • Replaces t.Parallel() with t.Chdir(repoRoot) in TestV2ReadSessionMetadata_FetchesMissingMetadataBlob.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cmd/entire/cli/doctor_test.go Drops parallelism, chdirs into the temp repo to avoid stray git calls hitting the real repo.
cmd/entire/cli/checkpoint/v2_read_test.go Same treatment for the missing-metadata-blob fetch test.

@computermode computermode enabled auto-merge May 14, 2026 23:04
@computermode computermode merged commit 11da3db into main May 15, 2026
9 checks passed
@computermode computermode deleted the test-speedups branch May 15, 2026 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants