Skip to content

Fix slow test hitting real ~/.claude/projects#109

Merged
cboos merged 1 commit intomainfrom
dev/fix-test-no-args-uses-default
Apr 12, 2026
Merged

Fix slow test hitting real ~/.claude/projects#109
cboos merged 1 commit intomainfrom
dev/fix-test-no-args-uses-default

Conversation

@cboos
Copy link
Copy Markdown
Collaborator

@cboos cboos commented Apr 12, 2026

Summary

  • test_no_arguments_uses_default_or_cwd invoked main with no arguments and no isolation, scanning the real ~/.claude/projects directory. On systems with large project histories (~5GB) this caused multi-minute hangs during test runs.
  • Monkeypatch get_default_projects_dir to return tmp_path and isolate the cache DB. Test now completes in <1s.
  • Also adds a reminder in CLAUDE.md to run just ci before pushing.

Test plan

  • Fixed test passes in <1s (uv run pytest test/test_cli.py::TestCLIMainCommand::test_no_arguments_uses_default_or_cwd -v)
  • Full unit test suite passes (712 passed, ~69s vs ~140s before)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Added development workflow reminder in contribution guidelines.
  • Tests

    • Improved CLI test isolation to enhance test reliability and prevent environmental interference during testing.

test_no_arguments_uses_default_or_cwd invoked `main` with no arguments
and no isolation, scanning the real ~/.claude/projects directory. On
systems with large project histories this caused multi-minute hangs.

Monkeypatch get_default_projects_dir to return tmp_path and isolate
the cache DB. Test now completes in <1s.

Also add "remind user to just ci before push" to CLAUDE.md.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 00b5d2b3-32e8-4fc0-a44a-f77c20b399ae

📥 Commits

Reviewing files that changed from the base of the PR and between 082af9c and b591ff2.

📒 Files selected for processing (2)
  • CLAUDE.md
  • test/test_cli.py

📝 Walkthrough

Walkthrough

Two modifications: a documentation reminder in CLAUDE.md instructing users to run just ci before pushing changes, and test isolation improvements in test_cli.py where monkeypatching and environment variables prevent filesystem reads during CLI testing.

Changes

Cohort / File(s) Summary
Documentation Update
CLAUDE.md
Added reminder line instructing users to run just ci before pushing changes.
Test Isolation Enhancement
test/test_cli.py
Enhanced test_no_arguments_uses_default_or_cwd to accept tmp_path fixture and use monkeypatching of get_default_projects_dir plus environment variable setup to isolate filesystem and environment effects during CLI invocation testing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A note hops in—just ci, you see,
Before you push, run it with glee!
Tests now waltz on paths pristine,
No filesystem mess in between—
Monkeypatch magic keeps all clean!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main fix: addressing a slow test that was accessing the real ~/.claude/projects directory instead of using a temporary test directory.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev/fix-test-no-args-uses-default

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cboos cboos merged commit 69a3160 into main Apr 12, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant