refactor(driver): harden preset parsing and refresh tooling

This commit is contained in:
2026-03-22 02:00:13 +13:00
parent f3bcc89320
commit 044dd815dc
7 changed files with 233 additions and 126 deletions

27
dev.py
View File

@@ -3,11 +3,12 @@
import subprocess
import serial
import sys
from pathlib import Path
print(sys.argv)
# Extract port (first arg if it's not a command)
commands = ["src", "lib", "ls", "reset", "follow", "db"]
commands = ["src", "lib", "ls", "reset", "follow", "db", "test"]
port = None
if len(sys.argv) > 1 and sys.argv[1] not in commands:
port = sys.argv[1]
@@ -51,3 +52,27 @@ for cmd in sys.argv[1:]:
subprocess.call(["mpremote", "connect", port, "fs", "cp", "-r", "db", ":" ])
else:
print("Error: Port required for 'db' command")
case "test":
if port:
if "all" in sys.argv[1:]:
test_files = sorted(
str(path)
for path in Path("test").rglob("*.py")
if path.is_file()
)
failed = []
for test_file in test_files:
print(f"Running {test_file}")
code = subprocess.call(
["mpremote", "connect", port, "run", test_file]
)
if code != 0:
failed.append((test_file, code))
if failed:
print("Some tests failed:")
for test_file, code in failed:
print(f" {test_file} (exit {code})")
else:
subprocess.call(["mpremote", "connect", port, "run", "test/all.py"])
else:
print("Error: Port required for 'test' command")