test: cut low-value tests, rewrite the rest around behavior, parallelize lanes (#285)

This commit is contained in:
sudacode authored and GitHub committed 2026-10-05 00:07:44 -07:00
1 parent 4b6842d034
commit b48083ddd8
368 files changed
+18045 -60331

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
/**
* Runs `run` with the given process env values (`undefined` deletes a key) and restores the
* originals afterwards, even if `run` throws or rejects.
*/
export async function withEnv<T>(
overrides: Record<string, string | undefined>,
run: () => T | Promise<T>,
): Promise<T> {
const originals = Object.fromEntries(
Object.keys(overrides).map((key) => [key, process.env[key]]),
);
const apply = (values: Record<string, string | undefined>): void => {
for (const [key, value] of Object.entries(values)) {
if (value === undefined) delete process.env[key];
else process.env[key] = value;
}
};
apply(overrides);
try {
return await run();
} finally {
apply(originals);
}
}