Repository navigation
fix(generators): make_samples builds fixtures from the shared checkout, not the tree it runs in - #1388
Merged
Conversation
…t, not the tree it runs in Run as a script, a generator's sys.path[0] is examples/generators/, so pcapkit resolved to the editable install's pinned checkout instead of the tree being run. make_samples.py, options.py, dispatch.py and pcapng.py now put their own tree root first on sys.path before any pcapkit import. options.generate() also raises once its captures are written if any captured case was left out, so a stale library fails make samples instead of silently shrinking the fixture set. Closes #1343
Owner
Author
|
Cross-review verdict on
Nit, worth a follow-up commit: if Python 3.10–3.13 and |
Contributor
|
Coverage: 88.97% (unit tier, Python 3.14,
Per-file detail: the |
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.
make testpasses, and a test case covers the change —pytest tests/projectand the option/dispatch generator modules, details belowWhat is the purpose of your pull request?
fix— corrects a defectDescription
Closes #1343
make_samples.py,options.py,dispatch.pyandpcapng.py(the generators that importpcapkit) put their tree root first onsys.pathbefore anypcapkitimport.options.py's one top-levelpcapkitimport moves intohandler(). I used an inline insert rather than a shared_path.pybecause importing a sibling by name only works when the generator runs as a script. Loaded by path, frommake_samplesor a test, it would fail, and this directory is deliberately kept offsys.path.options.generate()writes what it can, then raisesRuntimeErrorif any captured case was left out (pcapng.generate()already does this). No case is legitimately left out on a correct tree:EXPECTED_FAILURESholds onlypcapng-secretsentries, and that family is not captured. CI runsmake_samples.pyunderpipefailand gets0 left out.Probe (worktree, no
PYTHONPATH/PYTHONSAFEPATH): before the fix,python examples/generators/make_samples.pyprinted257 … 7 case(s) left out. After it prints266 … 0 case(s) left outfrom the tree root, fromcwd=/, and foroptions.pyrun on its own. With a stalepcapkitpre-imported,options.pynow exits 1:RuntimeError: options: 7 case(s) left out ….Tests. New
tests/project/test_generators_import_their_own_tree.pygives2 passed, 8 subtests passed. Withgit show origin/main:written over the four generators it gives9 failed: each subtest reportsimported pcapkit from /…/PyPCAPKit/pcapkit/__init__.py, plusRuntimeError not raised.pytest tests/projectgives391 passed, 1 skipped, and theprojectordering leg gives578 test(s), 0 failure(s). All runs used a 200 MB file-size cap.