Scrub GIT_DIR and friends from git tests #45
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/045-scrub-git-dir-and-friends-from-git-tests"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Scrub GIT_DIR and friends from git tests
Along the way:
Touches 6 files:
ck-ui/src/theme/dark.rs,ck-ui/src/theme/tokens.rs,ckeditor-lint/baseline.toml,ckeditor-lint/baseline_CHANGELOG.md,ckeditor/src/app_layout/buffer_panel.rs,ckeditor/src/git/diff.rs.Happy with this. I ran the suite against the branch and it is green,
ckeditor/src/app_layout/buffer_panel.rsincluded.@ -293,0 +375,4 @@}}fn paint_tab_background(paint_tab_backgroundreads, decides and writes in one function. The deciding part is the piece I would want to test on its own. Worth splitting?Split. The decision in
paint_tab_backgroundis a pure function now, with its own tests inckeditor/src/app_layout/buffer_panel.rs.Looked through
ckeditor/src/app_layout/buffer_panel.rsas well. Fine by me.ckeditor:
:diff::tests spawns `git init` / `git config` inside a
tempfile::tempdir so each test has its own self-contained repo. Run
directly via `cargo test --workspace` that works, but under the
pre-commit hook git inherits GIT_DIR (and GIT_WORK_TREE,
GIT_INDEX_FILE, GIT_COMMON_DIR, GIT_OBJECT_DIRECTORY) from the hook's
environment. Every git invocation then secretly operates on the outer
repo's .git rather than the tempdir, so two parallel tests race on
.git/config.lock and one of them quietly stages a `seed.txt` into the
outer repo's index.
The git test helper now scrubs those env vars per Command, so the
tempdir's local repo is the only thing each git invocation sees.
Tests now pass under both `cargo test --workspace` and the pre-commit
hook environment.