test(e2e): stop source settlement at update completion
This commit is contained in:
@@ -373,15 +373,16 @@ test('Windows source settle bypasses the current cmd launcher beside a stale his
|
||||
const python = path.join(root, 'managed python', 'python.exe')
|
||||
fs.mkdirSync(path.dirname(python), { recursive: true })
|
||||
fs.writeFileSync(python, '')
|
||||
const bootstrap = path.join(root, 'hermes_bootstrap.py')
|
||||
fs.writeFileSync(bootstrap, '')
|
||||
const prepareLaunch = path.join(root, 'hermes_cli', 'venv_sync.py')
|
||||
fs.mkdirSync(path.dirname(prepareLaunch), { recursive: true })
|
||||
fs.writeFileSync(prepareLaunch, '')
|
||||
fs.writeFileSync(current, `@"${python}" -I -c "import base64; exec(base64.b64decode('eA=='))" %*\r\n`)
|
||||
fs.writeFileSync(path.join(bin, 'hermes.exe'), 'locked historical launcher')
|
||||
const invocation = sourceRuntimeSettleCommand(root, { ComSpec: 'C:\\Windows\\System32\\cmd.exe' }, 'win32')
|
||||
expect(invocation).toEqual({
|
||||
launcher: current,
|
||||
command: python,
|
||||
args: ['-I', '-B', '-c', `import runpy, sys; sys.path.insert(0, ${JSON.stringify(root)}); sys.argv = [${JSON.stringify(bootstrap)}, 'status']; runpy.run_path(${JSON.stringify(bootstrap)}, run_name='__main__')`],
|
||||
args: ['-I', '-B', '-c', `import pathlib, sys; sys.path.insert(0, ${JSON.stringify(root)}); from hermes_cli.venv_sync import prepare_launch; prepare_launch(pathlib.Path(${JSON.stringify(root)}), ['status'])`],
|
||||
windowsVerbatimArguments: false,
|
||||
})
|
||||
} finally { fs.rmSync(root, { recursive: true, force: true }) }
|
||||
@@ -398,7 +399,9 @@ test('Windows source settle bypasses the generated cmd command line', (): void =
|
||||
expect(pythonProbe.status, pythonProbe.stderr || String(pythonProbe.error)).toBe(0)
|
||||
const python = pythonProbe.stdout.trim()
|
||||
fs.writeFileSync(path.join(bin, 'hermes.cmd'), `@"${python}" -I -c "import base64; exec(base64.b64decode('eA=='))" %*\r\n`)
|
||||
fs.writeFileSync(path.join(root, 'hermes_bootstrap.py'), `import sys\nfrom pathlib import Path\nPath(${JSON.stringify(witness)}).write_text('\\n'.join(sys.argv))\n`)
|
||||
const prepareLaunch = path.join(root, 'hermes_cli', 'venv_sync.py')
|
||||
fs.mkdirSync(path.dirname(prepareLaunch), { recursive: true })
|
||||
fs.writeFileSync(prepareLaunch, `from pathlib import Path\ndef prepare_launch(root, args):\n Path(${JSON.stringify(witness)}).write_text(str(root) + '\\n' + '\\n'.join(args))\n`)
|
||||
fs.writeFileSync(path.join(bin, 'hermes.exe'), 'locked historical launcher')
|
||||
const invocation = sourceRuntimeSettleCommand(root, process.env, 'win32')
|
||||
const result = spawnSync(invocation.command, invocation.args, {
|
||||
@@ -407,7 +410,7 @@ test('Windows source settle bypasses the generated cmd command line', (): void =
|
||||
})
|
||||
expect(result.status, result.stderr || String(result.error)).toBe(0)
|
||||
expect(fs.readFileSync(witness, 'utf8').split(/\r?\n/)).toEqual([
|
||||
path.join(root, 'hermes_bootstrap.py'),
|
||||
root,
|
||||
'status',
|
||||
])
|
||||
} finally { fs.rmSync(workspace, { recursive: true, force: true }) }
|
||||
|
||||
@@ -28,17 +28,16 @@ export function sourceRuntimeSettleCommand(root, env, platform = process.platfor
|
||||
void env;
|
||||
// PM's fallback command launcher embeds the Python bootstrap in a base64
|
||||
// `-c` argument. Running that .cmd through cmd.exe constrains the already
|
||||
// long command to 8191 characters; a source update's clean-interpreter
|
||||
// relaunch then exceeds CreateProcess' limit as well. Use the launcher's
|
||||
// selected Python to run the source bootstrap by file instead. This drives
|
||||
// the same lazy source-update completion without nesting either command.
|
||||
// long command to 8191 characters. Drive the bootstrap's prepare_launch seam
|
||||
// directly: it owns lazy dependency/product completion, while continuing
|
||||
// through a redundant CLI command can inherit update children and never exit.
|
||||
const commandFile = fs.readFileSync(launcher, 'utf8');
|
||||
const generated = commandFile.match(/^\s*@?"([^"\r\n]+)"\s+-I(?:\s|$)/m);
|
||||
if (!generated) throw new Error(`Unrecognized source command launcher: ${launcher}`);
|
||||
const command = generated[1];
|
||||
const bootstrap = path.join(root, 'hermes_bootstrap.py');
|
||||
const prepareLaunch = path.join(root, 'hermes_cli', 'venv_sync.py');
|
||||
if (!fs.existsSync(command)) throw new Error(`Source launcher Python does not exist: ${command}`);
|
||||
if (!fs.existsSync(bootstrap)) throw new Error(`Source bootstrap does not exist: ${bootstrap}`);
|
||||
const code = `import runpy, sys; sys.path.insert(0, ${JSON.stringify(root)}); sys.argv = [${JSON.stringify(bootstrap)}, 'status']; runpy.run_path(${JSON.stringify(bootstrap)}, run_name='__main__')`;
|
||||
if (!fs.existsSync(prepareLaunch)) throw new Error(`Source update preparation does not exist: ${prepareLaunch}`);
|
||||
const code = `import pathlib, sys; sys.path.insert(0, ${JSON.stringify(root)}); from hermes_cli.venv_sync import prepare_launch; prepare_launch(pathlib.Path(${JSON.stringify(root)}), ['status'])`;
|
||||
return { launcher, command, args: ['-I', '-B', '-c', code], windowsVerbatimArguments: false };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user