Skip to content

test: run the 1732 leg steps once and share tree scans (#3148) - #3151

Merged
JarryShaw merged 1 commit into
developfrom
test/3148-e2-project-pins
Nov 27, 2026
Merged

JarryShaw merged 1 commit into
developfrom
test/3148-e2-project-pins

Conversation

@JarryShaw

@JarryShaw JarryShaw commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Please follow the guide below

  • Put an x into every box [ ] that applies to your pull request (like this: [x])

  • Use the Preview tab to see how your pull request will look

  • Searched for similar pull requests

  • Followed the coding style (make pylint, make mypy, make isort)

  • make test passes, and a test case covers the change

  • Described the user-visible change below and left its changelog entry to the maintainer, keeping docs/source/changelog/ and CHANGELOG.md out of the diff, if the change is user-visible: N/A — centralised

What is the purpose of your pull request?

Tick the commit type your subject line carries.

  • fix — corrects a defect

  • feat — adds a feature

  • perf — changes performance, not behaviour

  • refactor — changes neither behaviour nor performance

  • test — tests only

  • docs — documentation only

  • ci — workflows or build tooling

  • release — bumps the version or rolls up a distribution

  • chore — anything else

  • Also tick if it regenerates constant or registry tables, members keeping their numeric values (the const label)


Description of your pull request and other information

Part of #3148, batch E2 (T7, T10). No pcapkit/ change. Times are local JUnit test-seconds, CPython 3.14, -n 4.

Change Proof on a scratch tree, reverted Coverage Time
1732 TestTheStepSelectsByLeg: 5 tests → 1, a subtest per old name, no assertion removed PROJECT_PINS_SELECTOR for LATEST_TIER_SELECTOR in Run unit tests fails it on every off-latest leg; its own doctored step still differs n/a setUpClass 3× → 1×, class 134.4 → 45.8 s
TestTheIgnoresAreTheLatestTier → test_latest_ignores_by_pytest_1732.py, so is_project_pin() takes 1732 (pins gain only 1732) — executed lines and branches equal in all 827 pcapkit files (43%) 219.8 s under coverage → 68.9 s pin + 16.2 s
tests/_sources.py: text, comments and per-file parse products, keyed on inode, size, mtime and ctime; a file changed within 100 ms is never kept, nor trees, nor anything outside the checkout one plant in pcapkit/ and one in tests/ fail all 6 tree checks n/a, pins —
new test_sources_loader_3148_unit.py: a same-size rewrite under the checkout is read again the old (size, mtime) loader returns 48 of 50 rewrites stale; dropping the 100 ms rule fails 50, dropping inode/ctime fails the kept-file test n/a 1 s
ext_len 2854, per-class guard, epilog 1936, roles 1103, issue refs, unit_tests_queue docs readers use it as above n/a pins half 1: touched 35.3 → 21.1 s; one process: 47.0 → 29.2 s
  • No trees are cached: held, pcapkit's cost ~186 MiB and 0.31 s per full gc.collect, tests/' ~446 MiB and 1.48 s, and run_unittest_leg.py collects every 10 tests.
  • Scans share only within one process: the six modules alone at -n 4 saved nothing, so no CI figure is claimed.
  • Tests, on 974e1f48b9: touched modules; tests/project 2493 passed, 88 skipped, and root tests/test_*.py 266 passed, 1 skipped, at -n 2.

@github-actions github-actions Bot added this to the PyPCAPKit v1.9 milestone Nov 27, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Nov 27, 2026
@JarryShaw JarryShaw added test Pull requests that add or correct tests (test: subject prefix) review: running A cross-review is in flight against the current head - no verdict yet labels Nov 27, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Review verdict: needs changes at af30782c6, from a cross-review on Sonnet.

  1. tests/_sources.py's cache can serve a stale file. _cached keys on (size, st_mtime_ns), and a file's mtime advances in coarse ticks. So a same-size rewrite made right after a read comes back stale: 275 times out of 300 in the reviewer's trial. Treat a file whose mtime is within about 100 ms of now as uncacheable, as git does for racy timestamps, and add a test that rewrites a same-size file under ROOT straight after reading it.

Confirmed:

  • T7: the merged test keeps every assertion and fails on every off-latest leg under the selector swap.
  • The split: is_project_pin() takes the reduced 1732 module, and the new module is LATEST.
  • Planted violations in five of the six converted modules each turn red.
  • Another worktree's files are never cached.
  • tests/project and the root suites pass (2743).

The fix goes to the original worker, and this head's CI is cancelled.

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment and removed review: running A cross-review is in flight against the current head - no verdict yet labels Nov 27, 2026
- test_sweeps_on_latest_only_1732: TestTheStepSelectsByLeg's five tests
  become one, each a subtest under its old name, so setUpClass runs the
  steps on one xdist worker rather than on each that drew a test.
- TestTheIgnoresAreTheLatestTier moves to test_latest_ignores_by_pytest_1732:
  its child pytest imports pcapkit, so the rest of 1732 is now a project pin.
- tests/_sources.py: text, comments and per-file products of a parse, cached
  per process and checked against each file's inode, size, mtime and ctime; a
  file changed within RACY_NS is never kept, trees are not kept, and paths
  outside the checkout are never cached.
- test_sources_loader_3148_unit pins that a same-size rewrite is read again.
- ext_len 2854, per_class_import_guard, docs epilog 1936, docs roles 1103,
  issue refs in comments and unit_tests_queue's docs readers scan through it,
  so a repeated tree scan in one process parses each file once.

The touched modules, tests/project and the root suites pass.
@JarryShaw
JarryShaw force-pushed the test/3148-e2-project-pins branch from af30782 to 28344fe Compare November 27, 2026 16:33
@JarryShaw JarryShaw added review: running A cross-review is in flight against the current head - no verdict yet and removed review: needs-changes Cross-review at the current head says changes are required; see the verdict comment labels Nov 27, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Re-review verdict: good to go at 28344fe71, from a delta re-review on Sonnet.

  • Stale reads gone: across 300 same-size back-to-back rewrites, none comes back stale. The old loader returned 275 stale.
  • Both halves of the fix count: with the 100 ms window removed, 50 tests fail. With the old (size, mtime) stamp, the settled-file test fails.
  • Write after the stamp: a write landing after the stamp is re-read on the next call. Only a clock running more than 100 ms ahead of the filesystem, as on a lagging network share, could beat the window.
  • Probe cleanup: the loader test writes its probes to a hidden .txt-only directory that addCleanup removes. The tree-scanning sweeps only look at tracked or .py/.md files, so the probes can't leak into them.
  • Test run: tests/project plus the root suites pass, 2759 tests.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Nov 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 94.79% (unit tier, Python 3.15, 28344fe71, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 108 4 20 2 95.31%
pcapkit/const 21794 212 3100 185 98.32%
pcapkit/corekit 3059 83 1004 40 96.73%
pcapkit/dumpkit 423 3 148 5 98.60%
pcapkit/foundation 3919 24 1252 26 99.03%
pcapkit/interface 103 4 34 3 94.89%
pcapkit/protocols 26383 158 6952 129 99.13%
pcapkit/toolkit 994 26 356 8 96.74%
pcapkit/utilities 591 7 162 5 98.41%
pcapkit/vendor 6214 2320 1412 245 59.36%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw

Copy link
Copy Markdown
Owner Author

Ready to merge at 28344fe71. The verdict is good to go, every required check is green, and the KTLO and experimental legs carry no annotations.

@JarryShaw
JarryShaw merged commit 67a48af into develop Nov 27, 2026
38 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Nov 27, 2026
@JarryShaw
JarryShaw deleted the test/3148-e2-project-pins branch November 27, 2026 18:26
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Pull requests that add or correct tests (test: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant