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
This commit is contained in:
parent
afcddbd81b
commit
53b9328908
@ -37,7 +37,7 @@ npm-test-trap-sandbox:
|
|||||||
npm test --prefix tools/trap-sandbox/
|
npm test --prefix tools/trap-sandbox/
|
||||||
|
|
||||||
# Run Node-based tool integration tests.
|
# 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-test-integration-mcp-bridge:
|
||||||
npm run test:integration --prefix tools/mcp-bridge
|
npm run test:integration --prefix tools/mcp-bridge
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { spawn } from "node:child_process";
|
import { spawn } from "node:child_process";
|
||||||
|
import { existsSync } from "node:fs";
|
||||||
import { mkdtemp, rm } from "node:fs/promises";
|
import { mkdtemp, rm } from "node:fs/promises";
|
||||||
import { tmpdir } from "node:os";
|
import { tmpdir } from "node:os";
|
||||||
import { dirname, join } from "node:path";
|
import { dirname, join } from "node:path";
|
||||||
@ -142,10 +143,15 @@ export function startCraftos(
|
|||||||
args.push("--id", String(opts.computerId));
|
args.push("--id", String(opts.computerId));
|
||||||
}
|
}
|
||||||
if (opts.mountRepo) {
|
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(
|
args.push(
|
||||||
"--mount-ro", `/trapos=${REPO_ROOT}`,
|
"--mount-ro", `/trapos=${REPO_ROOT}`,
|
||||||
"--mount-ro", `/apis=${join(REPO_ROOT, "apis")}`,
|
"--mount-ro", `/apis=${join(REPO_ROOT, ".stage/apis")}`,
|
||||||
"--mount-ro", `/programs=${join(REPO_ROOT, "programs")}`,
|
"--mount-ro", `/programs=${join(REPO_ROOT, ".stage/programs")}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (process.platform === "darwin") {
|
if (process.platform === "darwin") {
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { spawn } from "node:child_process";
|
import { spawn } from "node:child_process";
|
||||||
import { createServer } from "node:http";
|
import { createServer } from "node:http";
|
||||||
|
import { existsSync } from "node:fs";
|
||||||
import { mkdtemp, rm } from "node:fs/promises";
|
import { mkdtemp, rm } from "node:fs/promises";
|
||||||
import { tmpdir } from "node:os";
|
import { tmpdir } from "node:os";
|
||||||
import { dirname, join } from "node:path";
|
import { dirname, join } from "node:path";
|
||||||
@ -148,14 +149,19 @@ export function startCraftos(
|
|||||||
const dataDir = await mkdtemp(join(tmpdir(), "trap-sandbox-it-"));
|
const dataDir = await mkdtemp(join(tmpdir(), "trap-sandbox-it-"));
|
||||||
const watchdog = setTimeout(() => controller.abort(), timeoutMs);
|
const watchdog = setTimeout(() => controller.abort(), timeoutMs);
|
||||||
try {
|
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[] = [
|
const args: string[] = [
|
||||||
"--directory", dataDir,
|
"--directory", dataDir,
|
||||||
"--headless",
|
"--headless",
|
||||||
"--mount-ro", `/staging=${LUA_DIR}`,
|
"--mount-ro", `/staging=${LUA_DIR}`,
|
||||||
"--mount-ro", `/trapos=${REPO_ROOT}`,
|
"--mount-ro", `/trapos=${REPO_ROOT}`,
|
||||||
"--mount-ro", `/apis=${join(REPO_ROOT, "apis")}`,
|
"--mount-ro", `/apis=${join(REPO_ROOT, ".stage/apis")}`,
|
||||||
"--mount-ro", `/servers=${join(REPO_ROOT, "servers")}`,
|
"--mount-ro", `/servers=${join(REPO_ROOT, ".stage/servers")}`,
|
||||||
"--mount-ro", `/programs=${join(REPO_ROOT, "programs")}`,
|
"--mount-ro", `/programs=${join(REPO_ROOT, ".stage/programs")}`,
|
||||||
];
|
];
|
||||||
if (opts.computerId !== undefined) {
|
if (opts.computerId !== undefined) {
|
||||||
args.push("--id", String(opts.computerId));
|
args.push("--id", String(opts.computerId));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user