mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-23 23:22:32 +00:00
refactor(test): snapshot shell/path env in bash tools e2e
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import path from "node:path";
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { peekSystemEvents, resetSystemEventsForTest } from "../infra/system-events.js";
|
||||
import { captureEnv } from "../test-utils/env.js";
|
||||
import { getFinishedSession, resetProcessRegistryForTests } from "./bash-process-registry.js";
|
||||
import { createExecTool, createProcessTool, execTool, processTool } from "./bash-tools.js";
|
||||
import { buildDockerExecArgs } from "./bash-tools.shared.js";
|
||||
@@ -61,18 +62,17 @@ beforeEach(() => {
|
||||
});
|
||||
|
||||
describe("exec tool backgrounding", () => {
|
||||
const originalShell = process.env.SHELL;
|
||||
let envSnapshot: ReturnType<typeof captureEnv>;
|
||||
|
||||
beforeEach(() => {
|
||||
envSnapshot = captureEnv(["SHELL"]);
|
||||
if (!isWin && defaultShell) {
|
||||
process.env.SHELL = defaultShell;
|
||||
}
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
if (!isWin) {
|
||||
process.env.SHELL = originalShell;
|
||||
}
|
||||
envSnapshot.restore();
|
||||
});
|
||||
|
||||
it(
|
||||
@@ -301,18 +301,17 @@ describe("exec tool backgrounding", () => {
|
||||
});
|
||||
|
||||
describe("exec exit codes", () => {
|
||||
const originalShell = process.env.SHELL;
|
||||
let envSnapshot: ReturnType<typeof captureEnv>;
|
||||
|
||||
beforeEach(() => {
|
||||
envSnapshot = captureEnv(["SHELL"]);
|
||||
if (!isWin && defaultShell) {
|
||||
process.env.SHELL = defaultShell;
|
||||
}
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
if (!isWin) {
|
||||
process.env.SHELL = originalShell;
|
||||
}
|
||||
envSnapshot.restore();
|
||||
});
|
||||
|
||||
it("treats non-zero exits as completed and appends exit code", async () => {
|
||||
@@ -416,20 +415,17 @@ describe("exec notifyOnExit", () => {
|
||||
});
|
||||
|
||||
describe("exec PATH handling", () => {
|
||||
const originalPath = process.env.PATH;
|
||||
const originalShell = process.env.SHELL;
|
||||
let envSnapshot: ReturnType<typeof captureEnv>;
|
||||
|
||||
beforeEach(() => {
|
||||
envSnapshot = captureEnv(["PATH", "SHELL"]);
|
||||
if (!isWin && defaultShell) {
|
||||
process.env.SHELL = defaultShell;
|
||||
}
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
process.env.PATH = originalPath;
|
||||
if (!isWin) {
|
||||
process.env.SHELL = originalShell;
|
||||
}
|
||||
envSnapshot.restore();
|
||||
});
|
||||
|
||||
it("prepends configured path entries", async () => {
|
||||
|
||||
Reference in New Issue
Block a user