From df68b8100673a9e5aff6b95c941849cff710fbc7 Mon Sep 17 00:00:00 2001 From: Shakker Date: Sat, 20 Jun 2026 19:52:37 +0100 Subject: [PATCH] fix: isolate bundled probe env --- ...led-plugin-install-uninstall-probe.test.ts | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/test/scripts/bundled-plugin-install-uninstall-probe.test.ts b/test/scripts/bundled-plugin-install-uninstall-probe.test.ts index 37e391594f4c..2064971d4bbd 100644 --- a/test/scripts/bundled-plugin-install-uninstall-probe.test.ts +++ b/test/scripts/bundled-plugin-install-uninstall-probe.test.ts @@ -7,6 +7,7 @@ import os from "node:os"; import path from "node:path"; import { pathToFileURL } from "node:url"; import { afterEach, describe, expect, it, vi } from "vitest"; +import { withEnvAsync } from "../../src/test-utils/env.js"; const tempDirs: string[] = []; const probePath = path.resolve("scripts/e2e/lib/bundled-plugin-install-uninstall/probe.mjs"); @@ -97,28 +98,11 @@ function runRuntimeSmoke(root: string, args: string[]) { } async function importRuntimeSmokeWithEnv(env: Record) { - const previous = new Map(); - for (const [key, value] of Object.entries(env)) { - previous.set(key, process.env[key]); - if (value === undefined) { - delete process.env[key]; - } else { - process.env[key] = value; - } - } - try { + return await withEnvAsync(env, async () => { return await import( `${pathToFileURL(runtimeSmokePath).href}?case=${Date.now()}-${Math.random()}` ); - } finally { - for (const [key, value] of previous.entries()) { - if (value === undefined) { - delete process.env[key]; - } else { - process.env[key] = value; - } - } - } + }); } async function listenOnLoopback(server: HttpServer | NetServer): Promise {