fix: bootstrap serial monitor on UART open
This commit is contained in:
@@ -396,6 +396,40 @@ print(json.dumps({"results": results, "commands": executor.commands}))
|
||||
assert.deepEqual(result.results.map((item: any) => item.status), ["completed", "completed", "completed"]);
|
||||
});
|
||||
|
||||
test("python hwpod-node starts an unreachable serial-monitor server before opening UART", () => {
|
||||
const script = `
|
||||
import importlib.util, json, logging
|
||||
spec = importlib.util.spec_from_file_location("hwlab_node", "tools/hwlab-node.py")
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
class Executor(module.NodeOpsExecutor):
|
||||
def __init__(self):
|
||||
super().__init__({"nodeId": "node-test"}, logging.getLogger("test"))
|
||||
self.commands = []
|
||||
def _spawn_output(self, command, cwd, timeout_ms):
|
||||
self.commands.append(command)
|
||||
if command[-2:] == ["server", "start"]:
|
||||
body = {"success": True}
|
||||
elif len(self.commands) == 1:
|
||||
body = {"success": False, "data": {"request": {"code": "ECONNREFUSED"}, "diagnosis": {"status": "not_running"}}}
|
||||
else:
|
||||
body = {"success": True}
|
||||
return {"ok": True, "stdout": json.dumps(body), "stderr": "", "exitCode": 0}
|
||||
executor = Executor()
|
||||
result = executor._execute_op({"opId": "open", "op": "io.uart.open", "args": {"workspacePath": ".", "port": "COM4", "baudRate": 921600, "serialMonitorCommand": ["serial-monitor"]}})
|
||||
print(json.dumps({"result": result, "commands": executor.commands}))
|
||||
`;
|
||||
const completed = spawnSync("python3", ["-c", script], { cwd: process.cwd(), encoding: "utf8" });
|
||||
assert.equal(completed.status, 0, completed.stderr);
|
||||
const result = JSON.parse(completed.stdout);
|
||||
assert.equal(result.result.status, "completed");
|
||||
assert.deepEqual(result.commands, [
|
||||
["serial-monitor", "monitor", "start", "-p", "COM4", "-b", "921600"],
|
||||
["serial-monitor", "server", "start"],
|
||||
["serial-monitor", "monitor", "start", "-p", "COM4", "-b", "921600"],
|
||||
]);
|
||||
});
|
||||
|
||||
test("hwpod-node resolves Git for Windows when service PATH omits git", async () => {
|
||||
const result = await resolveHwpodNodeCommand("git", {
|
||||
platform: "win32",
|
||||
|
||||
Reference in New Issue
Block a user