Repository navigation
test(const): key the manufactured-name exemption on the name shape, not on file paths - #881
Conversation
|
CI cannot run on this PR while it is stacked, and that is a property of the workflows rather than a problem with the branch. Measured: Both suites are filtered to In the meantime the change is covered locally: |
|
GOOD TO GO on The shape predicate on its own is wider than the path one was, and the count assertion is what makes the exemption safe. I planted a shape-matching name with an unsanctioned prefix in a file that was never meant to be exempt:
Nothing narrow about it in practice, measured. All 53 sites share one distinct right-operand
All four briefed mutations fail, and failing is right in each: Scope and hygiene: one commit, one file, +56/−22, author and committer both Diagnosability nit, pre-existing and unchanged here: for shape-drift mutations Reminder for whoever merges: this is stacked on #878 and has no CI until that lands — |
df62008 to
8d20755
Compare
…ot on file paths The manufactured-name sweep in test_every_unregistered_member_call_passes_a_non_manufactured_name exempted EtherType's and Socket's 53 hex-suffixed _unregistered_member calls by file path (HEX_SUFFIXED_NAME_EXEMPT_PATHS), which is blind to shape inside those two files: mutating one branch to a differently manufactured name (e.g. 'Xyplex_%d' % value) still passed, since the exemption fired for the whole file regardless of what the name argument actually looked like. - Drop HEX_SUFFIXED_NAME_EXEMPT_PATHS entirely. - Add _HEX_SUFFIX_SHAPE, a parsed AST for hex(value)[2:].upper().zfill(4), and _is_hex_suffixed_unregistered_name(), which exempts a call only when its name argument is a '%'-BinOp with a literal left operand ending in '_0x%s' and a right operand structurally identical (via ast.dump) to that shape -- matching all 53 intended call sites and nothing else. - Update the module, class, and helper docstrings that referenced the old path-based exemption. Verified: mutating Xyplex's branch to 'Xyplex_%d' % value now fails the sweep (exempt_hits 52 != 53); mutating an unrelated file (arp/hardware.py) to 'Unassigned_%d' % value is flagged as an offender; unmutated, the sweep passes with exempt_hits == 53. Full file: 69 tests, 0 failures, 0 errors. Refs #879
|
Merge conflicts. |
8d20755 to
933e998
Compare
|
Resolved — you caught it about a minute before the fix landed. Head is now The cause was not this change. #881's branch was cut on top of #878's commit Fixed with Now: one commit, one file ( I have pulled the |
|
GOOD TO GO on It re-derived both numbers itself rather than taking mine: On tree-identity it did better than my check: And it corrected me on a point of attribution, which I have verified and accept. I had described the Both the raise to 1065 and the introduction of Two inherited nits it flagged, neither blocking and neither introduced here: the module docstring calls CI on this head: 53 green, 0 failed, 3 skipped, 5 still in flight. Unpublished and unmerged, yours to merge. |
Please follow the guide below
make pylint,make mypy,make isort)make testpasses, and a test case covers the changedocs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible -- N/A, changelog centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
test— adds or corrects a testDescription of your pull request and other information
Closes #879. No longer stacked — it was cut on #878's commit
f210ddc71, which was squash-merged intomainas6102bf43f(a different sha), leaving the pre-squash commit on the branch and the PRCONFLICTING. Rebased withgit rebase --onto origin/main f210ddc71, so the base is nowmainand this is one commit on top of it. The replay is tree-identical to the reviewed sha:8d207553c^{tree}and933e998a8^{tree}are both093c5ac1e.#878 exempted two files from
test_const_enum_no_mint.py'sis_manufactured()sweep by path, so the preserved hex-suffixed names would pass. That made the exemption shape-blind inside those files: rewriting a branch to'Xyplex_%d' % value— exactly the value-derived shape the predicate exists to flag — left the sweep green, becauseexempt_hitsstayed at 53.This keys the exemption on the name-expression shape instead, and drops
HEX_SUFFIXED_NAME_EXEMPT_PATHSentirely:An AST structural comparison rather than a source-text match, because the sweep already holds the parsed
name_argnode at the point of the check — so it needs no per-prefix pattern (there are 53 distinct prefixes,Xyplex_throughRegistered by Xerox_) and is immune to quote-style or whitespace drift in generated source. Every one of the 53 shares that suffix verbatim and no other call site inpcapkit/const/contains0x%sat all, so the match hits exactly the intended 53.The mutation that used to pass now fails — verified independently of the author, by mutating
const/reg/ethertype.py:540in a scratch worktree after asserting the line's exact content:Also proved the other two directions: unmutated the file is 69/0/0, and a value-derived name in an unrelated file is still flagged — mutating
const/arp/hardware.py:163to'Unassigned_%d' % valuefails the sweep with that path named. The exactexempt_hits == 53bound is kept, so adding or removing a branch still forces a human look.One commit, one file (
git diff --name-only f210ddc71 df62008ce→tests/const/test_const_enum_no_mint.py), nothing underpcapkit/ordocs/.