The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(install): settle source runtime before desktop smoke
ethernet0b8df3672859
diff --git a/tests-js/scripts/desktop-smoke.test.ts b/tests-js/scripts/desktop-smoke.test.tsindex 43b48f3082d..4e7c79f51e4 100644--- a/tests-js/scripts/desktop-smoke.test.ts+++ b/tests-js/scripts/desktop-smoke.test.ts@@ -300,6 +300,50 @@ test('driver strips caller secrets and records missing executables as failure wi} finally { fs.rmSync(home, { recursive: true, force: true }) }})+test.runIf(process.platform !== 'win32')('NEW source smoke settles the clean runtime before Electron launch', async (): Promise<void> => {+ const workspace = fs.mkdtempSync(path.join(os.tmpdir(), 'smoke-source-settle-'))+ const root = path.join(workspace, 'source')+ const home = path.join(workspace, 'home')+ const out = path.join(workspace, 'out')+ const userData = path.join(workspace, 'user-data')+ const exe = path.join(root, 'fake-desktop')+ const launcher = path.join(root, '.hermes', 'bin', 'hermes')+ const witness = path.join(workspace, 'settled')++ try {+ fs.mkdirSync(path.dirname(launcher), { recursive: true })+ fs.writeFileSync(exe, '#!/bin/sh\nexit 1\n')+ fs.chmodSync(exe, 0o755)+ fs.writeFileSync(launcher, `#!/bin/sh+set -eu+[ "$1" = status ]+[ "$HERMES_HOME" = ${JSON.stringify(home)} ]+[ "$HOME" = ${JSON.stringify(path.join(home, '.desktop-smoke-home'))} ]+[ -z "\${PM_E2E_LEAK-}" ]+printf 'clean source runtime settled\\n'+: > ${JSON.stringify(witness)}+`)+ fs.chmodSync(launcher, 0o755)++ const refuseLaunch = async (): Promise<never> => {+ expect(fs.existsSync(witness)).toBe(true)+ throw new Error('launch observed settled runtime')+ }++ const prior = process.env.PM_E2E_LEAK+ process.env.PM_E2E_LEAK = 'must be stripped'++ try {+ await expect(runInstalledDesktopSmoke({ exe, root, origin: 'source', home, 'user-data': userData,+ out, phase: 'new', 'expect-commit': 'a'.repeat(40) }, refuseLaunch)).rejects.toThrow('launch observed settled runtime')+ } finally {+ if (prior === undefined) { delete process.env.PM_E2E_LEAK } else { process.env.PM_E2E_LEAK = prior }+ }++ expect(fs.readFileSync(path.join(out, 'desktop-source-settle-new.log'), 'utf8')).toContain('clean source runtime settled')+ } finally { fs.rmSync(workspace, { recursive: true, force: true }) }+})+test('predictSmokeHermesHome replays the bundle banner through the shared resolver', (): void => {const launchEnv = { HERMES_HOME: '/pinned/home', HERMES_DESKTOP_USER_DATA_DIR: '/pinned/userdata', LOCALAPPDATA: 'C:/Users/runner/AppData/Local' }// No baked env: the driver's own HERMES_HOME pin wins.diff --git a/tests/install/e2e-assets/desktop-smoke.ts b/tests/install/e2e-assets/desktop-smoke.tsindex a1a0a29373b..46c6c6c635d 100644--- a/tests/install/e2e-assets/desktop-smoke.ts+++ b/tests/install/e2e-assets/desktop-smoke.ts@@ -1,6 +1,7 @@+import { spawnSync } from 'node:child_process'import fs from 'node:fs'-import os from 'node:os'import { createRequire } from 'node:module'+import os from 'node:os'import path from 'node:path'import { pathToFileURL } from 'node:url'import { parseArgs } from 'node:util'@@ -12,10 +13,11 @@ import { resolveDesktopHermesHome } from '../../../apps/desktop/electron/data-paimport { applyBundleEnvironment } from '../../../apps/desktop/scripts/bundle-env.mjs'import { readChatIdentity, runDesktopChatSmoke, waitForChatReady } from '../../../tests-js/scripts/desktop-chat-smoke.ts'import { assertBackendOrigin, localBackendProcess, readBundledBundleEnv, readInstallationCommit } from '../../../tests-js/scripts/desktop-smoke-process.ts'-import { type SmokeEnvironment, smokeEnvironment, within } from './smoke-env.mjs'import { validateMockUrl, writeEnvFile, writeMockProviderConfig } from '../../../tests-js/scripts/mock-provider-config.ts'import { type MockServer, startMockServer } from '../../../tests-js/scripts/mock-server.ts'+import { type SmokeEnvironment, smokeEnvironment, within } from './smoke-env.mjs'+const require = createRequire(import.meta.url)const { pickAppWindow }: { pickAppWindow: (app: ElectronApplication, log: (message: string) => void) => Promise<Page> } = require('./update-ui.cjs')const { prepareWindowForInput }: { prepareWindowForInput: (app: ElectronApplication, page: Page) => Promise<void> } = require('./window-input.cjs')@@ -188,6 +190,42 @@ function captureBackendLogs(homes: readonly string[], outDir: string, phase: str}}+/**+ * A source update can be current under the CI driver's inherited environment+ * but still owe a dependency/product refresh in the clean app environment.+ * If Electron owns that first clean startup, its backend replaces the running+ * bundle and Electron intentionally relaunches; Playwright then reports the+ * expected renderer teardown as "Target crashed/closed". Settle the source+ * runtime before Electron starts, using the exact environment it will inherit.+ */+export function settleSourceDesktopRuntime(options: SmokeOptions, launch: Launch): void {+ if (options.origin !== 'source' || options.phase !== 'new') { return }++ const suffix = process.platform === 'win32' ? '.exe' : ''+ const candidates = [+ path.join(options.root, '.hermes', 'bin', `hermes${suffix}`),+ process.platform === 'win32'+ ? path.join(options.root, 'venv', 'Scripts', 'hermes.exe')+ : path.join(options.root, 'venv', 'bin', 'hermes'),+ ]++ const launcher = candidates.find((candidate: string): boolean => fs.existsSync(candidate))+ if (!launcher) { throw new Error(`No source launcher available to settle ${options.root}`) }++ const result = spawnSync(launcher, ['status'], {+ cwd: options.root, env: launch.env, encoding: 'utf8', timeout: 20 * 60_000,+ maxBuffer: 16 * 1024 * 1024,+ })++ const transcript = [result.stdout, result.stderr].filter(Boolean).join('')+ fs.writeFileSync(path.join(options.out, `desktop-source-settle-${options.phase}.log`), redact(transcript))+ if (result.error) { throw result.error }++ if (result.status !== 0) {+ throw new Error(`Source runtime settle failed: exit=${result.status}, signal=${result.signal}`)+ }+}+async function gracefulClose(app: ElectronApplication): Promise<void> {let timer: ReturnType<typeof setTimeout> | undefinedtry {@@ -258,6 +296,7 @@ export async function runInstalledDesktopSmoke(options: SmokeOptions, launchApp:launch.env.XDG_DATA_HOME, launch.env.XDG_CACHE_HOME]) {fs.mkdirSync(dir, { recursive: true })}+ settleSourceDesktopRuntime(options, launch)selectLocal(options['user-data'])if (!options['mock-url']) { mock = await startMockServer() }const mockUrl = validateMockUrl(options['mock-url'] ?? mock!.url)