Tests: speed up media note prompt setup
This commit is contained in:
@@ -30,12 +30,22 @@ function makeResult(text: string) {
|
|||||||
async function withTempHome<T>(fn: (home: string) => Promise<T>): Promise<T> {
|
async function withTempHome<T>(fn: (home: string) => Promise<T>): Promise<T> {
|
||||||
const base = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-media-note-"));
|
const base = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-media-note-"));
|
||||||
const previousHome = process.env.HOME;
|
const previousHome = process.env.HOME;
|
||||||
|
const previousBundledSkills = process.env.CLAWDBOT_BUNDLED_SKILLS_DIR;
|
||||||
process.env.HOME = base;
|
process.env.HOME = base;
|
||||||
|
process.env.CLAWDBOT_BUNDLED_SKILLS_DIR = path.join(
|
||||||
|
base,
|
||||||
|
"bundled-skills",
|
||||||
|
);
|
||||||
try {
|
try {
|
||||||
vi.mocked(runEmbeddedPiAgent).mockReset();
|
vi.mocked(runEmbeddedPiAgent).mockReset();
|
||||||
return await fn(base);
|
return await fn(base);
|
||||||
} finally {
|
} finally {
|
||||||
process.env.HOME = previousHome;
|
process.env.HOME = previousHome;
|
||||||
|
if (previousBundledSkills === undefined) {
|
||||||
|
delete process.env.CLAWDBOT_BUNDLED_SKILLS_DIR;
|
||||||
|
} else {
|
||||||
|
process.env.CLAWDBOT_BUNDLED_SKILLS_DIR = previousBundledSkills;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await fs.rm(base, { recursive: true, force: true });
|
await fs.rm(base, { recursive: true, force: true });
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Reference in New Issue
Block a user