From 53b9328908d1da2c8add2e6e4d3c4cd9f52392c4 Mon Sep 17 00:00:00 2001 From: Guillaume ARM Date: Tue, 16 Jun 2026 22:40:57 +0200 Subject: [PATCH] test(integration): mount staged lua dirs and guard on .stage - Mount .stage/apis, .stage/programs (and .stage/servers) instead of repo roots - Fail fast with a clear message when .stage/ is missing - Make npm-test-integration depend on stage --- just/npm.just | 2 +- tools/mcp-bridge/test-integration/harness.ts | 10 ++++++++-- tools/trap-sandbox/test-integration/harness.ts | 12 +++++++++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/just/npm.just b/just/npm.just index cedceda..6f8b09c 100644 --- a/just/npm.just +++ b/just/npm.just @@ -37,7 +37,7 @@ npm-test-trap-sandbox: npm test --prefix tools/trap-sandbox/ # Run Node-based tool integration tests. -npm-test-integration: npm-test-integration-mcp-bridge npm-test-integration-trap-sandbox +npm-test-integration: stage npm-test-integration-mcp-bridge npm-test-integration-trap-sandbox npm-test-integration-mcp-bridge: npm run test:integration --prefix tools/mcp-bridge diff --git a/tools/mcp-bridge/test-integration/harness.ts b/tools/mcp-bridge/test-integration/harness.ts index d4ed622..e3e906d 100644 --- a/tools/mcp-bridge/test-integration/harness.ts +++ b/tools/mcp-bridge/test-integration/harness.ts @@ -1,4 +1,5 @@ import { spawn } from "node:child_process"; +import { existsSync } from "node:fs"; import { mkdtemp, rm } from "node:fs/promises"; import { tmpdir } from "node:os"; import { dirname, join } from "node:path"; @@ -142,10 +143,15 @@ export function startCraftos( args.push("--id", String(opts.computerId)); } if (opts.mountRepo) { + if (!existsSync(join(REPO_ROOT, ".stage/apis"))) { + throw new Error( + ".stage/ is missing — run `just stage` (or use `just test-integration`) before the integration tests.", + ); + } args.push( "--mount-ro", `/trapos=${REPO_ROOT}`, - "--mount-ro", `/apis=${join(REPO_ROOT, "apis")}`, - "--mount-ro", `/programs=${join(REPO_ROOT, "programs")}`, + "--mount-ro", `/apis=${join(REPO_ROOT, ".stage/apis")}`, + "--mount-ro", `/programs=${join(REPO_ROOT, ".stage/programs")}`, ); } if (process.platform === "darwin") { diff --git a/tools/trap-sandbox/test-integration/harness.ts b/tools/trap-sandbox/test-integration/harness.ts index 6da11d0..fc7ec7f 100644 --- a/tools/trap-sandbox/test-integration/harness.ts +++ b/tools/trap-sandbox/test-integration/harness.ts @@ -1,5 +1,6 @@ import { spawn } from "node:child_process"; import { createServer } from "node:http"; +import { existsSync } from "node:fs"; import { mkdtemp, rm } from "node:fs/promises"; import { tmpdir } from "node:os"; import { dirname, join } from "node:path"; @@ -148,14 +149,19 @@ export function startCraftos( const dataDir = await mkdtemp(join(tmpdir(), "trap-sandbox-it-")); const watchdog = setTimeout(() => controller.abort(), timeoutMs); try { + if (!existsSync(join(REPO_ROOT, ".stage/apis"))) { + throw new Error( + ".stage/ is missing — run `just stage` (or use `just test-integration`) before the integration tests.", + ); + } const args: string[] = [ "--directory", dataDir, "--headless", "--mount-ro", `/staging=${LUA_DIR}`, "--mount-ro", `/trapos=${REPO_ROOT}`, - "--mount-ro", `/apis=${join(REPO_ROOT, "apis")}`, - "--mount-ro", `/servers=${join(REPO_ROOT, "servers")}`, - "--mount-ro", `/programs=${join(REPO_ROOT, "programs")}`, + "--mount-ro", `/apis=${join(REPO_ROOT, ".stage/apis")}`, + "--mount-ro", `/servers=${join(REPO_ROOT, ".stage/servers")}`, + "--mount-ro", `/programs=${join(REPO_ROOT, ".stage/programs")}`, ]; if (opts.computerId !== undefined) { args.push("--id", String(opts.computerId));