From e83b2e315b86d8e4bc9be8c45bf43c3ad5e55cb2 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 02:50:45 +0100 Subject: [PATCH] EV-59: test_ev13 T26 goldens, N4/N8/N10 tests, stronger T12b/T11a PM ruling: drop the 4th and 5th tries (1095, 1155) from the test_ev13 T26 goldens T20-beside and T20-inside. test_ev59 gains T13e (a give-up never blocks _undo, abandon or _begin), N8 and N10, and the fails-at-select and fails-at-timeout asserts that kill mutant M12. Co-Authored-By: Claude --- goodwe_controller/test_ev13.py | 4 +-- goodwe_controller/test_ev59.py | 46 +++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/goodwe_controller/test_ev13.py b/goodwe_controller/test_ev13.py index 28cb15d..d220fc3 100644 --- a/goodwe_controller/test_ev13.py +++ b/goodwe_controller/test_ev13.py @@ -1027,8 +1027,8 @@ BASE_SENDS = { # recorded on 76f4de2 (release/1.0 before EV-13) 'T19-inside': ([(1011, 0.0, False), (1071, 0.0, False), (1131, 0.0, False)], [(11, 'current', 0.0), (71, 'current', 0.0), (131, 'current', 0.0)]), 'T2-error-beside': ([(1011, 10.0, False), (1071, 10.0, False), (1131, 10.0, False)], []), 'T2-error-inside': ([(1011, 10.0, False), (1071, 10.0, False), (1131, 10.0, False)], []), - 'T20-beside': ([(1011, 0.0, True), (1025, 16.0, False), (1030, 16.0, False), (1035, 16.0, False), (1095, 16.0, False), (1155, 16.0, False)], [(11, 'current', 0.0), (15, 'phases', 1)]), - 'T20-inside': ([(1011, 0.0, True), (1025, 16.0, False), (1030, 16.0, False), (1035, 16.0, False), (1095, 16.0, False), (1155, 16.0, False)], [(11, 'current', 0.0), (15, 'phases', 1)]), + 'T20-beside': ([(1011, 0.0, True), (1025, 16.0, False), (1030, 16.0, False), (1035, 16.0, False)], [(11, 'current', 0.0), (15, 'phases', 1)]), + 'T20-inside': ([(1011, 0.0, True), (1025, 16.0, False), (1030, 16.0, False), (1035, 16.0, False)], [(11, 'current', 0.0), (15, 'phases', 1)]), 'T21-beside': ([(1011, 12.0, False)], [(11, 'current', 12.0)]), 'T21-inside': ([(1011, 12.0, False)], [(11, 'current', 12.0)]), } diff --git a/goodwe_controller/test_ev59.py b/goodwe_controller/test_ev59.py index 3c6ff1e..6aa93d8 100644 --- a/goodwe_controller/test_ev59.py +++ b/goodwe_controller/test_ev59.py @@ -460,6 +460,7 @@ check(f"T11a: the drawing timeout, the 16 A restore refused: 3 tries 5 s " near(nz(R11a, 0, 300), [20, 25, 30]) and R11a.rows[30]["fails"] == CM.MAX_TRIES and R11a.rows[30]["gave_up"] and refs(R11a) == [30] and R11a.rows[30]["phase_fails"] == 1 + and R11a.rows[20]["fails"] == 0 and R11a.rows[25]["fails"] == 0 and not R11a.drv.phases_log and nz(R11a, 300)[:1] == [300]) never("T11a", R11a, ucs=[300]) UCS.clear() @@ -487,6 +488,7 @@ check(f"T12b: a refused select counts for the phases only: close taken, fails " f"{R12b.rows[60]['fails']}, phase_fails {R12b.rows[60]['phase_fails']}, " "no REF", R12b.rows[60]["fails"] == 0 and R12b.rows[60]["phase_fails"] == 1 + and R12b.rows[1]["fails"] == 0 and R12b.rows[1]["phase_fails"] == 1 and not refs(R12b) and not R12b.rows[60]["gave_up"]) R12c = run(lambda a, n: True, 100, cur=16.0, a=16.0, power=lambda t, d: 1380.0) @@ -650,7 +652,49 @@ R22 = run(refuse, 600, avail=lambda t: False) check("T22: no charger: 0 writes, no lines, no REF", not R22.drv.calls and not R22.log and not refs(R22)) -print("\n7. N4") +print("\n6b. A GIVE-UP NEVER BLOCKS THE UNDO, THE SHUTDOWN OR A NEW SEQUENCE (N4)") + + +def given_up_writer(): + w = CM.ManualWriter() + w.gave_up, w.fails = True, CM.MAX_TRIES + w.seq = {"stage": "zero", "t0": 0.0, "n": 3, "tries": 0, "prev": 10.0} + return w, Drv(0.0, lambda a, n: True), Trk() + + +w13, d13, t13 = given_up_writer() +asyncio.run(w13._undo(d13, 1.0, t13, 16.0, False)) +check(f"T13e/N4: `_undo` with gave_up set restores the 10 A ({d13.calls})", + d13.calls == [(0.0, 10.0)] and w13.seq is None) +w13, d13, t13 = given_up_writer() +asyncio.run(w13.abandon(d13, 1.0, t13, clamp=16.0)) +check(f"T13e/N4: `abandon` with gave_up set gives the 10 A back " + f"({d13.calls})", d13.calls == [(0.0, 10.0)] and w13.seq is None) +w13, d13, t13 = given_up_writer() +w13.seq = None +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("\n7. N4, N8, N10") +APP = os.path.join(HERE, "app") +SRC = {f: open(os.path.join(APP, f), encoding="utf-8").read() + for f in sorted(os.listdir(APP)) if f.endswith(".py")} +cm_src = SRC["carmode.py"] +check("N8 (write_phases and the peak-cut rules untouched): carmode.py still " + "has the one `write_phases(` call and no new write path; base had 1", + cm_src.count("write_phases(") == 1 + and cm_src.count("drv.write_current(") == 1) +check("N10 (no new store key, setting, notification or timer): `_close_k` " + "lives in carmode.py only, never next to a store or option; the " + "asyncio.sleep, create_task and _LOG.warning counts are the base's " + "(1, 0, 10)", + [f for f, s in SRC.items() if "_close_k" in s] == ["carmode.py"] + and cm_src.count("asyncio.sleep") == 1 + and cm_src.count("create_task") == 0 + and cm_src.count("_LOG.warning(") == 10 + and not any("_close_k" in line and ("store" in line or "opts" in line) + for line in cm_src.splitlines())) w4 = CM.ManualWriter() w4.gave_up, w4.fails, w4._close_k = True, 3, 3 w4.user_changed()