You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by as...@apache.org on 2026/08/26 03:43:01 UTC

(maka) branch main updated: refactor(windows): reuse packaged verifier for rollback (#3707)

This is an automated email from the ASF dual-hosted git repository.

Astro-Han pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/maka.git


The following commit(s) were added to refs/heads/main by this push:
     new b30d01302 refactor(windows): reuse packaged verifier for rollback (#3707)
b30d01302 is described below

commit b30d01302cf904213db29f996aea8f6d6ace2e7f
Author: testikun <bu...@gmail.com>
AuthorDate: Wed Aug 26 11:42:56 2026 +0800

    refactor(windows): reuse packaged verifier for rollback (#3707)
    
    * refactor(windows): reuse packaged verifier for rollback
    
    Refs #3575
    
    Generated-by: Codex
    
    * fix(windows): verify rollback with current artifact contract
    
    Generated-by: OpenAI Codex
    
    * fix(windows): prepare rollback smoke directory
    
    Generated-by: OpenAI Codex
    
    * fix(windows): narrow rollback verifier reuse
    
    Keep the rollback gate focused on restored launchability and product version after the tree and registry checks already prove restoration. Reuse the shared renderer smoke without rerunning the full packaged-app contract, and pin the delegation boundary in the harness test.
    
    Generated-by: OpenAI Codex
    
    ---------
    
    Co-authored-by: testikun <te...@google.com>
---
 scripts/verify-windows-harness.test.mjs       | 39 ++++++++++++++++
 scripts/verify-windows-installer-rollback.mjs | 64 +++++++++------------------
 2 files changed, 59 insertions(+), 44 deletions(-)

diff --git a/scripts/verify-windows-harness.test.mjs b/scripts/verify-windows-harness.test.mjs
index 15e6d976c..81231b14c 100644
--- a/scripts/verify-windows-harness.test.mjs
+++ b/scripts/verify-windows-harness.test.mjs
@@ -45,6 +45,7 @@ import {
 import {
   deleteUninstallRegistrationForInstall,
   readUninstallDisplayVersionsForInstall,
+  verifyRestoredWindowsInstallation,
 } from './verify-windows-installer-rollback.mjs';
 import {
   completeInstalledApplicationUninstall,
@@ -286,6 +287,44 @@ it('uses the product SemVer contract throughout Windows release verification', (
   );
 });
 
+it('reuses the packaged renderer smoke without widening rollback verification', async () => {
+  const calls = [];
+  const installDirectory = 'C:\\fixture\\installed';
+  const workingDirectory = 'C:\\fixture\\smoke';
+  const executable = join(installDirectory, 'Maka.exe');
+  const run = async (command, args, options) => {
+    calls.push({ command, args, options });
+    return { stdout: '1.2.3.0', stderr: '' };
+  };
+  const smokeRenderer = async (executable, options) => {
+    calls.push({ executable, options });
+  };
+
+  await verifyRestoredWindowsInstallation(installDirectory, workingDirectory, '1.2.3', {
+    run,
+    smokeRenderer,
+  });
+
+  assert.deepEqual(calls, [
+    {
+      executable,
+      options: {
+        workingDirectory,
+      },
+    },
+    {
+      command: 'powershell',
+      args: [
+        '-NoProfile',
+        '-NonInteractive',
+        '-Command',
+        `(Get-Item '${executable}').VersionInfo.ProductVersion`,
+      ],
+      options: { timeoutMs: 30_000 },
+    },
+  ]);
+});
+
 async function makeTree(shape) {
   const root = await mkdtemp(join(tmpdir(), 'maka-harness-test-'));
   temporaryRoots.push(root);
diff --git a/scripts/verify-windows-installer-rollback.mjs b/scripts/verify-windows-installer-rollback.mjs
index 8f711ca90..d0db35da5 100644
--- a/scripts/verify-windows-installer-rollback.mjs
+++ b/scripts/verify-windows-installer-rollback.mjs
@@ -25,12 +25,8 @@ import { pathToFileURL } from 'node:url';
 import {
   diffTreeManifests,
   directoryTreeManifest,
-  findRendererTarget,
-  isolatedUserEnv,
-  waitForDevToolsPort,
-  waitForUsableRenderer,
   runCommand,
-  stopChild,
+  smokePackagedRenderer,
 } from './verify-packaged-app.mjs';
 import {
   installerVersion,
@@ -173,43 +169,21 @@ $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,
+  { smokeRenderer = smokePackagedRenderer, run } = {},
+) {
+  await mkdir(workingDirectory, { recursive: true });
+  const installedExecutable = join(installDirectory, executableName);
+  // The caller has already proved the restored tree byte-identical. Keep this
+  // gate focused on rollback-specific evidence: the restored candidate still
+  // launches and reports the expected version, while the package step owns the
+  // full artifact/sandbox contract.
+  await smokeRenderer(installedExecutable, { workingDirectory });
+  const actualVersion = await readInstalledProductVersion(installedExecutable, { run });
+  assertWindowsProductVersion(actualVersion, expectedVersion);
 }
 
 /**
@@ -240,6 +214,7 @@ export async function verifyWindowsInstallerRollback(
     platform = process.platform,
     makeTemporaryDirectory = () => mkdtemp(join(tmpdir(), 'maka-rollback-')),
     run = runCommand,
+    smokeRenderer = smokePackagedRenderer,
   } = {},
 ) {
   if (platform !== 'win32') {
@@ -364,10 +339,11 @@ export async function verifyWindowsInstallerRollback(
     }
 
     step('asserting the restored installation launches');
-    await assertLaunchable(
-      installedExecutable,
+    await verifyRestoredWindowsInstallation(
+      installDirectory,
       join(temporaryDirectory, 'restored-smoke'),
       candidateVersion,
+      { run, smokeRenderer },
     );
     await waitForInstalledProcessesToExit(installDirectory);
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org