Skip to content

Add in-process unit tests and 100% coverage config#6

Draft
rjmurillo wants to merge 2 commits into
ohad6k:mainfrom
rjmurillo:test/coverage-suite
Draft

Add in-process unit tests and 100% coverage config#6
rjmurillo wants to merge 2 commits into
ohad6k:mainfrom
rjmurillo:test/coverage-suite

Conversation

@rjmurillo

@rjmurillo rjmurillo commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

What

Adds direct unit tests plus coverage config:

  • tests/test_ditto_unit.py: imports ditto and exercises every branch:
    redaction, log-shape parsing for Codex, Claude, and Copilot, verbatim
    dedupe, session labelling, chunking, stats, the profile card (terminal and
    HTML rendering, browser open, fallbacks), all install targets, and main()
    dispatch including --card.
  • .coveragerc: branch coverage on the ditto module.
  • .gitignore: ignore .coverage and htmlcov/.

Reaches 100% statement and branch coverage of ditto.py (377 statements, 152
branches, 0 missed), 75 tests.

Why

The existing tests drive the CLI end to end through subprocess, so they never
import ditto and do not measure its own lines. These do, and they lock the
behavior of the card renderer and the dedupe path against regressions.

Run

python -m coverage run -m unittest discover -s tests && python -m coverage report

The plain CI command also passes:

python -m unittest discover -s tests -v

@ohad6k

ohad6k commented Jul 9, 2026

Copy link
Copy Markdown
Owner

saw this one too — it's marked draft so i'll wait for you to take it out of draft. heads up that main just moved (card feature + your copilot source merged), so it'll need a rebase. the in-process test approach looks right.

rjmurillo and others added 2 commits July 10, 2026 08:47
The existing subprocess tests drive the CLI end to end but never import
ditto, so they do not measure ditto.py's own lines. Add tests/test_ditto_unit.py
that imports the module and exercises every branch: redaction, log-shape
parsing for Codex, Claude, and Copilot, session labelling, chunking, and all
install targets. Reaches 100% statement and branch coverage of ditto.py.

Run with: python -m coverage run -m unittest discover -s tests && python -m coverage report

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep .coverage data files and htmlcov/ reports out of version control.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rjmurillo
rjmurillo force-pushed the test/coverage-suite branch from cfc870e to 94b8575 Compare July 10, 2026 13:48
@rjmurillo
rjmurillo marked this pull request as ready for review July 10, 2026 13:48
@rjmurillo

Copy link
Copy Markdown
Contributor Author

rebased and added test cases for the new code so things are at 100% coverage; ready for review

@ohad6k

ohad6k commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Really appreciate this. 75 tests and full-branch coverage is exactly what I want sitting under the rewrite that's coming.

One thing before I merge: it's green on your CI but red on Windows for me. test_all_targets_and_unknown asserts the install paths with forward slashes:

ditto.install_destination("claude", "/repo", "/home").endswith("/.claude/skills/you/SKILL.md")

On Windows that returns \home\.claude\skills\you\SKILL.md, so the endswith fails. The product path is correct, the assertion just isn't cross-platform. Normalizing the separator before the check fixes it:

dest = ditto.install_destination("claude", "/repo", "/home").replace(os.sep, "/")
self.assertTrue(dest.endswith("/.claude/skills/you/SKILL.md"))

Ditto ships on Windows (Hebrew paths and all), so I want the suite green there too before it goes in. Fix that and I'll merge.

Heads up: there's a bigger ditto.py rewrite in flight (bounded mining, stable segments, caching), so some of these tests will need to move with it. Having them here makes that safer, not wasted.

If you want to go back and forth on it, come hang in the Discord: https://discord.gg/VNnMq2U5r

@rjmurillo
rjmurillo marked this pull request as draft July 11, 2026 04:58
@rjmurillo

Copy link
Copy Markdown
Contributor Author

I pulled this back into draft. I won't be near a Windows machine until next week and I can wait for the in flight to land and get the coverage needed

@ohad6k

ohad6k commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Perfect, no rush at all. The rewrite should land before you're back at a Windows machine, and your suite is going to make merging it a lot safer. Ping me when you take it out of draft.

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.

2 participants