test: align CLI help checks with bounded output

This commit is contained in:
mikecarper committed 2026-10-20 13:35:03 -07:00
1 parent 2fbc075aaa
commit 0a9939b34b
4 files changed
+37 -7

No files matched your search

+15 -2
View File
@@ -144,8 +144,21 @@ assert 'strcmp(command, "get companion.transport") == 0' in local
assert 'strncmp(command, "set companion.transport", 23) == 0' in local
assert '"OK - companion transport %s saved; reboot required"' in local
assert '"Error: failed to save companion transport"' in local
assert 'terminalOutput().print(" get companion.transport\\r\\n")' in mesh
assert 'terminalOutput().print(" set companion.transport <wifi|ble>\\r\\n")' in mesh
help_start = mesh.index(' } else if (strcmp(command, "help") == 0) {')
help_end = mesh.index(' } else if (handleCommand(command, 0, local_reply))', help_start)
help_body = mesh[help_start:help_end]
# Help uses one selected terminal reference while each native USB write stays
# bounded. Keep both policy-specific commands on that same selected stream.
help_output = re.search(r"auto& (\w+) = terminalOutput\(\);", help_body)
assert help_output
help_transport = re.search(
r"#if defined\(COMPANION_EXCLUSIVE_WIFI_BLE\)(.*?)#endif",
help_body,
re.DOTALL,
)
assert help_transport
for text in (" get companion.transport\\r\\n", " set companion.transport <wifi|ble>\\r\\n"):
assert f'{help_output[1]}.print("{text}")' in help_transport[1]
assert "WebUI unavailable while Bluetooth transport is active" in mesh
+13 -1
View File
@@ -2,6 +2,7 @@
"""Pin local UF2 reset support across every nRF52 text CLI family."""
from pathlib import Path
import re
ROOT = Path(__file__).resolve().parents[1]
@@ -35,7 +36,18 @@ assert "sender_timestamp == 0" in common
assert "sender_timestamp == 0 && mesh::cli::isUf2ResetCommand(command)" in companion
assert "board.rebootToUf2Bootloader()" in companion
assert 'terminalOutput().println(" uf2reset");' in companion
help_start = companion.index(' } else if (strcmp(command, "help") == 0) {')
help_end = companion.index(' } else if (handleCommand(command, 0, local_reply))', help_start)
help_body = companion[help_start:help_end]
help_output = re.search(r"auto& (\w+) = terminalOutput\(\);", help_body)
assert help_output
# Bounded help writes use the cached selected stream; UF2 help stays nRF-only.
assert re.search(
r"#if defined\(NRF52_PLATFORM\)\s+"
+ re.escape(f'{help_output[1]}.println(" uf2reset");')
+ r"\s+#endif",
help_body,
)
assert "mesh::cli::isUf2ResetCommand(command)" in chat
assert "board.rebootToUf2Bootloader()" in chat
+7 -3
View File
@@ -140,10 +140,14 @@ int main() {
re.DOTALL,
),
)
self.assertIn(
'terminalOutput().print(" get storage.layout\\r\\n");',
companion,
help_start = companion.index(' } else if (strcmp(command, "help") == 0) {')
help_end = companion.index(
' } else if (handleCommand(command, 0, local_reply))', help_start
)
help_body = companion[help_start:help_end]
self.assertRegex(help_body, r"auto& \w+ = terminalOutput\(\);")
# This line may share a bounded help chunk with adjacent commands.
self.assertIn('" get storage.layout\\r\\n"', help_body)
# ESP-IDF discovery and every platform-specific result live only in the
# shared formatter; neither role owns a second copy.
+2 -1
View File
@@ -159,7 +159,8 @@ int main() {
self.assertIn("handleLocalControlCommand(command, reply, reply_capacity)", handler)
terminal = extract_braced(mesh, "void MyMesh::handleTerminalCommand(")
self.assertIn("handleLocalControlCommand(command, local_reply, sizeof(local_reply))", terminal)
self.assertIn('get display.touch\\r\\n', terminal)
help_body = extract_braced(terminal, 'else if (strcmp(command, "help") == 0)')
self.assertIn('get/set display.touch <on|off> (this boot)\\r\\n', help_body)
# No persistent preference schema or write is involved.
setter = extract_braced(local, 'if (strncmp(command, "set display.touch", 17) == 0')
self.assertNotIn("savePrefs", setter)