A process that could not adopt a newly published dependency generation keeps importing the old one. restart_needed() names that case (and stays silent for dev venvs, Nix and anything not booted from a PM generation, so no false restart prompts); adopt_selected() lets callers move onto the selection before loading new code. The test helpers publish real generations and make the test process run from one. (cherry picked from commit 978abe8ec4b852778b8c63bcefdf141db51bc703) (cherry picked from commit 28be27334adc531db59bf37a02a64acaaf47a2ee)
24 lines
1.1 KiB
Python
24 lines
1.1 KiB
Python
"""restart_needed / adopt_selected against real generations: real uv, offline wheels, temp HERMES_HOME."""
|
|
from __future__ import annotations
|
|
|
|
from tests.hermes_cli.plugin_worker_support import (
|
|
boot as boot, isolated_python as isolated_python, plugin_world as plugin_world, publish_plugins)
|
|
|
|
|
|
def test_a_process_on_a_superseded_generation_needs_a_restart_until_it_adopts(plugin_world, boot):
|
|
from pm.environments_adopt import adopt_selected, restart_needed
|
|
|
|
world = plugin_world
|
|
first = publish_plugins(world, {"base": ["plugin-proof-dep==1.0"]})
|
|
# This interpreter never booted from the install: nothing it could restart into.
|
|
assert restart_needed(world.core) is None
|
|
assert adopt_selected(world.core)
|
|
boot(first)
|
|
assert restart_needed(world.core) is None
|
|
second = publish_plugins(world, {"base": ["plugin-proof-dep==1.0"], "adds": ["plugin-proof-other"]})
|
|
assert second != first
|
|
reason = restart_needed(world.core)
|
|
assert reason and second.parent.name in reason
|
|
assert adopt_selected(world.core)
|
|
assert restart_needed(world.core) is None
|