fix(v02): preserve device-pod rg patterns on Windows
This commit is contained in:
@@ -346,6 +346,43 @@ test("device-pod executor maps v0.1 CLI options to device-host-cli argv", async
|
||||
}
|
||||
});
|
||||
|
||||
test("device-pod executor forwards workspace rg patterns through base64 for Windows cmd", async () => {
|
||||
let dispatchedBody = null;
|
||||
const cloudApi = createServer(async (request, response) => {
|
||||
dispatchedBody = await requestJson(request);
|
||||
response.writeHead(200, { "content-type": "application/json; charset=utf-8" });
|
||||
response.end(JSON.stringify({
|
||||
jsonrpc: "2.0",
|
||||
id: dispatchedBody.id,
|
||||
result: { status: "completed", dispatch: { dispatchStatus: "succeeded", stdout: "ok", exitCode: 0 } }
|
||||
}));
|
||||
});
|
||||
await new Promise((resolve) => cloudApi.listen(0, "127.0.0.1", resolve));
|
||||
const cloudPort = cloudApi.address().port;
|
||||
const service = await startDevicePod("device-pod-test", {
|
||||
HWLAB_CLOUD_API_INTERNAL_URL: `http://127.0.0.1:${cloudPort}`
|
||||
});
|
||||
|
||||
try {
|
||||
await submitAndWait(service.port, "workspace.rg", {
|
||||
pattern: "FREQ_Controller_FW\\.(axf|bin|hex)$",
|
||||
path: "projects/71-00075-11/FirmWare/MDK-ARM",
|
||||
nameOnly: true,
|
||||
filesWithMatches: true
|
||||
}, "job_rg_quote", {
|
||||
profile: { devicePodId: "device-pod-test", target: { id: "target-test" }, route: { gatewaySessionId: "gws_test", hostCli: "node tools\\device-host-cli.mjs" } }
|
||||
});
|
||||
const command = dispatchedBody.params.input.command;
|
||||
const encoded = Buffer.from("FREQ_Controller_FW\\.(axf|bin|hex)$", "utf8").toString("base64");
|
||||
assert.match(command, /^node tools\\device-host-cli\.mjs --profile-json-b64 /u);
|
||||
assert.match(command, new RegExp(` workspace rg --pattern-b64 ${encoded.replace(/[+]/gu, "\\+")} --path projects/71-00075-11/FirmWare/MDK-ARM --files-with-matches --name-only$`, "u"));
|
||||
assert.equal(command.includes("FREQ_Controller_FW\\\\."), false);
|
||||
} finally {
|
||||
await service.stop();
|
||||
await new Promise((resolve, reject) => cloudApi.close((error) => (error ? reject(error) : resolve())));
|
||||
}
|
||||
});
|
||||
|
||||
test("device-pod executor returns build verify synchronously for one-call artifact verification (HWLAB #821)", async () => {
|
||||
let dispatchedBody = null;
|
||||
const cloudApi = createServer(async (request, response) => {
|
||||
|
||||
@@ -523,7 +523,7 @@ function deviceHostArgs(intent, args = {}) {
|
||||
}
|
||||
if (intent === "workspace.rg") {
|
||||
const pattern = textOr(args.pattern ?? args.query, "");
|
||||
return pattern ? ["workspace", "rg", pattern, textOr(args.path, "."), ...hostOptionArgs(args, ["glob", "g", "filesWithMatches", "nameOnly", "names", "l", "ignoreCase", "i", "maxCount", "limit"])] : null;
|
||||
return pattern ? ["workspace", "rg", "--pattern-b64", Buffer.from(pattern, "utf8").toString("base64"), "--path", textOr(args.path, "."), ...hostOptionArgs(args, ["glob", "g", "filesWithMatches", "nameOnly", "names", "l", "ignoreCase", "i", "maxCount", "limit"])] : null;
|
||||
}
|
||||
if (intent === "workspace.put") {
|
||||
const path = textOr(args.path, "");
|
||||
|
||||
Reference in New Issue
Block a user