























@@ -3,7 +3,6 @@ import { describe, expect, test } from "vitest";
33import {
44extractShellCommandFromArgv,
55formatExecCommand,
6-resolveSystemRunCommand,
76resolveSystemRunCommandRequest,
87validateSystemRunCommandConsistency,
98} from "./system-run-command.js";
@@ -282,8 +281,8 @@ describe("system run command helpers", () => {
282281});
283282});
284283285-test("resolveSystemRunCommand requires command when rawCommand is present", () => {
286-const res = resolveSystemRunCommand({ rawCommand: "echo hi" });
284+test("resolveSystemRunCommandRequest requires command when rawCommand is present", () => {
285+const res = resolveSystemRunCommandRequest({ rawCommand: "echo hi" });
287286expect(res.ok).toBe(false);
288287if (res.ok) {
289288throw new Error("unreachable");
@@ -292,8 +291,8 @@ describe("system run command helpers", () => {
292291expect(res.details?.code).toBe("MISSING_COMMAND");
293292});
294293295-test("resolveSystemRunCommand treats non-array command values as missing", () => {
296-const res = resolveSystemRunCommand({
294+test("resolveSystemRunCommandRequest treats non-array command values as missing", () => {
295+const res = resolveSystemRunCommandRequest({
297296command: "echo hi",
298297rawCommand: "echo hi",
299298});
@@ -304,17 +303,17 @@ describe("system run command helpers", () => {
304303expect(res.details?.code).toBe("MISSING_COMMAND");
305304});
306305307-test("resolveSystemRunCommand returns an empty success payload when no command is provided", () => {
308-const res = expectValidResult(resolveSystemRunCommand({}));
306+test("resolveSystemRunCommandRequest returns an empty success payload when no command is provided", () => {
307+const res = expectValidResult(resolveSystemRunCommandRequest({}));
309308expect(res.argv).toStrictEqual([]);
310309expect(res.commandText).toBe("");
311310expect(res.shellPayload).toBeNull();
312311expect(res.previewText).toBeNull();
313312});
314313315-test("resolveSystemRunCommand stringifies non-string argv tokens", () => {
314+test("resolveSystemRunCommandRequest stringifies non-string argv tokens", () => {
316315const res = expectValidResult(
317-resolveSystemRunCommand({
316+resolveSystemRunCommandRequest({
318317command: ["echo", 123, false, null],
319318}),
320319);
@@ -335,19 +334,19 @@ describe("system run command helpers", () => {
335334336335test.each([
337336{
338-name: "resolveSystemRunCommand unwraps macOS dispatch wrappers before deriving shell previews",
337+name: "resolveSystemRunCommandRequest unwraps macOS dispatch wrappers before deriving shell previews",
339338run: () =>
340-resolveSystemRunCommand({
339+resolveSystemRunCommandRequest({
341340command: ["/usr/bin/arch", "-arm64", "/bin/sh", "-lc", "echo hi"],
342341}),
343342expectedShellPayload: null,
344343expectedCommandText: '/usr/bin/arch -arm64 /bin/sh -lc "echo hi"',
345344expectedPreviewText: null,
346345},
347346{
348-name: "resolveSystemRunCommand unwraps xcrun before deriving shell previews",
347+name: "resolveSystemRunCommandRequest unwraps xcrun before deriving shell previews",
349348run: () =>
350-resolveSystemRunCommand({
349+resolveSystemRunCommandRequest({
351350command: ["/usr/bin/xcrun", "/bin/sh", "-lc", "echo hi"],
352351}),
353352expectedShellPayload: null,
@@ -367,39 +366,39 @@ describe("system run command helpers", () => {
367366expectedPreviewText: "echo SAFE&&whoami",
368367},
369368{
370-name: "resolveSystemRunCommand binds commandText to full argv for shell-wrapper positional-argv carriers",
369+name: "resolveSystemRunCommandRequest binds commandText to full argv for shell-wrapper positional-argv carriers",
371370run: () =>
372-resolveSystemRunCommand({
371+resolveSystemRunCommandRequest({
373372command: ["/bin/sh", "-lc", '$0 "$1"', "/usr/bin/touch", "/tmp/marker"],
374373}),
375374expectedShellPayload: null,
376375expectedCommandText: '/bin/sh -lc "$0 \\"$1\\"" /usr/bin/touch /tmp/marker',
377376expectedPreviewText: null,
378377},
379378{
380-name: "resolveSystemRunCommand binds commandText to full argv when env prelude modifies shell wrapper",
379+name: "resolveSystemRunCommandRequest binds commandText to full argv when env prelude modifies shell wrapper",
381380run: () =>
382-resolveSystemRunCommand({
381+resolveSystemRunCommandRequest({
383382command: ["/usr/bin/env", "BASH_ENV=/tmp/payload.sh", "bash", "-lc", "echo hi"],
384383}),
385384expectedShellPayload: null,
386385expectedCommandText: '/usr/bin/env BASH_ENV=/tmp/payload.sh bash -lc "echo hi"',
387386expectedPreviewText: null,
388387},
389388{
390-name: "resolveSystemRunCommand keeps wrapper preview separate from canonical command text",
389+name: "resolveSystemRunCommandRequest keeps wrapper preview separate from canonical command text",
391390run: () =>
392-resolveSystemRunCommand({
391+resolveSystemRunCommandRequest({
393392command: ["./env", "sh", "-c", "jq --version"],
394393}),
395394expectedShellPayload: "jq --version",
396395expectedCommandText: './env sh -c "jq --version"',
397396expectedPreviewText: "jq --version",
398397},
399398{
400-name: "resolveSystemRunCommand accepts canonical full argv text for wrapper approvals",
399+name: "resolveSystemRunCommandRequest accepts canonical full argv text for wrapper approvals",
401400run: () =>
402-resolveSystemRunCommand({
401+resolveSystemRunCommandRequest({
403402command: ["./env", "sh", "-c", "jq --version"],
404403rawCommand: './env sh -c "jq --version"',
405404}),
@@ -420,9 +419,9 @@ describe("system run command helpers", () => {
420419},
421420);
422421423-test("resolveSystemRunCommand rejects legacy shell payload text in strict mode", () => {
424-const res = resolveSystemRunCommand({
425-command: ["/bin/sh", "-lc", "echo hi"],
422+test("validateSystemRunCommandConsistency rejects legacy shell payload text in strict mode", () => {
423+const res = validateSystemRunCommandConsistency({
424+argv: ["/bin/sh", "-lc", "echo hi"],
426425rawCommand: "echo hi",
427426});
428427expect(res.ok).toBe(false);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。