fix(qa-lab): resolve Windows node lookup tool · openclaw/openclaw@a70b34a
vincentkoc
·
2026-06-21
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | // Qa Lab tests cover node exec plugin behavior. |
| 2 | +import path from "node:path"; |
2 | 3 | import { describe, expect, it } from "vitest"; |
3 | 4 | import { resolveQaNodeExecPath } from "./node-exec.js"; |
4 | 5 | |
@@ -40,6 +41,29 @@ describe("resolveQaNodeExecPath", () => {
|
40 | 41 | ).resolves.toBe("/usr/local/bin/node"); |
41 | 42 | }); |
42 | 43 | |
| 44 | +it("uses trusted Windows where.exe when resolving node from PATH", async () => { |
| 45 | +await expect( |
| 46 | +resolveQaNodeExecPath({ |
| 47 | +execPath: String.raw`D:\Tools\bun.exe`, |
| 48 | +platform: "win32", |
| 49 | +versions: { ...process.versions, bun: "1.2.3" }, |
| 50 | +env: { SystemRoot: String.raw`D:\Windows` }, |
| 51 | +execFileImpl: async (file, args, options) => { |
| 52 | +expect(file).toBe(path.win32.join(String.raw`D:\Windows`, "System32", "where.exe")); |
| 53 | +expect(args).toEqual(["node"]); |
| 54 | +expect(options).toEqual({ |
| 55 | +encoding: "utf8", |
| 56 | +env: { SystemRoot: String.raw`D:\Windows` }, |
| 57 | +}); |
| 58 | +return { |
| 59 | +stdout: String.raw`D:\nodejs\node.exe` + "\r\n", |
| 60 | +stderr: "", |
| 61 | +}; |
| 62 | +}, |
| 63 | +}), |
| 64 | +).resolves.toBe(String.raw`D:\nodejs\node.exe`); |
| 65 | +}); |
| 66 | + |
43 | 67 | it("throws a clear error when node is unavailable", async () => { |
44 | 68 | await expect( |
45 | 69 | resolveQaNodeExecPath({ |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。