EV-59: test_ev59 gains T14c, T17, T18, T11c, N3, N7, N11, N12; docstring
infra-pin / fresh (pull_request) Successful in 2s
checks / unit (pull_request) Successful in 51m36s

T14c drives SolarWriter._advance with a moving close value (pinned to the
base result). T17, T18, T11c and N11 are source checks on the edited test
files. N3 is asserted in every run, N7 with an answering charger, N12 on the
tracker notes. The docstring now says which row is here, which is carried by
another suite, and which existing tests are edited.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude
2026-12-01 05:32:29 +01:00
parent e83b2e315b
commit e522e6ffbb
+109 -4
View File
@@ -1,9 +1,15 @@
"""EV-59: Manual gives one value at most MAX_TRIES tries per user change, the
phase-change closes included. `python3 -B test_ev59.py`
Rows T1-T25 and N1-N14 of reports/EV-59-test-plan.md (T14a, T14b, T14d, T15
and T19 are carried by the unedited EV-56, EV-28 and EV-04 suites: see the dev
report). The `ManualWriter` / `SolarWriter` on a stub driver, a stub tracker
Rows T1-T25 and N1-N14 of reports/EV-59-test-plan.md. Here: T1-T13, T14c, T15
(the answering charger, writer level), T16, T17, T18 (source checks on the
edited test files), T20-T25, T11c and N1-N14 (N8, N10, N11 as source checks).
Carried by other suites, green and unedited: T14a, T14b, T14d (test_ev56 T8,
T11, T12, T13, T19b and their T20 digests), T15's T20 digests (test_ev56
[A]), T12b/T12c's EV-28 side (test_ev28 T11-T13), T19 (the listed suites).
EDITED, not unedited: test_ev56 T5, T5b and the golden "T20 T5 [R]" (Q1, Q2),
test_ev28 T15 (Q3, T11c), test_ev13 T13 text and T26 goldens (rulings).
The `ManualWriter` / `SolarWriter` on a stub driver, a stub tracker
and a stub reading; time is the 1 s step counter, never wall time. The close
of the plan's T5 world: 0 A at t=0 and the select at t=1, both taken, so the
settle ends at s=11 and the closes are at 11, 16, 21.
@@ -210,7 +216,7 @@ def never(name, r, *, ucs=(), clamp=16.0):
REF per give-up), N5 (no select under load), N6 (nothing above the clamp
or in 0-6 A), N9 (no exception out of a step), N13 (closes at least 5 s
apart, normal tries RETRY_S apart)."""
bad1, up = [], 0
bad1, bad3, up = [], [], 0
t_prev, gv = None, False
for t in sorted(r.rows):
row = r.rows[t]
@@ -221,6 +227,15 @@ def never(name, r, *, ucs=(), clamp=16.0):
bad1.append(t)
if row["gave_up"] and not (before or {}).get("gave_up"):
up += 1
# N3: not before MAX_TRIES tries of the value owed since the
# last user change (the last call's value, from that change on).
u0 = max([u for u in ucs if u <= t], default=-1)
last = [(tt, x) for tt, x in r.drv.calls if tt <= t and x > 0]
if last:
v = last[-1][1]
n_v = len([1 for tt, x in last if tt >= u0])
if n_v < CM.MAX_TRIES:
bad3.append((t, v, n_v))
if not row["gave_up"] and (before or {}).get("gave_up"):
gv = False
if any(u == t for u in ucs):
@@ -240,6 +255,8 @@ def never(name, r, *, ucs=(), clamp=16.0):
bad5 = [x for x in r.drv.phases_log if x[2] is not None
and x[2] >= CM.QUIET_W]
bad6 = [x for _t, x in nzc if x > clamp + 1e-9 or x < 6.0 - 1e-9]
check(f"{name}: N3 no give-up before MAX_TRIES tries of the value owed "
f"({bad3[:3]})", not bad3)
check(f"{name}: N1 no write while given up ({bad1[:3]}); N2 one REF per "
f"give-up ({len(refs(r))} for {up}); N5 no select under load "
f"({bad5[:2]}); N6 nothing above the clamp or under 6 A "
@@ -607,6 +624,37 @@ check(f"T25 (resetSuper trap): a Solar press at 13 does not reset Solar's "
f"tries: 8 A at 12, 17, 22, fails 3, gave_up, REF at 22 ({S_PRESS})",
S_PRESS == ([12, 17, 22], 3, True, [22], 13))
def t14c():
"""T14c: Solar's close value changes between the tries (the spare falls
during the settle): `want_a(q)` is a function of the sequence. `_advance`
driven directly on a SolarWriter in stage settle, the close refused."""
LOG.clear()
w, drv, trk = solar_writer(8.0), Drv(0.0, lambda a, n: False), Trk()
w.seq = {"stage": "settle", "t0": 0.0, "n": 3, "tries": 0, "prev": 8.0,
"t1": 0.0}
vals = {10: 8.0, 15: 7.0, 20: 6.0}
async def main():
for t in range(10, 40):
if w.seq is None:
break
drv.now = float(t)
CLOCK["t"] = t
r = Rd(drv.cur, drv.ph, power=0.0)
await w._advance(drv, r, 0.0, float(t), trk,
lambda q: vals.get(t, 5.0), 16.0, 1)
asyncio.run(main())
rf = [t for t, lv, m in LOG if lv == "WARNING" and REF in m]
return ([(int(t), x) for t, x in drv.calls], w.fails, w.gave_up, rf,
w.seq)
S14C = t14c()
check(f"T14c (N14): Solar's close value moves between tries: 8, 7, 6 A at "
f"10, 15, 20, then `fails` 4, gave_up, REF at 20, seq None, as base "
f"({S14C})",
S14C == ([(10, 8.0), (15, 7.0), (20, 6.0)], 4, True, [20], None))
print("\n6. THE CAP, RESTART, UNKNOWN, NO CHARGER (T15-T22)")
UCS.clear()
RA = run(lambda a, n: True, 100)
@@ -676,6 +724,63 @@ asyncio.run(w13._begin(d13, Rd(10.0), 10.0, 3, 1.0, t13))
check(f"T13e/N4: `_begin` with gave_up set still writes the 0 A "
f"({d13.calls})", d13.calls == [(0.0, 0.0)] and w13.seq is not None)
print("\n6c. THE EDITS TO EXISTING TESTS, N7, N12 (T17, T18, T11c, N7, N11, N12)")
def tsrc(name):
return open(os.path.join(HERE, name), encoding="utf-8").read()
s56, s13, s28 = tsrc("test_ev56.py"), tsrc("test_ev13.py"), tsrc("test_ev28.py")
BASE_DIGESTS = ("905c0b8ba89bb307", "343ea01aacfa1019", "ff6306ce56b35c64",
"f1fb141275839562", "369069be9187ab3c", "2cd78dee7ee93aaa",
"f0adb058a5bbefba", "6d7bcb747d1dc5a3", "2be1a760b699b28c",
"a5888e4557b4ee8f", "2fd24ddbb18f14cc", "1ad97e089468d71b",
"7baf8981ab382e05", "54701b140ec6f30b", "0cfd3ccd334f378d",
"1d85595302dc032a", "5fc65dbdc730e539")
check("T17 (Q1, Q2): test_ev56 has the re-taken golden 'T20 T5 [R]' "
"(78ffe9cf72c5e214, the old ba32810fbb40d0f9 gone), T5 asserts "
"fails == MAX_TRIES and gave_up, T5b asserts len == MAX_TRIES",
'"T20 T5 [R]": "78ffe9cf72c5e214"' in s56
and "ba32810fbb40d0f9" not in s56
and 'end5[1]["fails"] == CM.MAX_TRIES' in s56
and 'end5[1]["gave_up"] is True' in s56
and "len(six) == CM.MAX_TRIES" in s56)
check("N11: every other golden digest of test_ev56 is the base's, and "
"GOLDEN['T5b'] still holds base's 5 tries",
all(f'"{d}"' in s56 for d in BASE_DIGESTS)
and '"T5b": [(111.0, 6.0), (116.0, 6.0), (121.0, 6.0), (181.0, 6.0),'
in s56)
check("T18: test_ev13 T13's check text says 'one refusal counted' and its "
"assert is still fails == 1",
"no window left, one refusal counted, the mute set" in s13
and "no refusal counted" not in s13
and "w.c.car_writer.fails == 1 and w.c.car.mute_until > 0" in s13)
check("N11: test_ev13 T26 lost only the 4th and 5th tries (1095, 1155) of "
"'T20-beside' and 'T20-inside'",
s13.count("(1035, 16.0, False)], [(11, 'current', 0.0), "
"(15, 'phases', 1)])") == 2
and "(1095, 16.0, False)" not in s13
and "(1155, 16.0, False)" not in s13)
check("T11c: test_ev28 T15 asserts fails == MAX_TRIES, gave_up, 3 tries and "
"the car at 0 A with no select (the only edit, ruled Q3)",
"w.wr.fails == MAX_TRIES" in s28 and "w.wr.gave_up" in s28
and "w.sim.readback_a == 0 and len(tries) == MAX_TRIES" in s28)
UCS.clear()
RN7 = run(lambda a, n: True, 400, cb=at(100, a=8.0))
check(f"N7: a charger that answers: the calls are 0 A at 0, 6 A at 11, 8 A at "
f"100 and nothing else ({RN7.drv.calls}); no REF, fails 0, no "
"give-up, no ERROR",
RN7.drv.calls == [(0.0, 0.0), (11.0, 6.0), (100.0, 8.0)]
and not refs(RN7) and not recs(RN7)
and RN7.rows[399]["fails"] == 0 and not RN7.rows[399]["gave_up"])
n12 = [x for x in R1.trk.notes if x[1] > 0]
check(f"N12: the tracker is told of each refused close once ({n12}) and of "
f"no raised close ({[x for x in RX.trk.notes if x[1] > 0]}, "
f"begin/end per write {RX.trk.notes[:1]})",
len(n12) == 3 and all(not ok for _t, _a, ok in n12)
and not [x for x in RX.trk.notes if x[1] > 0])
print("\n7. N4, N8, N10")
APP = os.path.join(HERE, "app")
SRC = {f: open(os.path.join(APP, f), encoding="utf-8").read()