Repository navigation
Expand unit tests, add coverage, and split unit/e2e CI - #8
Merged
Merged
Conversation
pytest-cov runs on every pytest invocation (--no-cov to skip), and tests/conftest.py marks each test unit or e2e by its directory, so `uv run pytest -m unit` runs only the fast offline tests. CI is unchanged: `uv run pytest` still runs everything. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mbb9ZdHu1tFP2ZhM62pbgq
- test_code.py: fetch_code for every source type, the target mismatch warning, build_binary_js, and copy_support_files with path/URL icons - test_website.py: copy/fill the real bundled template (title, favicon, package.json, copy-on-write), install_website_deps, and both website builds including node_modules symlinks - test_redun_compat.py: the get_proto patch and content-based dir hashing - extract_meta_comment, utils/paths, run_cmd, rmtree_robust, resources Tasks run through .func with run_cmd and network calls monkeypatched, so everything stays offline. Unit coverage goes from 42% to 66%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mbb9ZdHu1tFP2ZhM62pbgq
unit.yaml runs `pytest -m unit` with coverage and no Node.js setup, so unit results come back in seconds instead of after the toolchain install. e2e.yaml now runs only `pytest -m e2e --no-cov`, since coverage can't see the mkcd2app subprocess the e2e tests drive. Both run on all three OSes and neither waits for the other. Because CI now selects by marker, tests/conftest.py fails collection for a test outside tests/unit and tests/e2e, which would otherwise run in neither workflow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mbb9ZdHu1tFP2ZhM62pbgq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Unit coverage of
src/mkcd2appgoes from 42% to 66%. All new tests run offline: redun tasks are called through.func(...), andrun_cmd,clone_and_checkout,requests.getandget_sim_html_pathare monkeypatched, so nonpm,mkcor network access is needed. Unit and e2e tests now also run as separate CI workflows.Tooling
pytest-covas a dev dependency. Coverage runs on every pytest run (--no-covturns it off), configured inpyproject.toml.tests/conftest.py, which marks each testunitore2eby its directory, souv run pytest -m unitruns only the fast tests (~3s). Also turns on--strict-markers. A test outsidetests/unitandtests/e2efails collection, because it would otherwise run in neither CI workflow.conftest.py, because mypy fails when two modules are both namedconftest. Shared test helpers are intests/unit/helpers.py.CI
unit.yaml("Unit tests"):uv run pytest -m unitwith coverage, on ubuntu/windows/macos. It skips the Node.js setup step, since the unit tests don't need Node.e2e.yaml("E2E tests") now runs onlyuv run pytest -m e2e --no-cov. Coverage would read ~0% there anyway, because the tests drive themkcd2appexecutable in a subprocess.unit (<os>)and, unchanged,e2e (<os>). If branch protection requires specific checks, add theunitones.New tests
test_website.pypackage.json, input left unmodified, old output replaced),install_website_deps, both website builds including relativenode_modules/.binsymlinkswebsite.py23% → 100%test_code.pyfetch_codefor all five source types,_warn_on_target_mismatch,build_binary_js,copy_support_fileswith path icon, URL icon and HTTP errorcode.py25% → 100%test_redun_compat.pyget_protopatch; folder hashes ignore mtime but change on file edit, add, remove, rename and path change (checked that the mtime tests fail on unpatched redun)_redun_compat.py58% → 100%test_meta_comment.py,test_paths.py,test_run.py,test_filesystem.py,test_resources.pyextract_meta_comment, theMKCD2APP_HOMEoverride and every path helper,run_cmd(success, cwd,BuildError,which_path),rmtree_robustwith read-only files, bundled resourcestext.py(82%)Deliberately not covered here:
is_strict_semver, and title formatting and escaping infill_website_template. Those are known bugs being fixed separately, and that fix will add their tests. Still untested:cli.py,main.py, thebuild_projectwiring, and the toolchain/target install tasks. These are listed inPROJECT_CONTEXT.md.CLAUDE.mdanddocs/PROJECT_CONTEXT.mdare updated to match.Test plan
uv run ruff check .,uv run ruff format --check .,uv run mypy .: cleanuv run pytestlocally on Linux: 153 passed (148 unit + 5 e2e)06130e9, before the workflow splittests/test_stray.pyfails collection with a clear error8925378:unitande2eon all three OSes, pluslint🤖 Generated with Claude Code
https://claude.ai/code/session_01Mbb9ZdHu1tFP2ZhM62pbgq