Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions scripts/verify-windows-harness.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { waitForInstalledProductVersion } from './verify-windows-autoupdate.mjs'
import {
deleteUninstallRegistrationForInstall,
readUninstallDisplayVersionsForInstall,
verifyRestoredWindowsInstallation,
} from './verify-windows-installer-rollback.mjs';
import {
completeInstalledApplicationUninstall,
Expand Down Expand Up @@ -167,6 +168,31 @@ it('uses the product SemVer contract throughout Windows release verification', (
);
});

it('delegates restored-installation checks to the legacy packaged-app verifier', async () => {
const calls = [];
const run = async () => ({ stdout: '', stderr: '' });
const verifyApp = async (appDirectory, options) => {
calls.push({ appDirectory, options });
};

await verifyRestoredWindowsInstallation('C:\\fixture\\installed', 'C:\\fixture\\smoke', '1.2.3', {
run,
verifyApp,
});

assert.deepEqual(calls, [
{
appDirectory: 'C:\\fixture\\installed',
options: {
artifactContract: 'legacy-baseline',
expectedVersion: '1.2.3',
run,
workingDirectory: 'C:\\fixture\\smoke',
},
},
]);
});

async function makeTree(shape) {
const root = await mkdtemp(join(tmpdir(), 'maka-harness-test-'));
temporaryRoots.push(root);
Expand Down
75 changes: 24 additions & 51 deletions scripts/verify-windows-installer-rollback.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,22 @@
*/

import { spawn } from 'node:child_process';
import { access, cp, mkdir, mkdtemp, readdir, rm, writeFile } from 'node:fs/promises';
import { access, cp, mkdtemp, readdir, rm, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import {
diffTreeManifests,
directoryTreeManifest,
findRendererTarget,
isolatedUserEnv,
waitForDevToolsPort,
waitForUsableRenderer,
runCommand,
stopChild,
} from './verify-packaged-app.mjs';
import { diffTreeManifests, directoryTreeManifest, runCommand } from './verify-packaged-app.mjs';
import {
installerVersion,
waitForInstalledProcessesToExit,
waitForUninstallRegistrationToClear,
waitUntilMissing,
} from './verify-windows-installer-lifecycle.mjs';
import { assertWindowsProductVersion, powerShellLiteral } from './verify-windows-x64.mjs';
import {
assertWindowsProductVersion,
powerShellLiteral,
verifyPackagedWindowsApp,
} from './verify-windows-x64.mjs';

const uninstallExecutableName = 'Uninstall Maka.exe';
const executableName = 'Maka.exe';
Expand Down Expand Up @@ -173,43 +168,19 @@ $entries | ForEach-Object { Remove-Item -LiteralPath $_.Path -Recurse -Force }
});
}

async function assertLaunchable(installedExecutable, workingDirectory, expectedVersion) {
const home = join(workingDirectory, 'home');
const userData = join(workingDirectory, 'user-data');
const userEnv = isolatedUserEnv(home);
await mkdir(home, { recursive: true });
await mkdir(userData, { recursive: true });
await mkdir(userEnv.APPDATA, { recursive: true });
await mkdir(userEnv.LOCALAPPDATA, { recursive: true });
const child = spawn(
installedExecutable,
['--remote-debugging-port=0', `--user-data-dir=${userData}`, '--enable-logging=stderr'],
{
cwd: workingDirectory,
env: { ...process.env, MAKA_SKIP_SHELL_ENV: '1', ...userEnv },
stdio: ['ignore', 'ignore', 'pipe'],
},
);
let stderr = '';
child.stderr.setEncoding('utf8');
child.stderr.on('data', (chunk) => {
stderr = `${stderr}${chunk}`.slice(-16_384);
});
try {
const cdpPort = await waitForDevToolsPort(child);
const target = await findRendererTarget(cdpPort, child);
await waitForUsableRenderer(target.webSocketDebuggerUrl, child, {
description: 'Restored app renderer',
}).catch((error) => {
throw new Error(`${error.message}${stderr.trim() ? `\n${stderr.trim()}` : ''}`, {
cause: error,
});
});
const productVersion = await readInstalledProductVersion(installedExecutable);
assertWindowsProductVersion(productVersion, expectedVersion);
} finally {
await stopChild(child);
}
export async function verifyRestoredWindowsInstallation(
installDirectory,
workingDirectory,
expectedVersion,
{ verifyApp = verifyPackagedWindowsApp, run } = {},
) {
const options = {
artifactContract: 'legacy-baseline',
expectedVersion,
workingDirectory,
};
if (run) options.run = run;
await verifyApp(installDirectory, options);
}

/**
Expand Down Expand Up @@ -240,6 +211,7 @@ export async function verifyWindowsInstallerRollback(
platform = process.platform,
makeTemporaryDirectory = () => mkdtemp(join(tmpdir(), 'maka-rollback-')),
run = runCommand,
verifyApp = verifyPackagedWindowsApp,
} = {},
) {
if (platform !== 'win32') {
Expand Down Expand Up @@ -364,10 +336,11 @@ export async function verifyWindowsInstallerRollback(
}

step('asserting the restored installation launches');
await assertLaunchable(
installedExecutable,
await verifyRestoredWindowsInstallation(
installDirectory,
join(temporaryDirectory, 'restored-smoke'),
candidateVersion,
{ run, verifyApp },
);
await waitForInstalledProcessesToExit(installDirectory);

Expand Down