mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-09 07:10:34 +01:00
test: isolate executable OpenCode fixture copies
This commit is contained in:
2 files changed
+19
-7
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
chmod,
|
||||
copyFile,
|
||||
lstat,
|
||||
mkdir,
|
||||
mkdtemp,
|
||||
@@ -11,7 +12,7 @@ import {
|
||||
} from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join, resolve } from "node:path";
|
||||
import { afterAll, afterEach, describe, expect, it } from "vitest";
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
NATIVE_RUNTIME_ASSET_SCHEMA,
|
||||
@@ -29,7 +30,15 @@ import {
|
||||
} from "./opencode-server-driver.js";
|
||||
|
||||
const roots: string[] = [];
|
||||
const fixture = resolve("test/fixtures/fake-opencode-server.mjs");
|
||||
let fixtureRoot: string | undefined;
|
||||
let fixture: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
fixtureRoot = await mkdtemp(join(tmpdir(), "paperclip-opencode-fixture-"));
|
||||
fixture = join(fixtureRoot, "fake-opencode-server.mjs");
|
||||
// Other suites execute this fixture concurrently. Never chmod their source.
|
||||
await copyFile(resolve("test/fixtures/fake-opencode-server.mjs"), fixture);
|
||||
});
|
||||
|
||||
function runtimeContext(
|
||||
skillRoot: string,
|
||||
@@ -98,7 +107,7 @@ afterEach(async () => {
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await chmod(fixture, 0o644);
|
||||
if (fixtureRoot) await rm(fixtureRoot, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
describe("OpenCodeServerDriver", () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { chmod, mkdtemp, rm } from "node:fs/promises";
|
||||
import { chmod, copyFile, mkdtemp, rm } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join, resolve } from "node:path";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
OpenCodeServerDriver,
|
||||
} from "./opencode-server-driver.js";
|
||||
|
||||
const fixture = resolve("test/fixtures/fake-opencode-server.mjs");
|
||||
const roots: string[] = [];
|
||||
|
||||
afterEach(async () => {
|
||||
@@ -18,12 +17,16 @@ afterEach(async () => {
|
||||
|
||||
describe("prepared OpenCode context transport", () => {
|
||||
it("sends prepared initial prompts without the proxy task envelope", async () => {
|
||||
await chmod(fixture, 0o755);
|
||||
const root = await mkdtemp(join(tmpdir(), "paperclip-opencode-prepared-"));
|
||||
roots.push(root);
|
||||
// Executable modes belong to the test's copy, not the shared checkout.
|
||||
const fixture = join(root, "fake-opencode-server.mjs");
|
||||
await copyFile(resolve("test/fixtures/fake-opencode-server.mjs"), fixture);
|
||||
await chmod(fixture, 0o755);
|
||||
const workspace = await mkdtemp(
|
||||
join(tmpdir(), "paperclip-opencode-prepared-workspace-"),
|
||||
);
|
||||
roots.push(root, workspace);
|
||||
roots.push(workspace);
|
||||
const submitted: Record<string, unknown>[] = [];
|
||||
const driver = new OpenCodeServerDriver({
|
||||
model: "openrouter/deepseek/deepseek-v4-flash-0731",
|
||||
|
||||
Reference in new issue
Block a user