The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(desktop): vitest resolves HERMES_PYTHON from the checkout's test env
Maciej Lisiewskic5a7e48c123c
diff --git a/apps/desktop/vitest.config.ts b/apps/desktop/vitest.config.tsindex 0b95ebdb1ef..80091e89334 100644--- a/apps/desktop/vitest.config.ts+++ b/apps/desktop/vitest.config.ts@@ -39,7 +39,10 @@ const electronNative: TestProjectConfiguration = {// Tests here shell out to real interpreters (python3, pwsh) over a 40+// case corpus; pwsh alone takes several seconds to start on a loaded CI// runner, so vitest's 5s default timed the Windows marker judge out.- testTimeout: 30_000+ testTimeout: 30_000,+ // Only these contracts need the Hermes test interpreter; resolving it may+ // sync the Python environment, which UI-only runs must not wait for.+ globalSetup: ['./vitest.hermes-python.ts']}}diff --git a/apps/desktop/vitest.hermes-python.ts b/apps/desktop/vitest.hermes-python.tsnew file mode 100644index 00000000000..7a52eabf799--- /dev/null+++ b/apps/desktop/vitest.hermes-python.ts@@ -0,0 +1,32 @@+/**+ * HERMES_PYTHON for the electron contracts that drive real hermes_cli / pm code+ * (mac-sign, source-backend, checkout-source). CI exports the PM test+ * environment's interpreter; a developer's plain `npx vitest` does not, and the+ * PATH python3 lacks the application dependencies. Resolve the checkout's test+ * interpreter the way scripts/run_tests.sh does. Workers inherit process.env.+ */+import { execFileSync } from 'node:child_process'+import path from 'node:path'++const repo = path.resolve(import.meta.dirname, '../..')++export default function setup(): void {+ if (process.env.HERMES_PYTHON || process.platform === 'win32') {+ return+ }++ try {+ const python = execFileSync(+ 'bash',+ [path.join(repo, 'scripts', 'run-in-hermes-env'), 'sh', '-c', 'printf %s "$__HERMES_TEST_PYTHON"'],+ { cwd: repo, encoding: 'utf8', stdio: ['ignore', 'pipe', 'inherit'] }+ )++ if (python) {+ process.env.HERMES_PYTHON = python+ }+ } catch (error: unknown) {+ // Electron tests that need no Python still run; only the contracts above fail, naming HERMES_PYTHON.+ console.warn(`vitest: could not resolve the Hermes test interpreter: ${String(error)}`)+ }+}