Migrate stepper tests to the level-list representation

Schedule test drives _pairs[i].explode/coalesce and patches _advance(index,
buffer) for the stale L1->L2 feed mutant; remap rejection test patches
_boundary_hosts entries and hierarchy.pairs instead of the read-only views;
the GPU launch-failure test patches _pairs[0].explode. Assertions unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-17 01:36:41 +00:00
1 parent edce582a2d
commit 7ecb179a41
3 files changed
+19 -14

No files matched your search

@@ -251,14 +251,14 @@ class ConstructorAndSchedule(unittest.TestCase):
initial_c=c.current initial_c=c.current
def record(name): def record(name):
return lambda source,*a,**kw: events.append((name,source)) return lambda source,*a,**kw: events.append((name,source))
run._explode.side_effect=record('explode01') run._pairs[0].explode.side_effect=record('explode01')
run._child.explode.side_effect=record('explode12') run._pairs[1].explode.side_effect=record('explode12')
for i,level in enumerate(run._levels): for i,level in enumerate(run._levels):
level.kernel.side_effect=record(f'step{i}') level.kernel.side_effect=record(f'step{i}')
if bodies: if bodies:
g.boundary.kernel.side_effect=record('bfl2') g.boundary.kernel.side_effect=record('bfl2')
run._child.coalesce.side_effect=lambda src,dst,*a,**kw: events.append(('restrict21',dst)) run._pairs[1].coalesce.side_effect=lambda src,dst,*a,**kw: events.append(('restrict21',dst))
run._coalesce.side_effect=lambda src,dst,*a,**kw: events.append(('restrict10',dst)) run._pairs[0].coalesce.side_effect=lambda src,dst,*a,**kw: events.append(('restrict10',dst))
run._status='ready' run._status='ready'
expected=[('explode01',initial_c)] expected=[('explode01',initial_c)]
for middle in (f.current,f.spare): for middle in (f.current,f.spare):
@@ -278,13 +278,14 @@ class ConstructorAndSchedule(unittest.TestCase):
self.assertEqual([l.kernel.call_count for l in run._levels],[1,2,4]) self.assertEqual([l.kernel.call_count for l in run._levels],[1,2,4])
# A stale-feed implementation must fail the source-identity guard. # A stale-feed implementation must fail the source-identity guard.
feeds=[] feeds=[]
advance=run._advance_child advance=run._advance
def checked_advance(buffer, **kw): def checked_advance(index, buffer, **kw):
self.assertIs(buffer,(f.current,f.spare)[len(feeds)]) if index == 2: # L1 -> L2 feed: must be the L1 hop source
feeds.append(buffer) self.assertIs(buffer,(f.current,f.spare)[len(feeds)])
advance(buffer,**kw) feeds.append(buffer)
with patch.object(run,'_advance_child',side_effect=lambda buffer,**kw: advance(index,buffer,**kw)
checked_advance(f.current,**kw)): with patch.object(run,'_advance',side_effect=lambda index,buffer,**kw:
checked_advance(index,f.current if index == 2 else buffer,**kw)):
with self.assertRaises(AssertionError): with self.assertRaises(AssertionError):
run.step() run.step()
# A per-region shared-parent advance must fail the 1:2:4 guard. # A per-region shared-parent advance must fail the 1:2:4 guard.
+6 -2
View File
@@ -1,4 +1,5 @@
"""CPU mocks execute production remap lifecycle; no GPU numerical claim.""" """CPU mocks execute production remap lifecycle; no GPU numerical claim."""
from dataclasses import replace
import unittest import unittest
from unittest.mock import patch from unittest.mock import patch
@@ -68,8 +69,11 @@ class RuntimeChildRemap(unittest.TestCase):
run._status = 'ready' run._status = 'ready'
for bad in ([], [(40,16,48,40)], [(16,16,32,24),(16,27,32,40)]): for bad in ([], [(40,16,48,40)], [(16,16,32,24),(16,27,32,40)]):
with self.assertRaises(ValueError): run.remap_child(bad) with self.assertRaises(ValueError): run.remap_child(bad)
for attribute, value in (('_wall_aware', True), ('child_boundary', object()), hosts, pairs = run._boundary_hosts, run.hierarchy.pairs
('fine_boundary', object()), ('child_patch', None)): for attribute, value in (('_wall_aware', True),
('_boundary_hosts', [*hosts[:2], object()]), # child boundary
('_boundary_hosts', [hosts[0], object(), hosts[2]]), # fine boundary
('hierarchy', replace(run.hierarchy, pairs=(pairs[0], None)))):
with patch.object(run, attribute, value): with patch.object(run, attribute, value):
with self.assertRaises(ValueError): run.remap_child(B) with self.assertRaises(ValueError): run.remap_child(B)
self.assertEqual(len(allocations), start) self.assertEqual(len(allocations), start)
@@ -194,7 +194,7 @@ class CoupledGPU(unittest.TestCase):
f"max_corner_packet={max_corner:.9g}; ownership/counts PASS", flush=True) f"max_corner_packet={max_corner:.9g}; ownership/counts PASS", flush=True)
# Fail before any additional time step; no stale synchronized export. # Fail before any additional time step; no stale synchronized export.
with patch.object(backend, "_explode", side_effect=RuntimeError("injected launch failure")): with patch.object(backend._pairs[0], "explode", side_effect=RuntimeError("injected launch failure")):
with self.assertRaisesRegex(RuntimeError, "injected"): with self.assertRaisesRegex(RuntimeError, "injected"):
backend.step() backend.step()
with self.assertRaisesRegex(RuntimeError, "failed"): with self.assertRaisesRegex(RuntimeError, "failed"):