Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/onboard-extra-provider-reconciliation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ const { createSandbox } = require(${onboardPath});
PATH: `${fakeBin}:${process.env.PATH || ""}`,
NEMOCLAW_NON_INTERACTIVE: "1",
NEMOCLAW_TEST_MANAGED_IMAGE_FALLBACK: "1",
NEMOCLAW_SANDBOX_PREBUILD: "1",
OPENSHELL_GATEWAY_ENDPOINT: undefined,
},
});
Expand Down
1 change: 1 addition & 0 deletions test/onboard-installer-restore-intent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ const MARKER_SHA = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852
PATH: `${fakeBin}:${process.env.PATH || ""}`,
NEMOCLAW_NON_INTERACTIVE: "1",
NEMOCLAW_TEST_MANAGED_IMAGE_FALLBACK: "1",
NEMOCLAW_SANDBOX_PREBUILD: "1",
};
delete env["NEMOCLAW_RECREATE_SANDBOX"];
const result = spawnSync(process.execPath, [scriptPath], {
Expand Down
34 changes: 17 additions & 17 deletions test/onboard-messaging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const onboardScriptMocksPath = JSON.stringify(
);
beforeEach(() => {
vi.stubEnv("NEMOCLAW_TEST_MANAGED_IMAGE_FALLBACK", "1");
vi.stubEnv("NEMOCLAW_SANDBOX_PREBUILD", "1");
});
describe("onboard messaging", () => {
it("creates providers for messaging tokens and attaches them to the sandbox", {
Expand Down Expand Up @@ -513,7 +514,7 @@ const childProcess = require("node:child_process");
const { EventEmitter } = require("node:events");
const fs = require("node:fs");

const commands = [];
const commands = []; let dockerfileContent;
const registerCalls = [];
registry.registerSandbox({
name: "my-assistant",
Expand Down Expand Up @@ -556,15 +557,15 @@ childProcess.spawn = (...args) => {
child.pid = 4242;
const command = _n([args[0], ...(Array.isArray(args[1]) ? args[1] : [])]);
const entry = { command, env: args[2]?.env || null };
const dockerfileMatch = command.match(/--from ([^ ]+Dockerfile)/);
const dockerfileMatch = command.match(/(?:--from|-f) ([^ ]+Dockerfile)/);
if (dockerfileMatch) {
try {
entry.dockerfileContent = fs.readFileSync(dockerfileMatch[1], "utf-8");
entry.dockerfileContent = dockerfileContent = fs.readFileSync(dockerfileMatch[1], "utf-8");
} catch (error) {
entry.dockerfileReadError = String(error);
}
}
commands.push(entry);
commands.push({ ...entry, dockerfileContent: entry.dockerfileContent ?? dockerfileContent });
process.nextTick(() => {
child.stdout.emit("data", Buffer.from("Created sandbox: my-assistant\n"));
child.emit("close", 0);
Expand Down Expand Up @@ -628,7 +629,6 @@ const { createSandbox } = require(${onboardPath});
assert.match(createCommand.command, /--provider my-assistant-discord-bridge/);
assert.match(createCommand.command, /--provider my-assistant-slack-bridge/);
assert.match(createCommand.command, /--provider my-assistant-slack-app/);

assert.deepEqual(activeChannelsFromDockerfile(createCommand.dockerfileContent), [
"discord",
"slack",
Expand Down Expand Up @@ -674,7 +674,7 @@ const childProcess = require("node:child_process");
const { EventEmitter } = require("node:events");
const fs = require("node:fs");

const commands = [];
const commands = []; let dockerfileContent;
const registerCalls = [];
registry.registerSandbox({
name: "my-assistant",
Expand Down Expand Up @@ -715,15 +715,15 @@ childProcess.spawn = (...args) => {
child.pid = 4242;
const command = _n([args[0], ...(Array.isArray(args[1]) ? args[1] : [])]);
const entry = { command, env: args[2]?.env || null };
const dockerfileMatch = command.match(/--from ([^ ]+Dockerfile)/);
const dockerfileMatch = command.match(/(?:--from|-f) ([^ ]+Dockerfile)/);
if (dockerfileMatch) {
try {
entry.dockerfileContent = fs.readFileSync(dockerfileMatch[1], "utf-8");
entry.dockerfileContent = dockerfileContent = fs.readFileSync(dockerfileMatch[1], "utf-8");
} catch (error) {
entry.dockerfileReadError = String(error);
}
}
commands.push(entry);
commands.push({ ...entry, dockerfileContent: entry.dockerfileContent ?? dockerfileContent });
process.nextTick(() => {
child.stdout.emit("data", Buffer.from("Created sandbox: my-assistant\n"));
child.emit("close", 0);
Expand Down Expand Up @@ -827,7 +827,7 @@ const childProcess = require("node:child_process");
const { EventEmitter } = require("node:events");
const fs = require("node:fs");

const commands = [];
const commands = []; let dockerfileContent;
const registerCalls = [];
runner.run = (command, opts = {}) => {
const normalized = _n(command);
Expand Down Expand Up @@ -863,15 +863,15 @@ childProcess.spawn = (...args) => {
child.pid = 4242;
const command = _n([args[0], ...(Array.isArray(args[1]) ? args[1] : [])]);
const entry = { command, env: args[2]?.env || null };
const dockerfileMatch = command.match(/--from ([^ ]+Dockerfile)/);
const dockerfileMatch = command.match(/(?:--from|-f) ([^ ]+Dockerfile)/);
if (dockerfileMatch) {
try {
entry.dockerfileContent = fs.readFileSync(dockerfileMatch[1], "utf-8");
entry.dockerfileContent = dockerfileContent = fs.readFileSync(dockerfileMatch[1], "utf-8");
} catch (error) {
entry.dockerfileReadError = String(error);
}
}
commands.push(entry);
commands.push({ ...entry, dockerfileContent: entry.dockerfileContent ?? dockerfileContent });
process.nextTick(() => {
child.stdout.emit("data", Buffer.from("Created sandbox: my-assistant\n"));
child.emit("close", 0);
Expand Down Expand Up @@ -982,7 +982,7 @@ registry.registerSandbox({
messaging: { schemaVersion: 1, plan: ${messagingPlanLiteral(["whatsapp"], ["whatsapp"])} },
});

const commands = [];
const commands = []; let dockerfileContent;
const registerCalls = [];
runner.run = (command, opts = {}) => {
const normalized = _n(command);
Expand Down Expand Up @@ -1018,15 +1018,15 @@ childProcess.spawn = (...args) => {
child.pid = 4242;
const command = _n([args[0], ...(Array.isArray(args[1]) ? args[1] : [])]);
const entry = { command, env: args[2]?.env || null };
const dockerfileMatch = command.match(/--from ([^ ]+Dockerfile)/);
const dockerfileMatch = command.match(/(?:--from|-f) ([^ ]+Dockerfile)/);
if (dockerfileMatch) {
try {
entry.dockerfileContent = fs.readFileSync(dockerfileMatch[1], "utf-8");
entry.dockerfileContent = dockerfileContent = fs.readFileSync(dockerfileMatch[1], "utf-8");
} catch (error) {
entry.dockerfileReadError = String(error);
}
}
commands.push(entry);
commands.push({ ...entry, dockerfileContent: entry.dockerfileContent ?? dockerfileContent });
process.nextTick(() => {
child.stdout.emit("data", Buffer.from("Created sandbox: my-assistant\n"));
child.emit("close", 0);
Expand Down
1 change: 1 addition & 0 deletions test/onboard-reservation-recreate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ const { createSandbox } = require(${onboardPath});
env: workspaceEnv(workspace, {
NEMOCLAW_NON_INTERACTIVE: "1",
NEMOCLAW_TEST_MANAGED_IMAGE_FALLBACK: "1",
NEMOCLAW_SANDBOX_PREBUILD: "1",
}),
});

Expand Down
3 changes: 2 additions & 1 deletion test/onboard-sandbox-build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {

beforeEach(() => {
vi.stubEnv("NEMOCLAW_TEST_MANAGED_IMAGE_FALLBACK", "1");
vi.stubEnv("NEMOCLAW_SANDBOX_PREBUILD", "1");
});

describe("onboard helpers", () => {
Expand Down Expand Up @@ -448,7 +449,7 @@ sandboxBaseImage.resolveSandboxBaseImage = (options) => {
};
};
buildContext.stageOptimizedSandboxBuildContext = () => {
const buildCtx = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-openclaw-build-"));
const buildCtx = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-build-"));
const stagedDockerfile = path.join(buildCtx, "Dockerfile");
fs.writeFileSync(
stagedDockerfile,
Expand Down
10 changes: 10 additions & 0 deletions test/onboard-sandbox-recreation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { type CommandEntry, onboardScriptMocksPath } from "./helpers/onboard-spl

beforeEach(() => {
vi.stubEnv("NEMOCLAW_TEST_MANAGED_IMAGE_FALLBACK", "1");
vi.stubEnv("NEMOCLAW_SANDBOX_PREBUILD", "1");
});

describe("onboard helpers", () => {
Expand Down Expand Up @@ -1189,6 +1190,9 @@ const { createSandbox } = require(${onboardPath});
const credentialsPath = JSON.stringify(
path.join(repoRoot, "src", "lib", "credentials", "store.ts"),
);
const dockerExecPath = JSON.stringify(
path.join(repoRoot, "src", "lib", "adapters", "docker", "exec.ts"),
);

fs.mkdirSync(fakeBin, { recursive: true });
writeOkOpenshell(fakeBin);
Expand All @@ -1203,6 +1207,12 @@ const preflight = require(${preflightPath});
const credentials = require(${credentialsPath});
const childProcess = require("node:child_process");
const { EventEmitter } = require("node:events");
const dockerExec = require(${dockerExecPath});
dockerExec.dockerSpawn = () => {
const child = new EventEmitter();
process.nextTick(() => child.emit("close", 0));
return child;
};
const fs = require("node:fs");

const commands = [];
Expand Down
Loading