test(e2e): route managed Desktop checks to staged Git main

This commit is contained in:
ethernet
2026-09-24 06:19:09 -04:00
parent 099addd628
commit 2120e8728d
4 changed files with 14 additions and 3 deletions

View File

@@ -82,6 +82,7 @@ it.skipIf(process.platform === 'win32')('uses the install-scoped PM launcher rat
fs.mkdirSync(path.join(root, 'pm'))
fs.mkdirSync(home)
fs.writeFileSync(launcher, '#!/bin/sh\n[ "$1" = --run-module ] && [ "$2" = hermes_cli.source_check ] || exit 5\nprintf \'%s\\n\' \'{"supported":true,"channel":"stable","behind":-1}\'\n', { mode: 0o755 })
try {
const probe = { python: '/nonexistent/system-python', git: 'git', updateRoot: root, hermesHome: home, channel: 'stable' as const }
await expect(readSourceUpdate(probe)).resolves.toMatchObject({ supported: true, channel: 'stable', behind: null })

View File

@@ -49,9 +49,11 @@ export async function readSourceUpdate(probe: SourceUpdateProbe): Promise<Source
// existing path until that transport is migrated.
const managed = process.platform !== 'win32' && existsSync(path.join(probe.updateRoot, 'pm'))
const launcher = managed ? resolveInstallationLauncher(probe.updateRoot, false, probe.hermesHome) : null
if (managed && !launcher) {
throw new Error('The source installation launcher is missing; repair this installation before checking updates.')
}
if (!managed && !probe.python) {
throw new Error('No Python interpreter is available to check the source update channel.')
}

View File

@@ -90,8 +90,14 @@ test('test-only source probe pins staged main without changing other Python invo
expected[expected.indexOf('--git') + 1] = '/real/git'
expected.push('--branch', 'main')
expect(sourceBranchProbe.branchProbeArgs(probe, root, '/real/git')).toEqual(expected)
const managed = ['--run-module', 'hermes_cli.source_check', ...probe.slice(2)]
expect(sourceBranchProbe.branchProbeArgs(managed, root, '/real/git')).toEqual([
'--run-module', 'hermes_cli.source_check', ...expected.slice(2),
])
expect(sourceBranchProbe.branchProbeArgs(probe, '/other/install', '/real/git')).toBe(probe)
expect(sourceBranchProbe.branchProbeArgs(managed, '/other/install', '/real/git')).toBe(managed)
expect(sourceBranchProbe.branchProbeArgs(['-c', 'print("hermes_cli/source_check.py")'], root, '/real/git')).toEqual(['-c', 'print("hermes_cli/source_check.py")'])
expect(sourceBranchProbe.branchProbeArgs(['--run-module', 'hermes_cli.config', ...managed.slice(2)], root, '/real/git')).toEqual(['--run-module', 'hermes_cli.config', ...managed.slice(2)])
expect(sourceBranchProbe.branchProbeArgs([...probe, '--branch', 'topic'], root, '/real/git')).toEqual([...probe, '--branch', 'topic'])
expect(sourceBranchProbe.branchProbeArgs(probe, root, '')).toBe(probe)
})

View File

@@ -45,9 +45,11 @@ function prepareSourceBranchEnvironment(root, expectedSha, realGit, capturedEnv,
}
function branchProbeArgs(args, root, realGit) {
if (!root || !realGit || !Array.isArray(args) || args[0] !== '-c'
|| !args[1]?.includes('runpy.run_path(str(p))')
|| !args[1]?.includes('hermes_cli/source_check.py')
if (!root || !realGit || !Array.isArray(args)) return args
const legacy = args[0] === '-c' && args[1]?.includes('runpy.run_path(str(p))')
&& args[1]?.includes('hermes_cli/source_check.py')
const managed = args[0] === '--run-module' && args[1] === 'hermes_cli.source_check'
if (!(legacy || managed)
|| args[args.indexOf('--install-root') + 1] !== root
|| !args.includes('--git') || args.includes('--branch')) return args
const selected = [...args]