mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 01:31:08 +00:00
test(scripts): reuse temp dir helpers in repo fixtures
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { mkdirSync, writeFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { createScriptTestHarness } from "./test-helpers.js";
|
||||
|
||||
const scriptPath = path.join(process.cwd(), "scripts", "committer");
|
||||
const tempRepos: string[] = [];
|
||||
const { createTempDir } = createScriptTestHarness();
|
||||
|
||||
function run(cwd: string, command: string, args: string[]) {
|
||||
return execFileSync(command, args, {
|
||||
@@ -19,8 +19,7 @@ function git(cwd: string, ...args: string[]) {
|
||||
}
|
||||
|
||||
function createRepo() {
|
||||
const repo = mkdtempSync(path.join(tmpdir(), "committer-test-"));
|
||||
tempRepos.push(repo);
|
||||
const repo = createTempDir("committer-test-");
|
||||
|
||||
git(repo, "init", "-q");
|
||||
git(repo, "config", "user.email", "test@example.com");
|
||||
@@ -47,15 +46,6 @@ function committedPaths(repo: string) {
|
||||
return output.split("\n").filter(Boolean).toSorted();
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
while (tempRepos.length > 0) {
|
||||
const repo = tempRepos.pop();
|
||||
if (repo) {
|
||||
rmSync(repo, { force: true, recursive: true });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
describe("scripts/committer", () => {
|
||||
it("accepts supported path argument shapes", () => {
|
||||
const cases = [
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { stageBundledPluginRuntimeDeps } from "../../scripts/stage-bundled-plugin-runtime-deps.mjs";
|
||||
import { createScriptTestHarness } from "./test-helpers.js";
|
||||
|
||||
const { createTempDir } = createScriptTestHarness();
|
||||
|
||||
describe("stageBundledPluginRuntimeDeps", () => {
|
||||
function createBundledPluginFixture(params: {
|
||||
packageJson: Record<string, unknown>;
|
||||
pluginId?: string;
|
||||
}) {
|
||||
const repoRoot = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-runtime-deps-"));
|
||||
const repoRoot = createTempDir("openclaw-runtime-deps-");
|
||||
const pluginId = params.pluginId ?? "fixture-plugin";
|
||||
const pluginDir = path.join(repoRoot, "dist", "extensions", pluginId);
|
||||
fs.mkdirSync(pluginDir, { recursive: true });
|
||||
|
||||
Reference in New Issue
Block a user