Conversation
Change-Id: I2c6e1d74affcc868ffea51a39e2a37548f5402d7 Signed-off-by: Thomas Kosiewski <tk@coder.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fc16ba73ee
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # Detect if the required dev tools are already available; otherwise run via Nix. | ||
| ifeq (,$(shell command -v busted >/dev/null 2>&1 && command -v luacheck >/dev/null 2>&1 && echo ok)) | ||
| NIX_PREFIX := nix develop .\#ci -c |
There was a problem hiding this comment.
Gate Nix fallback on luacov too
The new NIX_PREFIX detection only checks for busted and luacheck, but make test-cov also requires luacov. In an environment where a developer has busted/luacheck on PATH but not luacov (common when coverage isn’t installed), NIX_PREFIX is empty and make test-cov will now fail at the luacov step instead of falling back to nix develop like it did before. Consider including luacov in the tool check or making test-cov explicitly use the Nix wrapper when luacov is missing.
Useful? React with 👍 / 👎.
This PR speeds up the local edit→test loop by making coverage opt-in and reducing the largest luacov hot spots.
Key changes
make testis now fast (no coverage);make test-covruns coverage +luacov..luacovconfig to focus coverage on plugin code (exclude tests/mocks).vim.waittest mock.Verification
make checkmake testmake test-cov📋 Implementation Plan
Speed up test runs (busted / luacov)
Context / Why
Running the repo’s tests via
make testis currently painfully slow (~4m+), which breaks the local edit→test loop.Primary goal: make the default developer test command fast again, while keeping a coverage-producing path for CI/release quality.
Targets
make test): <15s (current suite can run in ~9s without coverage)make test-cov): materially faster than today (~4m17s), ideally <90sEvidence (what we verified)
Makefile:testrunsbusted --coverage -vover alltests/**/*_{spec,test}.lua. (Makefile:25–35)make testwith coverage: ~4m17s (423 tests)tests/unit/terminal_spec.lua(~1m50s vs ~8s without)lua/claudecode/server/tcp.luabuilds + shuffles an entire port range array before binding. (lua/claudecode/server/tcp.lua:26–35)lua/claudecode/server/utils.luaprecomputes a 256×256 XOR lookup table at module load. (lua/claudecode/server/utils.lua:367–391)tests/mocks/vim.luamockvim.waitusesos.execute("sleep 0.001"), spawning a shell repeatedly. (tests/mocks/vim.lua:712–724)package.loaded[...]inbefore_each, forcing repeated module reloads (amplifies module-load hot spots), e.g.tests/unit/terminal_spec.lua:225+.nvim --headlessper file and wraps each innix develop, with a 30s timeout. (scripts/run_integration_tests_individually.sh:30–33)Plan
Phase 0 — Lock in a baseline (so improvements are measurable)
DEVELOPMENT.mddocumenting the expected ballpark timings and the two modes:make test(fast, no coverage)make test-cov(coverage)Phase 1 — Fast-by-default local tests (biggest win)
Makefile:make testto runbusted -v …without--coverage.make test-cov(ormake coverage) that runsbusted --coverage -v ….COVERAGE=1 make testas an alias.make test:DEVELOPMENT.md(currently recommendsmake testas the primary command; seeDEVELOPMENT.md:79–95).README.md(mentionsmake test; see aroundREADME.md:779).make test-cov.Phase 2 — Reduce coverage-enabled runtime (so CI stays reasonable)
lua/claudecode/server/tcp.lua:lua/claudecode/server/utils.lua:bit.bxor(available in Neovim) or compute XOR directly per byte.apply_mask(apply_mask(data, mask), mask) == data).tests/helpers/reload.lua) to reset stateful globals without nukingpackage.loadedbroadly.package.loaded[...] = nilfrombefore_each→setup(per-file) where isolation allows.tests/unit/terminal_spec.luasince it dominates coverage time.vim.waitmock intests/mocks/vim.lua:os.execute("sleep …")withvim.loop.sleep/uv.sleep(no shell) or a pure-Lua approach suitable for unit tests..luacovconfig to focus coverage on plugin code:tests/,tests/mocks/, and third-party deps; includelua/claudecode/.Phase 3 — Integration test speed / reliability (separate, but related)
nix developper integration file inscripts/run_integration_tests_individually.sh:IN_NIX_SHELLlike the Makefile does.plenary.test_harness.test_directoryhangs, either:Validation / Success Criteria
make test(no coverage): consistently <15s.make test-cov(coverage): improves materially from ~4m17s to <90s (or at least 2× faster), withtests/unit/terminal_spec.luano longer dominating.luacov.report.out,luacov.stats.out).Generated with
mux• Model:openai:gpt-5.2• Thinking:xhigh