The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(smoke): check bundled Hermes home before sandbox setup
ethernetbaef00bf4c6d
diff --git a/tests-js/scripts/desktop-smoke.test.ts b/tests-js/scripts/desktop-smoke.test.tsindex cbfa00f5972..209cd13f691 100644--- a/tests-js/scripts/desktop-smoke.test.ts+++ b/tests-js/scripts/desktop-smoke.test.ts@@ -599,7 +599,10 @@ test('readBundledBundleEnv reads the stamped defaults/clears and is absent when} finally { fs.rmSync(root, { recursive: true, force: true }) }})-test('a bundle-env HERMES_HOME clear cannot strand the mock config outside the resolved home', async (): Promise<void> => {+test.each<[Record<string, string | null> | undefined]>([+ [undefined], [{ HERMES_GUEST_ONBOARDING: '1' }], [{ HERMES_HOME: null }],+])(+ 'bundled smoke admits a fresh home and seeds the resolved provider with defaults %j', async (bundleEnv: Record<string, string | null> | undefined): Promise<void> => {const root = fs.mkdtempSync(path.join(os.tmpdir(), 'smoke-bundle-clear-'))const home = path.join(root, 'home')const userData = path.join(root, 'root', 'user-data')@@ -611,6 +614,10 @@ test('a bundle-env HERMES_HOME clear cannot strand the mock config outside the rfs.writeFileSync(exe, '#!/bin/sh\nexit 1\n')fs.chmodSync(exe, 0o755)+ if (bundleEnv) {+ fs.writeFileSync(path.join(root, 'install-stamp.json'), JSON.stringify({ payload: 'bundled', bundleEnv }))+ }+const refuseLaunch = async (): Promise<never> => { throw new Error('launch refused by test') }try {@@ -636,6 +643,15 @@ test('a bundle-env HERMES_HOME clear cannot strand the mock config outside the rfor (const dir of ['AppData/Roaming', 'AppData/Local', '.config', '.local/share', '.cache']) {expect(fs.statSync(path.join(home, '.desktop-smoke-home', ...dir.split('/'))).isDirectory()).toBe(true)}++ if (bundleEnv) {+ const predicted = predictSmokeHermesHome(smokeEnvironment({}, home, userData), bundleEnv)+ const config = path.join(predicted, 'config.yaml')+ const before = fs.readFileSync(config)+ await expect(runInstalledDesktopSmoke({ exe, root: path.join(root, 'root'), origin: 'bundled', home,+ 'user-data': userData, out: root, phase: 'installed', 'expect-commit': 'a'.repeat(40) }, refuseLaunch)).rejects.toThrow('refusing to seed an existing profile')+ expect(fs.readFileSync(config)).toEqual(before)+ }} finally {await mock.close()}diff --git a/tests/install/e2e-assets/desktop-smoke.ts b/tests/install/e2e-assets/desktop-smoke.tsindex f53b19069fe..123d471a73b 100644--- a/tests/install/e2e-assets/desktop-smoke.ts+++ b/tests/install/e2e-assets/desktop-smoke.ts@@ -289,9 +289,15 @@ export async function runInstalledDesktopSmoke(options: SmokeOptions, launchApp:try {fs.accessSync(options.exe, fs.constants.X_OK)fs.accessSync(options.root)+ const launch: Launch = resolveSmokeLaunch(options)+ const bundleEnv: Record<string, string | null> | undefined = options.origin === 'bundled' ? readBundledBundleEnv(options.root) : undefined+ predictedHome = bundleEnv ? predictSmokeHermesHome(launch.env, bundleEnv) : undefined++ // Check before the driver creates its sandbox folders inside this home.+ if (predictedHome) { requireEmptyHermesHome(predictedHome) }+fs.mkdirSync(options.home, { recursive: true })fs.mkdirSync(options['user-data'], { recursive: true })- const launch = resolveSmokeLaunch(options)fs.mkdirSync(launch.env.HOME!, { recursive: true })// Electron resolves shell folders before app 'ready': Windows SHGetFolderPath// fails (and applyDesktopIdentity crashes the process) when the roaming/local@@ -310,10 +316,7 @@ export async function runInstalledDesktopSmoke(options: SmokeOptions, launchApp:// provider config and .env. When the artifact's stamp carries its baked// bundle env, predict the home the app will actually resolve and seed that// too, refusing to seed a non-empty one.- const bundleEnv = options.origin === 'bundled' ? readBundledBundleEnv(options.root) : undefined- predictedHome = bundleEnv ? predictSmokeHermesHome(launch.env, bundleEnv) : undefinedfor (const home of new Set([...candidateSmokeHermesHomes(options.home, options['user-data']), ...(predictedHome ? [predictedHome] : [])])) {- if (predictedHome && home === predictedHome) { requireEmptyHermesHome(home) }writeMockProviderConfig(home, mockUrl)writeEnvFile(home, 'e2e-mock-key', mockUrl)}