Skip to content

Keep the unit tests from depending on the machine they run on - #620

Merged
hannesa2 merged 2 commits into
masterfrom
fix-amend-test-launching-git
Sep 13, 2026
Merged

hannesa2 merged 2 commits into
masterfrom
fix-amend-test-launching-git

Conversation

@goneng

@goneng goneng commented Sep 13, 2026 •

Copy link
Copy Markdown
Collaborator

master is red on arm64 since #601 merged, and the cause came in with #599.
x86_64 passes, so it shows up on one architecture at a time.

Classes/Util/PBTask.m:43: error: -[PBGitIndexDiffCacheTests testAmendingIsAskedForAgain] :
must provide a launch path (NSInvalidArgumentException)

testAmendingIsAskedForAgain sets amend, -setAmend: asks the index to
read itself back, and -refresh launches git through [PBGitBinary path]
rather than through the task output these tests answer for.
When that lookup comes back empty on a runner, PBTask raises instead of running,
and the test fails on an environment detail it never meant to depend on.

The diff cache tests now use an index whose read-back does nothing, which
is what PBGitIndexRefreshTests already does with PBRecordingIndex.

The rest of the sweep

Second commit, after looking for the same kind of dependency elsewhere:

  • PBGitRepositoryFetchArgumentsTests wrote the real PBPruneOnFetch
    preference and cleared it afterwards.
    The tests run in the application, so running them deleted that setting for whoever ran them.
    It is now put back the way it was found.
  • PBRepositoryFinderTests and PBGitWindowWiringTests build a real repository
    with /usr/bin/git and ignored whether it worked, so a git that cannot run
    surfaced as an assertion further down that reads like a product bug.
    They now say which command failed.
  • Both hand git an empty global and system config, so the repository a test builds
    does not depend on the config of whoever runs it.

PBGitWindowWiringTests took the keyboard focus to say which list it meant,
which a test cannot reliably hold. That one is #622 rather than here, since it
needs a seam in the window controller. It is worth saying that I have not been
able to reproduce on demand the failures I have seen from that suite, so the
focus was a dependency worth removing rather than a diagnosis.

Test plan

  • make unit-test: 71 tests, 0 failures
  • testAmendingIsAskedForAgain drops from 0.331s to 0.001s, since it no
    longer launches three git processes it never wanted
  • Still has teeth: replacing [self parentTree] in the cache key with a
    constant fails it, so it continues to check that amending is asked for
    against HEAD^ rather than HEAD
  • Set PBPruneOnFetch to 2, ran the suite, and it is still 2 afterwards
  • Pointed the finder at a git that does not exist and got "git init did
    not start: The file ... doesn't exist" rather than a null comparison

@goneng goneng changed the title Fix the amend test launching a git it may not find Keep the unit tests from depending on the machine they run on Sep 13, 2026
Setting amend asks the index to read itself back, and that read-back
launches git rather than going through the task output the test answers
for. On a runner where the git lookup comes back empty the launch raises
instead, which is how the suite came to fail on master on one
architecture while passing on the other.

* Keep the read-back out of the diff cache tests, the way the refresh
  tests already do, so the only git they need is the one they answer for
A sweep of the suites for the same kind of dependency that made the
amend test fail on one runner and pass on the other.

* Put the prune-on-fetch preference back the way it was found, rather
  than clearing it: the tests run in the application, so that setting
  belongs to whoever runs them
* Say so when the git that builds a test repository fails to run or
  fails outright, instead of leaving the assertion that follows to
  report something that reads like a product bug
* Hand that git an empty global and system config, so a repository
  built for a test is the same one everywhere
@goneng
goneng force-pushed the fix-amend-test-launching-git branch from 6922397 to 32a2171 Compare September 13, 2026 06:50
@hannesa2

Copy link
Copy Markdown
Contributor

Screenshot differs: emulatorApi=arm64 with 3 screenshot(s)

setpoint (old) | diff | actual screenshot (new)

00-commit-context-menu.pngscreenshot

01-history-view.pngscreenshot

02-main-window.pngscreenshot

@goneng
goneng marked this pull request as ready for review September 13, 2026 06:56
@goneng goneng added the bugfix label Sep 13, 2026
@goneng
goneng requested a review from hannesa2 September 13, 2026 07:20
@hannesa2
hannesa2 merged commit 3f95aed into master Sep 13, 2026
3 checks passed
@hannesa2
hannesa2 deleted the fix-amend-test-launching-git branch September 13, 2026 07:23
@hannesa2 hannesa2 added the test Test related label Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix test Test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants