Skip to content

Commit e03e2c8

Browse files
committed
test(protocols): run the hand-written edge-case round-trip tables on every interpreter (#1958)
- Mark the #1202 edge-case table modules for the application, internet, link and transport layers `ALL`: their rows are hand-picked round trips, not a sweep. The short-read sweep and the harness's deadline test stay `LATEST`. - Split the sweep pin in tests/project/test_sweeps_on_latest_only_1732.py: the corekit harness's users stay `LATEST`, the edge-case tables are `ALL`. - Pin both sides of the ruling in the tier guard's ruling table. - Reword the tier paragraph on the workflows page to match. Refs #1958
1 parent c68a5ac commit e03e2c8

8 files changed

Lines changed: 43 additions & 27 deletions

‎docs/source/contributing/workflows.rst‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -930,9 +930,10 @@ collects it; a test tier decides on which of that job's legs it runs.
930930
exercises ``pcapkit`` is ``ALL``.
931931

932932
The marker says what the AST cannot see. Each real sweep -- a round trip over every
933-
case of a table, every registry entry or every capture -- is marked ``LATEST``, as
934-
the owner ruled on #1732 and #1958; the hand-picked round trips, whatever their
935-
names, run on ``ALL``. A module that imports ``pcapkit`` only to read its text or
933+
class or registry entry a table enumerates, every offset of a packet or every
934+
capture -- is marked ``LATEST``, as the owner ruled on #1732 and #1958; the
935+
hand-picked round trips, whatever their names, run on ``ALL``, and so do the #1202
936+
edge-case tables, whose cases are each written out by hand. A module that imports ``pcapkit`` only to read its text or
936937
structure, or that drives a docs hook or a generator other legs already run, is
937938
marked ``LATEST``; one that the rule would send to ``latest`` but that depends on
938939
the interpreter, such as the tier guard itself, which :file:`tests/conftest.py` runs at

‎tests/project/test_sweeps_on_latest_only_1732.py‎

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,17 +246,28 @@ def test_the_tier_is_no_name_rule(self) -> None:
246246
self.assertTrue([module for module in named if module in latest])
247247
self.assertTrue([module for module in latest if module not in named and 'tests/project/' not in module])
248248

249-
def test_every_module_on_a_sweep_harness_is_latest(self) -> None:
250-
"""The #1202 edge-case and corekit tables build every case they list, so their users are sweeps."""
251-
modules = _tiers.suite_modules()
252-
for harness in ('tests/protocols/_edge_roundtrip.py', 'tests/corekit/_roundtrip.py'):
253-
users = [module for module in modules if _tiers.is_unit_tier(module) and re.search(
254-
rf'^from {re.escape(harness[:-3].replace("/", "."))} import .*\b(?:Case|KnownFailureTable)\b',
255-
(ROOT / module).read_text(encoding='utf-8'), re.M)]
256-
with self.subTest(harness=harness):
257-
self.assertTrue(users)
258-
self.assertEqual([module for module in users if _tiers.module_tier(module) != _tiers.TIER_LATEST],
259-
[])
249+
@staticmethod
250+
def harness_users(harness: 'str') -> 'list[str]':
251+
"""The unit-tier modules that import a table type from ``harness``."""
252+
return [module for module in _tiers.suite_modules() if _tiers.is_unit_tier(module) and re.search(
253+
rf'^from {re.escape(harness[:-3].replace("/", "."))} import .*\b(?:Case|KnownFailureTable)\b',
254+
(ROOT / module).read_text(encoding='utf-8'), re.M)]
255+
256+
def test_every_module_on_the_corekit_harness_is_latest(self) -> None:
257+
"""The corekit tables build a case for every class they enumerate, so their users are sweeps."""
258+
users = self.harness_users('tests/corekit/_roundtrip.py')
259+
self.assertTrue(users)
260+
self.assertEqual([module for module in users if _tiers.module_tier(module) != _tiers.TIER_LATEST], [])
261+
262+
def test_the_edge_case_tables_run_on_every_leg(self) -> None:
263+
"""#1958: the #1202 edge-case tables are written out by hand, so they run on every leg."""
264+
deadline = 'tests/protocols/test_edge_roundtrip_deadline_1736_unit.py'
265+
users = self.harness_users('tests/protocols/_edge_roundtrip.py')
266+
self.assertIn(deadline, users)
267+
tables = [module for module in users if module != deadline]
268+
self.assertTrue(tables)
269+
self.assertEqual([module for module in tables if _tiers.module_tier(module) != _tiers.TIER_ALL], [])
270+
self.assertEqual(_tiers.module_tier(deadline), _tiers.TIER_LATEST)
260271

261272

262273
@unittest.skipIf(shutil.which('bash') is None, 'the step is a bash script')

‎tests/protocols/application/test_application_edge_roundtrip_unit.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
from tests.protocols import _edge_roundtrip as edge
2121
from tests.protocols._edge_roundtrip import Case, MakeCase
2222

23-
#: Test tier (#1958): the #1202 edge-case table for the application layer, every case
24-
#: of it.
25-
__tier__ = 'LATEST'
23+
#: Test tier (#1958): hand-picked round-trip cases, not a sweep: the #1202 edge
24+
#: cases for the application layer, each written out by hand.
25+
__tier__ = 'ALL'
2626

2727
FTP = 'pcapkit.protocols.application.ftp:FTP'
2828
HTTP1 = 'pcapkit.protocols.application.httpv1:HTTP'

‎tests/protocols/internet/test_internet_edge_roundtrip_unit.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
from tests.protocols import _edge_roundtrip as edge
2121
from tests.protocols._edge_roundtrip import Case, MakeCase, Reject
2222

23-
#: Test tier (#1958): the #1202 edge-case table for the internet layer, every case of
24-
#: it.
25-
__tier__ = 'LATEST'
23+
#: Test tier (#1958): hand-picked round-trip cases, not a sweep: the #1202 edge
24+
#: cases for the internet layer, each written out by hand.
25+
__tier__ = 'ALL'
2626

2727
IPV4 = 'pcapkit.protocols.internet.ipv4:IPv4'
2828
IPX = 'pcapkit.protocols.internet.ipx:IPX'

‎tests/protocols/link/test_link_edge_roundtrip_unit.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
from tests.protocols import _edge_roundtrip as edge
1919
from tests.protocols._edge_roundtrip import Case, MakeCase, Reject
2020

21-
#: Test tier (#1958): the #1202 edge-case table for the link layer, every case of it.
22-
__tier__ = 'LATEST'
21+
#: Test tier (#1958): hand-picked round-trip cases, not a sweep: the #1202 edge
22+
#: cases for the link layer, each written out by hand.
23+
__tier__ = 'ALL'
2324

2425
ETHERNET = 'pcapkit.protocols.link.ethernet:Ethernet'
2526
C_TAG = 'pcapkit.protocols.link.c_tag:C_Tag'

‎tests/protocols/test_edge_roundtrip_deadline_1736_unit.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
if TYPE_CHECKING:
2828
from typing import Iterator
2929

30-
#: Test tier (#1958): tests the deadline of the edge-case harness, which only the
31-
#: edge-case sweeps use.
30+
#: Test tier (#1958): checks that the edge-case harness arms its deadline after the
31+
#: import, an order fixed by the harness's own code rather than by pcapkit or the
32+
#: interpreter; the edge-case tables it serves run on every leg.
3233
__tier__ = 'LATEST'
3334

3435
ETHERNET = 'pcapkit.protocols.link.ethernet:Ethernet'

‎tests/protocols/transport/test_transport_edge_roundtrip_unit.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
from tests.protocols import _edge_roundtrip as edge
2121
from tests.protocols._edge_roundtrip import Case, MakeCase, Reject
2222

23-
#: Test tier (#1958): the #1202 edge-case table for the transport layer, every case of
24-
#: it.
25-
__tier__ = 'LATEST'
23+
#: Test tier (#1958): hand-picked round-trip cases, not a sweep: the #1202 edge
24+
#: cases for the transport layer, each written out by hand.
25+
__tier__ = 'ALL'
2626

2727
TCP = 'pcapkit.protocols.transport.tcp:TCP'
2828
UDP = 'pcapkit.protocols.transport.udp:UDP'

‎tests/test_tier_guard.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,8 @@ def test_the_sweeps_and_the_pins_are_latest_and_the_hand_picked_round_trips_are_
559559
'tests/protocols/test_option_roundtrip_unit.py': _tiers.TIER_LATEST,
560560
'tests/protocols/test_capture_roundtrip_runtime.py': _tiers.TIER_LATEST,
561561
'tests/protocols/test_dispatch_reachability_unit.py': _tiers.TIER_LATEST,
562+
'tests/protocols/test_short_read_roundtrip_unit.py': _tiers.TIER_LATEST,
563+
'tests/protocols/link/test_link_edge_roundtrip_unit.py': _tiers.TIER_ALL,
562564
'tests/protocols/transport/test_tcp_ns_flag_roundtrip_unit.py': _tiers.TIER_ALL,
563565
'tests/corekit/test_from_dict_roundtrip_unit.py': _tiers.TIER_ALL,
564566
'tests/project/test_isort_clean.py': _tiers.TIER_LATEST,

0 commit comments

Comments
 (0)