mirror of
https://github.com/proxysoul/Empryo.git
synced 2026-11-07 06:25:57 -10:00
test: skip auto-format in edit tests via setFormatCache helper
- Add setFormatCache() to auto-format.ts for test overrides - Use setFormatCache(null) in edit-languages and edit-stack tests to prevent format detection from interfering with test assertions Co-Authored-By: SoulForge <[email protected]>
This commit is contained in:
3 files changed
+9
No files matched your search
@@ -22,6 +22,11 @@ export function resetFormatCache(): void {
|
||||
cachedFormatCmd = undefined;
|
||||
}
|
||||
|
||||
/** Override cached format command (e.g. set to null in tests to skip formatting). */
|
||||
export function setFormatCache(cmd: string | null): void {
|
||||
cachedFormatCmd = cmd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-format a file after edit. Returns true if formatted, false if skipped/failed.
|
||||
* Uses cached format command to avoid re-detecting project profile on every edit.
|
||||
|
||||
@@ -2,6 +2,7 @@ import { describe, expect, it, beforeEach, afterAll } from "bun:test";
|
||||
import { clearEditStacks, undoEditTool } from "../src/core/tools/edit-stack.js";
|
||||
import { editFileTool } from "../src/core/tools/edit-file.js";
|
||||
import { multiEditTool } from "../src/core/tools/multi-edit.js";
|
||||
import { setFormatCache } from "../src/core/tools/auto-format.js";
|
||||
import { writeFile, mkdir, rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
@@ -16,6 +17,7 @@ async function writeTestFile(name: string, content: string): Promise<string> {
|
||||
|
||||
beforeEach(async () => {
|
||||
clearEditStacks();
|
||||
setFormatCache(null);
|
||||
await mkdir(TMP, { recursive: true });
|
||||
});
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
} from "../src/core/tools/edit-stack.js";
|
||||
import { editFileTool, buildRichEditError } from "../src/core/tools/edit-file.js";
|
||||
import { multiEditTool } from "../src/core/tools/multi-edit.js";
|
||||
import { setFormatCache } from "../src/core/tools/auto-format.js";
|
||||
import { writeFile, mkdir, rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
@@ -21,6 +22,7 @@ async function writeTestFile(name: string, content: string): Promise<string> {
|
||||
|
||||
beforeEach(async () => {
|
||||
clearEditStacks();
|
||||
setFormatCache(null);
|
||||
await mkdir(TMP, { recursive: true });
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user