perf(test): trim fixture and serialization overhead in integration suites

This commit is contained in:
Peter Steinberger
2026-03-03 01:08:52 +00:00
parent 588fbd5b68
commit d7bafae387
5 changed files with 70 additions and 114 deletions

View File

@@ -8,12 +8,13 @@ const baseGitEnv = {
GIT_CONFIG_NOSYSTEM: "1",
GIT_TERMINAL_PROMPT: "0",
};
const baseRunEnv: NodeJS.ProcessEnv = { ...process.env, ...baseGitEnv };
const run = (cwd: string, cmd: string, args: string[] = [], env?: NodeJS.ProcessEnv) => {
return execFileSync(cmd, args, {
cwd,
encoding: "utf8",
env: { ...process.env, ...baseGitEnv, ...env },
env: env ? { ...baseRunEnv, ...env } : baseRunEnv,
}).trim();
};

View File

@@ -84,10 +84,11 @@ function runScript(
stdout: string;
stderr: string;
} {
const cacheKey = JSON.stringify({
homeDir,
extraEnv: Object.entries(extraEnv).toSorted(([a], [b]) => a.localeCompare(b)),
});
const extraEnvKey = Object.keys(extraEnv)
.toSorted((a, b) => a.localeCompare(b))
.map((key) => `${key}=${extraEnv[key] ?? ""}`)
.join("\u0001");
const cacheKey = `${homeDir}\u0000${extraEnvKey}`;
const cached = runScriptCache.get(cacheKey);
if (cached) {
return cached;