Repository navigation
fix(tui): stop the live git probe leaking host repo state into tests - #1366
Conversation
`gather_git_info` spawns a background thread that shells out to `git` and writes the answer into a process-global cache. The first caller in a test binary sees `None`, but every test after it inherits the developer's real branch, ahead/behind and dirty counts, so frame assertions depended on how many tests ran before them and on whether the checkout was clean. `master` therefore reports different `jcode-tui --lib` failures on different machines and on different runs of the same machine. Tests now read that cache without ever spawning the probe, and `seed_git_info_cache_for_tests` remains the explicit way to opt in to git data for the tests that want it. This also narrows `test_background_task_markdown_is_suppressed_even_if_role_was_lost`, which asserted the frame contains no box-drawing character at all. Info-widget overlays legitimately draw their own bordered box in the right margin, and whether they are docked depends on how many frames the process has already rendered, so that assertion was order-dependent rather than a statement about the card under test. The card assertions themselves are unchanged. Measured on `master` (`cargo test -p jcode-tui --lib -- --test-threads=1`): 19 failed before, 17 failed after, with the remaining failures tracked separately (#1340, #1342). Two of the failures this removes are the onboarding "recent project" tests that fail or pass depending on the developer's git state.
|
603e3b5 to
211067f
Compare
Comments Outside DiffThese findings sit on lines the diff does not cover, so they could not be posted inline. Each one leaves this list once its file changes.
|
|
The P1 points at I split that fix out so each change is independently reviewable: it is now #1368 for issue #1367, and this PR is back to the single isolation commit that its title and description describe. Two notes from that work, since they affect how you read this PR:
|
…jehuang#1366) `gather_git_info` spawns a background thread that shells out to `git` and writes the answer into a process-global cache. The first caller in a test binary sees `None`, but every test after it inherits the developer's real branch, ahead/behind and dirty counts, so frame assertions depended on how many tests ran before them and on whether the checkout was clean. `master` therefore reports different `jcode-tui --lib` failures on different machines and on different runs of the same machine. Tests now read that cache without ever spawning the probe, and `seed_git_info_cache_for_tests` remains the explicit way to opt in to git data for the tests that want it. This also narrows `test_background_task_markdown_is_suppressed_even_if_role_was_lost`, which asserted the frame contains no box-drawing character at all. Info-widget overlays legitimately draw their own bordered box in the right margin, and whether they are docked depends on how many frames the process has already rendered, so that assertion was order-dependent rather than a statement about the card under test. The card assertions themselves are unchanged. Measured on `master` (`cargo test -p jcode-tui --lib -- --test-threads=1`): 19 failed before, 17 failed after, with the remaining failures tracked separately (1jehuang#1340, 1jehuang#1342). Two of the failures this removes are the onboarding "recent project" tests that fail or pass depending on the developer's git state.
Fixes #1365. Restores the behavior #1133 introduced and that
masterhas since lost.Problem
gather_git_infospawns a background thread that shells out togitand writesthe answer into a process-global cache. In a test binary the first caller gets
Noneand later tests inherit whatever repositorycargo testran from, soframe assertions depend on test order and on whether the developer's checkout is
clean.
On
master(2a4edaa02):Two of those are the onboarding "recent project" tests, which assert on a notice
that the leaked git state overwrites.
seed_git_info_cache_for_testsstillexists (the onboarding golden test calls it) but is no longer honored, so seeding
does not stop the probe from replacing it.
Fix
Restore the
#[cfg(test)]read path ingather_git_info: tests read the cacheand never spawn the probe, and
seed_git_info_cache_for_testsis again the onlyway to inject git data. Production behavior is unchanged.
The second commit narrows
test_background_task_markdown_is_suppressed_even_if_role_was_lost, whichasserted the rendered frame contains no box-drawing character at all. Info-widget
overlays legitimately draw their own bordered box in the right margin, and whether
they are docked depends on how many frames the process has already rendered, so
that assertion was order-dependent rather than a statement about the card. The
card assertions themselves are untouched.
Verification
cargo test -p jcode-tui --lib -- --test-threads=1:masterThe remaining failures are tracked in #1340, #1342 and the other open
jcode-tuiissues; this PR only removes the order dependence that made the set unstable.
cargo fmt -p jcode-tui -- --checkis clean.