fix: broken tests and stale .env.example
- Fix container-runner bug: stopContainer() returns void but was passed to exec() as a command string. Replace with direct call and try/catch. - Mock container-runtime in tests so they don't need Docker running. - Increase claw-skill test timeout to handle slower python startup. - Clear .env.example (telegram token was added by mistake). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
TELEGRAM_BOT_TOKEN=
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { spawnSync } from 'child_process';
|
|||||||
import { describe, expect, it } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
|
|
||||||
describe('claw skill script', () => {
|
describe('claw skill script', () => {
|
||||||
it('exits zero after successful structured output even if the runtime is terminated', () => {
|
it('exits zero after successful structured output even if the runtime is terminated', { timeout: 20000 }, () => {
|
||||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claw-skill-test-'));
|
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claw-skill-test-'));
|
||||||
const binDir = path.join(tempDir, 'bin');
|
const binDir = path.join(tempDir, 'bin');
|
||||||
fs.mkdirSync(binDir, { recursive: true });
|
fs.mkdirSync(binDir, { recursive: true });
|
||||||
|
|||||||
@@ -51,6 +51,14 @@ vi.mock('./mount-security.js', () => ({
|
|||||||
validateAdditionalMounts: vi.fn(() => []),
|
validateAdditionalMounts: vi.fn(() => []),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// Mock container-runtime
|
||||||
|
vi.mock('./container-runtime.js', () => ({
|
||||||
|
CONTAINER_RUNTIME_BIN: 'docker',
|
||||||
|
hostGatewayArgs: () => [],
|
||||||
|
readonlyMountArgs: (h: string, c: string) => ['-v', `${h}:${c}:ro`],
|
||||||
|
stopContainer: vi.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
// Mock OneCLI SDK
|
// Mock OneCLI SDK
|
||||||
vi.mock('@onecli-sh/sdk', () => ({
|
vi.mock('@onecli-sh/sdk', () => ({
|
||||||
OneCLI: class {
|
OneCLI: class {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Container Runner for NanoClaw
|
* Container Runner for NanoClaw
|
||||||
* Spawns agent execution in containers and handles IPC
|
* Spawns agent execution in containers and handles IPC
|
||||||
*/
|
*/
|
||||||
import { ChildProcess, exec, spawn } from 'child_process';
|
import { ChildProcess, spawn } from 'child_process';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
@@ -431,15 +431,15 @@ export async function runContainerAgent(
|
|||||||
{ group: group.name, containerName },
|
{ group: group.name, containerName },
|
||||||
'Container timeout, stopping gracefully',
|
'Container timeout, stopping gracefully',
|
||||||
);
|
);
|
||||||
exec(stopContainer(containerName), { timeout: 15000 }, (err) => {
|
try {
|
||||||
if (err) {
|
stopContainer(containerName);
|
||||||
logger.warn(
|
} catch (err) {
|
||||||
{ group: group.name, containerName, err },
|
logger.warn(
|
||||||
'Graceful stop failed, force killing',
|
{ group: group.name, containerName, err },
|
||||||
);
|
'Graceful stop failed, force killing',
|
||||||
container.kill('SIGKILL');
|
);
|
||||||
}
|
container.kill('SIGKILL');
|
||||||
});
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let timeout = setTimeout(killOnTimeout, timeoutMs);
|
let timeout = setTimeout(killOnTimeout, timeoutMs);
|
||||||
|
|||||||
Reference in New Issue
Block a user