test(installer): wait for Windows cleanup completion
Windows CI / verify (push) Failing after 21s

This commit is contained in:
Sucukdeluxe
2026-08-12 03:27:29 +02:00
parent 0aebc701d8
commit 5bc58a0d85
+14 -7
View File
@@ -26,7 +26,16 @@ function findUninstaller(installationDirectory) {
.map((name) => path.join(installationDirectory, name))[0] || ''; .map((name) => path.join(installationDirectory, name))[0] || '';
} }
function main() { async function waitForPathRemoval(targetPath, timeoutMs = 10000) {
const deadline = Date.now() + timeoutMs;
while (fs.existsSync(targetPath)) {
if (Date.now() >= deadline) return false;
await new Promise((resolve) => setTimeout(resolve, 100));
}
return true;
}
async function main() {
if (process.platform !== 'win32') throw new Error('Installer smoke requires Windows'); if (process.platform !== 'win32') throw new Error('Installer smoke requires Windows');
if (process.env.CI !== 'true' && process.env.TWITCH_VOD_MANAGER_INSTALLER_SMOKE !== '1') { if (process.env.CI !== 'true' && process.env.TWITCH_VOD_MANAGER_INSTALLER_SMOKE !== '1') {
throw new Error('Installer smoke is restricted to CI or explicit TWITCH_VOD_MANAGER_INSTALLER_SMOKE=1 opt-in'); throw new Error('Installer smoke is restricted to CI or explicit TWITCH_VOD_MANAGER_INSTALLER_SMOKE=1 opt-in');
@@ -50,19 +59,17 @@ function main() {
env: { ...process.env, PACKAGED_APP_PATH: executablePath } env: { ...process.env, PACKAGED_APP_PATH: executablePath }
}); });
run(uninstallerPath, ['/S'], { cwd: smokeRoot }); run(uninstallerPath, ['/S'], { cwd: smokeRoot });
if (fs.existsSync(executablePath)) throw new Error('Silent uninstall left the packaged executable installed'); if (!await waitForPathRemoval(executablePath)) throw new Error('Silent uninstall left the packaged executable installed');
console.log(JSON.stringify({ failures: [], installerPath }, null, 2)); console.log(JSON.stringify({ failures: [], installerPath }, null, 2));
} finally { } finally {
if (uninstallerPath && fs.existsSync(uninstallerPath)) { if (uninstallerPath && fs.existsSync(uninstallerPath)) {
spawnSync(uninstallerPath, ['/S'], { cwd: smokeRoot, timeout: 240000, windowsHide: true, stdio: 'ignore' }); spawnSync(uninstallerPath, ['/S'], { cwd: smokeRoot, timeout: 240000, windowsHide: true, stdio: 'ignore' });
} }
fs.rmSync(smokeRoot, { recursive: true, force: true }); await fs.promises.rm(smokeRoot, { recursive: true, force: true, maxRetries: 10, retryDelay: 250 });
} }
} }
try { main().catch((error) => {
main();
} catch (error) {
console.error(error instanceof Error ? error.message : String(error)); console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1; process.exitCode = 1;
} });