Skip to content

The agent that grows with you

test(e2e): combine PM launcher and historical Electron Git probes

ethernet6edc9051c072
diff --git a/tests-js/update-ui.test.mjs b/tests-js/update-ui.test.mjs
index 9ea8fc7e0c0..c1b8bffb7f3 100644
--- a/tests-js/update-ui.test.mjs
+++ b/tests-js/update-ui.test.mjs
@@ -175,6 +175,9 @@ test.skipIf(process.platform === 'win32')('preloaded historical Desktop Git chec
run(['config', '--file', cfg, '--add', `url.file://${bare}.insteadOf`, 'https://github.com/NousResearch/hermes-agent.git'])
const shim = path.join(root, 'git')
fs.writeFileSync(shim, `#!/bin/sh\nif [ "$1 $2 $3" = "remote get-url origin" ]; then printf '%s\\n' 'https://github.com/NousResearch/hermes-agent.git'; else exec '${git}' "$@"; fi\n`, { mode: 0o700 })
+ const launcher = path.join(checkout, '.hermes', 'bin', 'hermes')
+ fs.mkdirSync(path.dirname(launcher), { recursive: true })
+ fs.writeFileSync(launcher, '#!/bin/sh\nexit 0\n', { mode: 0o700 })
const launchEnv = { HERMES_DESKTOP_USER_DATA_DIR: root }
sourceBranchProbe.prepareSourceBranchEnvironment(checkout, sha, git, { ...process.env, GIT_CONFIG_GLOBAL: cfg }, launchEnv)
const script = 'const {spawn} = require("node:child_process"); const child = spawn(process.argv[1], process.argv.slice(3), {cwd:process.argv[2], env:{...process.env, GIT_CONFIG_GLOBAL:"/dev/null"}}); child.stdout.pipe(process.stdout); child.stderr.pipe(process.stderr); child.on("close", code => process.exitCode=code)'
diff --git a/tests/install/e2e-assets/source-branch-probe.cjs b/tests/install/e2e-assets/source-branch-probe.cjs
index 1760982b87e..2ecd8aee2e3 100644
--- a/tests/install/e2e-assets/source-branch-probe.cjs
+++ b/tests/install/e2e-assets/source-branch-probe.cjs
@@ -39,6 +39,11 @@ function prepareSourceBranchEnvironment(root, expectedSha, realGit, capturedEnv,
if (advertised !== expectedSha) {
throw new Error(`staged Git main ${advertised} does not match expected ${expectedSha}`)
}
+ launchEnv.HERMES_E2E_SOURCE_ROOT = install
+ launchEnv.HERMES_E2E_SOURCE_URL = staged
+ launchEnv.HERMES_E2E_SOURCE_REAL_GIT = realGit
+ launchEnv.HERMES_E2E_SOURCE_GIT = sourceProbeGit(launchEnv.HERMES_DESKTOP_USER_DATA_DIR, realGit, staged)
+ launchEnv.NODE_OPTIONS = `--require=${JSON.stringify(__filename)}`
if (process.platform !== 'win32') {
// Packaged Electron ignores NODE_OPTIONS=--require. Select the branch at
// the isolated installation's launcher instead, leaving product code and
@@ -49,7 +54,6 @@ function prepareSourceBranchEnvironment(root, expectedSha, realGit, capturedEnv,
throw new Error('source app-update requires an unmodified installation launcher')
}
fs.copyFileSync(launcher, original)
- const git = sourceProbeGit(launchEnv.HERMES_DESKTOP_USER_DATA_DIR, realGit, staged)
const quote = value => `'${value.replace(/'/g, "'\\''")}'`
fs.writeFileSync(launcher, `#!/bin/sh
check_root() {
@@ -60,17 +64,12 @@ check_root() {
return 1
}
if [ "$1" = '--run-module' ] && [ "$2" = 'hermes_cli.source_check' ] && check_root "$@"; then
- exec ${quote(original)} "$@" --git ${quote(git)} --branch main
+ exec ${quote(original)} "$@" --git ${quote(launchEnv.HERMES_E2E_SOURCE_GIT)} --branch main
fi
exec ${quote(original)} "$@"
`, { mode: 0o700 })
return
}
- launchEnv.HERMES_E2E_SOURCE_ROOT = install
- launchEnv.HERMES_E2E_SOURCE_URL = staged
- launchEnv.HERMES_E2E_SOURCE_REAL_GIT = realGit
- launchEnv.HERMES_E2E_SOURCE_GIT = sourceProbeGit(launchEnv.HERMES_DESKTOP_USER_DATA_DIR, realGit, staged)
- launchEnv.NODE_OPTIONS = `--require=${JSON.stringify(__filename)}`
}
async function installSourceBranchProbe(app) {