tests.destructive_plan module¶
The plan driving the destructive install/remove round-trips and upgrades.
Which package each manager installs and removes, which managers cannot
complete that round-trip or a full upgrade on a given host, and which of them
may not run at the same time as another. Kept out of conftest.py because the
whole of it serves four test modules: the shared fixtures are what a reader
opens conftest for.
- tests.destructive_plan.PACKAGE_IDS = {'am': 'appimageupdate', 'antidote': 'zdharma-continuum/null', 'antigen': 'zdharma-continuum/null', 'antigravity-cli-plugins': 'apricot-notes', 'apk': 'nyancat', 'apm': 'markdown-pdf', 'app-manager': 'AppManager-3.8.0-anylinux-x86_64.AppImage', 'apt': 'nyancat', 'apt-cyg': 'tree', 'apt-mint': 'nyancat', 'aptitude': 'nyancat', 'asdf': 'jq', 'aura': 'yay-bin', 'basalt': 'hyperupcall/bash-args', 'bin': '/usr/local/bin/bin', 'bob': 'v0.11.7', 'bpkg': 'bpkg/term', 'brew': 'nyancat', 'bun': 'cowsay', 'cargo': 'fsays', 'cask': 'itsycal', 'cave': 'base/figlet', 'choco': 'hyperfine', 'choosenim': '2.0.0', 'chromebrew': 'sl', 'claude-code-plugins': 'pyright-lsp@claude-plugins-official', 'clib': 'stephenmathieson/tabs-to-spaces', 'composer': 'ralouphie/getallheaders', 'conda': 'pytz', 'cpan': 'Try::Tiny', 'cran': 'praise', 'deb-get': 'deb-get', 'dkp-pacman': 'gba-examples', 'dnf': 'nyancat', 'dnf5': 'nyancat', 'dotnet': 'dotnetsay', 'elan': 'leanprover/lean4:v4.33.0', 'emacs': 'queue', 'emerge': 'games-misc/nyancat', 'eopkg': 'sl', 'fink': 'figlet', 'fisher': 'zdharma-continuum/null', 'flatpak': 'org.gnome.Calculator', 'fwupd': 'f95c9218acd12697af946874bfe4239587209232', 'gcloud': 'kubectl', 'gem': 'paint', 'getnf': 'ShareTechMono', 'gext': 'caffeine@patapon.info', 'gh-ext': 'mislav/gh-branch', 'ghcup': 'hls-2.9.0.1', 'go': 'golang.org/x/example/hello', 'guix': 'hello', 'gup': 'hello', 'haxelib': 'hxjsonast', 'hyprpm': 'https://github.com/hyprwm/hyprland-plugins', 'ips': 'archiver/ofarc', 'jpm': 'argparse', 'julia': 'Example', 'juliaup': '1.6', 'krew': 'ctx', 'lazy': 'lazy.nvim', 'luarocks': 'inspect', 'lure': 'neofetch', 'macports': 'hello', 'mamba': 'zstd', 'mas': '747648890', 'mason': 'stylua', 'micro': 'bounce', 'microdnf': 'tree', 'micromamba': 'zstd', 'miktex': 'fancyhdr', 'mise': 'jq', 'nala': 'nyancat', 'nimble': 'parsetoml', 'nix': 'hello', 'npm': 'ms', 'octave': 'octest', 'oh-my-fish': 'bak', 'ollama': 'tinyllama:latest', 'opam': 'zarith', 'opkg': 'lolcat', 'pacaur': 'nyancat', 'pacman': 'nyancat', 'pacstall': 'hello', 'pamac': 'nyancat', 'paru': 'nyancat', 'pear': 'Text_Password', 'pearl': 'pearl/airline', 'pi': 'npm:@earendil-works/pi-telemetry', 'pikaur': 'nyancat', 'pip': 'pytz', 'pipx': 'pycowsay', 'pipxu': 'pycowsay', 'pixi': 'hyperfine', 'pkcon': 'hello', 'pkg': 'nyancat', 'pkg-tools': 'nyancat', 'pkgin': 'nyancat', 'pkgit': 'pkgit', 'pkgm': 'stedolan.github.io/jq', 'platformio-core': 'ArduinoJson', 'pmerge': 'games-misc/nyancat', 'pnpm': 'ms', 'ports': 'net/nyancat', 'protonplus': 'lutris-system/dxvk-doitsujin', 'prt-get': 'dosfstools', 'pwsh-gallery': 'Posh-Git', 'pyenv': 'pypy3.11-7.3.20', 'raco': 'uuid', 'roswell': 'sbcl-bin', 'rpm-ostree': 'nyancat', 'rustup': '1.60.0', 'scoop': 'main/hyperfine', 'sdkman': 'jbang', 'sfsu': 'main/hyperfine', 'sheldon': 'zsh-autosuggestions', 'shelly': 'nyancat', 'skills': 'deploy-to-vercel', 'slapt-get': 'nano', 'snap': 'hello-world', 'soar': 'bat', 'sorcery': 'figlet', 'spack': 'zlib', 'steamcmd': '1007', 'stew': 'sharkdp/hyperfine', 'sun-tools': 'SUNWzlib', 'swupd': 'curl', 'tazpkg': 'nano', 'tlmgr': 'lipsum', 'topgrade': 'topgrade', 'trizen': 'nyancat', 'urpmi': 'figlet', 'uv': 'pytz', 'uvx': 'pycowsay', 'vagrant': 'hashicorp/bionic64', 'vcpkg': 'zlib', 'vim-pack': 'https://github.com/tpope/vim-sensible', 'volta': 'nanoid', 'vscode': 'tamasfe.even-better-toml', 'vscodium': 'tamasfe.even-better-toml', 'whalebrew': 'whalebrew/whalesay', 'winget': 'sharkdp.hyperfine', 'xbps': 'sl', 'xcodes': '16.2', 'yarn': 'ms', 'yarn-berry': 'ms', 'yay': 'nyancat', 'yazi': 'yazi-rs/plugins:full-border', 'yum': 'nyancat', 'zef': 'hyperize', 'zerobrew': 'nyancat', 'zeroinstall': 'zeroinstall', 'zim': 'zsh-users/zsh-completions', 'zinit': 'zdharma-continuum/null', 'zplug': 'zdharma-continuum/null', 'zvm': '0.13.0', 'zypper': 'nyancat'}¶
Package IDs used by the destructive install/remove tests, one per manager.
Each entry is fed to
mpm --<manager_id> install <package_id>immediately followed bympm --<manager_id> remove <package_id>, so the package is both added to and removed from the host running the test. Each ID is picked to keep that round-trip cheap and free of side effects:Tiny and quick to install, with no dependency tree, no services or daemons, and no
/etcconfiguration: just a self-contained binary.Not a tool the OS, the manager itself, or common scripts are likely to depend on. Ubiquitous utilities (
wget,curl,git,jq, …) are avoided: they are usually already installed (so the install step is a no-op) and removing them can break the host.Preferably from the Rust or Go ecosystems, which rarely pull in extra dependencies.
Wherever a manager exposes general-purpose binaries the same low-impact tools are reused for consistency:
nyancat(a single-file C binary packaged by nearly every Linux distro, Homebrew, FreeBSD asnet/nyancat, OpenBSD and pkgsrc asmisc/nyancat), GNUhellofor the functional managers (Guix, Nix) andhyperfinefor the Windows binary stores andstew. Distros that lacknyancatfall back tosl(Chromebrew, Solus, Void),figlet(another tiny dependency-free C binary, for Exherbo, Fink, Mageia and Source Mage),lolcat(OpenWrt) ornano(Slackware’s official tree carries none of the above, soslapt-getmirrorstazpkg). Language and application managers use the smallest inert package native to their ecosystem (msfor npm and Yarn,pycowsayfor the pipx-style installers that require a console-script entry point, …).Warning
fwupdflashes real firmware. Its ID is a release with no matching device on CI runners, where the install is therefore a no-op. Never run the destructivefwupdtest on hardware that the ID actually targets.Note
A few managers cannot offer a small binary:
sdkmanonly ships full SDKs (jbangis its lightest candidate), andmasneeds a signed App Store app (its test is skipped anyway).deb-gethas no real per-package install, so it references itself, andtopgradedeclares no install operation at all, so its round-trip auto-skips.gh-extreferences its extension by theowner/reposlug: the only idgh extension installaccepts, and the id scheme itsinstalledoperation reports.Only to be used for destructive tests.
- tests.destructive_plan.DESTRUCTIVE_TEST_FAMILIES: dict[str, frozenset[str]] = {'active venv': frozenset({'pip', 'uv'}), 'tool shims': frozenset({'pipx', 'uvx'})}¶
Managers whose destructive tests collide on a shared install target.
The test-suite complement of
SHARED_LOCK_FAMILIES: those families record managers contending for one backend lock at runtime, while the entries here only collide because of what the destructive round-trips themselves install, so they belong to the suite rather than tompm. Family names carry a space on purpose, keeping them clear of the manager-id namespace the other group names live in.
- tests.destructive_plan.destructive_group(manager_id)[source]¶
Resolve the
xdist_groupa destructive test drivingmanager_idruns in.Managers sharing a backend lock (
SHARED_LOCK_FAMILIES) or an install target (DESTRUCTIVE_TEST_FAMILIES) collapse into one group, which--dist=loadgroupschedules serially on a single worker, mirroringmpm’s own grouped fan-out; every other manager gets a group of its own and runs in parallel with the rest.- Return type:
- tests.destructive_plan.SHORT_FAILURE_TIMEOUT = 10¶
Seconds to cap a destructive operation that is expected to fail.
The managers in
INSTALL_REMOVE_BLOCKED_WHENcannot complete a real install in the test environment, and those inUPGRADE_ALL_BLOCKED_WHENcannot complete a full upgrade. Most installs fail within a second (a permission error, a missing remote, an empty search), but a few (scoopandsfsuon Windows,pwsh-galleryon macOS) hang with no error until the state-change timeout would otherwise elapse, and a blocked upgrade always does. Capping their CLI calls keeps the doomed attempts cheap: long enough for the fast failures to surface, short enough that the genuine hangs do not dominate the destructive job’s wall-clock.
- tests.destructive_plan.gh_unauthenticated()[source]¶
Whether the
ghCLI is present but holds no usable credentials.ghrefuses to runextension installunauthenticated, so the gh-ext destructive round-trip can only succeed where it resolves a token.gh auth token``probes the resolved credentials (stored logins and``GH_TOKEN-style environment variables alike) without any network call. A missingghis not flagged: selection then finds no available manager and the test already exits on its “No manager selected” path.- Return type:
- tests.destructive_plan.cpan_install_blocked()[source]¶
Whether
cpan installcannot complete on this host.Derived from measured CI results rather than from the permissions of Perl’s site library, which do not predict the outcome: that tree is root-owned on macOS too, yet the round-trip succeeds there. The install fails only on the x86 Linux runners; the arm64 image of the same Ubuntu release ships a Perl the unelevated user can install into, and macOS resolves a writable target of its own.
Keep this keyed on evidence. A flat
is_linuxwas wrong on arm64, and a writability probe would have been wrong on macOS in the other direction.is_x86_64rather than a negated ARM test, so the pair of images actually measured is what the predicate names: a third Linux architecture would be an unknown, not an assumed failure.- Return type:
- tests.destructive_plan.cpan_upgrade_all_blocked()[source]¶
Whether
cpan -ucannot complete a full upgrade on this host.Measured on the
ubuntu-26.04-armrunner on 2026-09-17.cpan -Olists 527 outdated modules, and one pass ofcpan -ubuilds and tests them for 754 seconds. All 128 of itsmake installsteps then fail, because the unelevated user cannot create/usr/local/man/man1and/usr/local/man/man3. Nothing converges, so every run starts over. The x86 runner also hits the 500-second timeout, whilecpan -ufinishes within it on macOS and Windows.- Return type:
- tests.destructive_plan.pear_install_blocked()[source]¶
Whether
pear installcannot complete on this host.PEAR gates an install on exactly one test of its own, refusing with Cannot install, php_dir for channel “pear.php.net” is not writable by the current user, so the same directory is probed here rather than the platform guessed from. A distribution’s PHP roots that directory at
/usr/share/phpand owns it as root, blocking an unelevated round-trip; a PEAR relocated to a user-owned prefix is not blocked, and the probe follows it either way.mpm leaves PEAR’s privileged markers dormant, being a dual-scope language manager, so nothing escalates the install on the manager’s behalf.
- Return type:
Whether snap’s privileged install cannot run unattended on this host.
mpm sudo-escalates snap (snapd refuses unprivileged state changes), so the round-trip completes only where
sudoneeds no password. The platform cannot answer that: GitHub’s runners grant passwordless sudo, a typical workstation password-gates it, and a provisioned box may do either, so the state is probed live rather than inferred fromis_github_ci.sudo --non-interactive trueasks the question the install actually asks, which is whether a command can escalate without a prompt.--validateasks a different one, refreshing the credential cache, and answers non-zero on a host whoseNOPASSWDrule sits beside a password-requiring group rule even though every command still runs unprompted.- Return type:
- tests.destructive_plan.gcloud_components_blocked()[source]¶
Whether gcloud’s component manager cannot mutate this installation.
Two independent layouts break
components installon the runner fleet, and both vary across its images and architectures, so the state is probed live rather than assumed from the platform. A package-manager install disables the component manager outright (“You cannot perform this action because the Google Cloud CLI component manager is disabled for this installation.”), which the exit code of a read-onlycomponents listalready exposes. A tarball layout whose SDK root is owned by root passes that first probe yet still refuses the unelevated mutation, so the resolvedinstallation.sdk_rootis then checked for write access: the arm64 Ubuntu image ships a writable root where the x86 one does not. A missinggcloudis not flagged, as selection then finds no available manager and the test already exits on its “No manager selected” path.- Return type:
- tests.destructive_plan.claude_marketplace_missing()[source]¶
Whether Claude Code has no marketplace to resolve a plugin from.
A plugin id names its marketplace, and
claude plugin installresolves it against the ones configured for the current user. A fresh host has none, so the install fails for want of a registry rather than for any defect, which is a condition of the machine rather than of the platform: the maintainer’s own workstation carries two, and a runner carries none.- Return type:
- tests.destructive_plan.pearl_bash_too_old()[source]¶
Whether the host’s Bash predates what Pearl’s hook functions need.
Pearl requires Bash
4.1and warns on every invocation when it does not have it. Below that its read-only listings still work while an install fails inside the package’s own hooks, so the round-trip breaks for a property of the machine rather than ofmpm. macOS ships3.2, which is what this catches; any newer Bash earlier onPATHsatisfies it.- Return type:
- tests.destructive_plan.rpm_distro_missing()[source]¶
Whether this host is not backed by a working RPM distribution.
The RPM front-ends (
dnf,dnf5,microdnf,yum,zypper) resolve nothing on a host whose RPM database was never populated: they find no release version and no repositories, and fail at the search step before reaching the privileged install. A Debian-based runner carrying one of their binaries is exactly that host.Keyed on the database rather than on the platform, so a real openSUSE or Fedora machine runs the round-trip instead of inheriting a CI artifact.
- Return type:
- tests.destructive_plan.flatpak_install_blocked()[source]¶
Whether a flatpak install cannot complete unattended on this host.
Two gates, and an install needs both. It needs a configured remote to resolve the application from, which a bare flatpak has none of. It then needs polkit to authorize the system-scope deploy, which an unattended session cannot answer for:
pkcheckreportsauth_adminthere, and flatpak resolves the whole application before dying on Flatpak system operation Deploy not allowed for user, a late failure that reads like an mpm fault and is not one.Probed live rather than inferred: a desktop install configures Flathub and clears the polkit prompt from its session, while a CI image and a headless SSH login clear neither. Root needs no polkit at all and is let through.
Every uncertainty answers “blocked”, since the cost of skipping a round-trip that would have worked is one lost signal, against a red run for a property of the host.
- Return type:
- tests.destructive_plan.INSTALL_REMOVE_BLOCKED_WHEN: dict[str, bool | Callable[[], bool]] = {'antigravity-cli-plugins': True, 'app-manager': True, 'basalt': <functools._lru_cache_wrapper object>, 'claude-code-plugins': <function claude_marketplace_missing>, 'cpan': <function cpan_install_blocked>, 'dnf': <function rpm_distro_missing>, 'dnf5': <function rpm_distro_missing>, 'flatpak': <function flatpak_install_blocked>, 'fwupd': True, 'gcloud': <function gcloud_components_blocked>, 'gh-ext': <function gh_unauthenticated>, 'mas': <functools._lru_cache_wrapper object>, 'microdnf': <function rpm_distro_missing>, 'pear': <function pear_install_blocked>, 'pearl': <function pearl_bash_too_old>, 'pixi': <functools._lru_cache_wrapper object>, 'pkcon': <functools._lru_cache_wrapper object>, 'pnpm': <functools._lru_cache_wrapper object>, 'pwsh-gallery': <functools._lru_cache_wrapper object>, 'scoop': <functools._lru_cache_wrapper object>, 'sfsu': <functools._lru_cache_wrapper object>, 'snap': <function snap_sudo_unavailable>, 'steamcmd': True, 'yum': <function rpm_distro_missing>, 'zypper': <function rpm_distro_missing>}¶
Managers that cannot complete a real install, mapped to the condition under which that is true. Read an entry as “
<manager>is blocked when<condition>”.The name carries the polarity so the values do not have to: a bare
is_github_cinext to a manager id reads as a statement about that manager unless the mapping says which way round it goes. The inverse shape (listing where each manager is installable) was weighed and dropped: every entry but the two constants is naturally phrased as “blocked when X”, so inverting would spell them all as negation lambdas to spare those two.Rather than skip these managers (which would also drop their dispatch coverage and any signal that they still fail the expected way), the destructive install/remove test drives each one’s
installanyway, caps the doomed CLI call withSHORT_FAILURE_TIMEOUT, and asserts that mpm reports the stable failure: exit code1and aCould not install: {package}critical message. The follow-upremoveis skipped, since the failed install left nothing to remove and the working managers already cover the removal path.A condition is either a plain
Truefor the managers no environment can install, or a zero-argument callable evaluated per host:is_github_cifor GitHub Actions only (a configured local box can still install), or a live probe likegh_unauthenticatedorrpm_distro_missingwhen installability hinges on host state rather than platform. Prefer a probe: a platform test blocks every machine of that platform, including the ones where the round-trip would have worked. Resolve one throughinstall_remove_blocked()rather than calling it directly, which is what keeps the constants from needing alambdawrapper.Note
The assertion deliberately targets mpm’s own
Could not install:message rather than the underlying tool’s error. The raw tool output is not a stable contract: it is platform-specific (pwsh-gallerytimes out on macOS but hits a name-case mismatch on Linux), stage-specific (dnf/zypper/flatpakfail at the search step, never reaching their privileged install errors), and drifts across tool versions, OS images, and locales. mpm’s failure message is identical everywhere, so the test stays robust.
- tests.destructive_plan.install_remove_blocked(manager_id)[source]¶
Whether
manager_idcannot complete a real install here.Resolves the
INSTALL_REMOVE_BLOCKED_WHENcondition, which is either a constant or a callable evaluated against the running host. A manager with no entry is not blocked.- Return type:
- tests.destructive_plan.REMOVE_REFUSES_INSTALLED: frozenset[str] = frozenset({'choosenim'})¶
Managers whose
removecannot take back what the install leg just installed.Distinct from
INSTALL_REMOVE_BLOCKED_WHEN, which covers a failing install and skips the removal for want of anything to remove. Here the install succeeds and the removal is refused on purpose, so the round-trip is driven in full and the refusal asserted, keeping the signal that the manager still fails the expected way.Unconditional rather than host-resolved: the refusal is the tool’s own rule, so no environment satisfies it.
- tests.destructive_plan.UPGRADE_ALL_BLOCKED_WHEN: dict[str, bool | Callable[[], bool]] = {'cpan': <function cpan_upgrade_all_blocked>}¶
Managers whose
upgrade --allcannot complete withinMUTATING_TIMEOUT, mapped to the condition under which that is true.Read and resolved like
INSTALL_REMOVE_BLOCKED_WHEN, throughupgrade_all_blocked(). Left alone, such a manager runs until mpm kills it at the timeout, and that wait sets the length of both destructive CI steps. The destructive upgrade tests drive it anyway, cap its CLI calls atSHORT_FAILURE_TIMEOUT, and assert that mpm reports the timeout.A manager that the kill damages goes in
UPGRADE_ALL_SKIPPED_WHENinstead.
- tests.destructive_plan.upgrade_all_blocked(manager_id)[source]¶
Whether
manager_idcannot complete a full upgrade here.Resolves the
UPGRADE_ALL_BLOCKED_WHENcondition, which is either a constant or a callable evaluated against the running host. A manager with no entry is not blocked.- Return type:
- tests.destructive_plan.UPGRADE_ALL_SKIPPED_WHEN: dict[str, bool | Callable[[], bool]] = {'winget': <functools._lru_cache_wrapper object>}¶
Managers whose
upgrade --allmust not run, mapped to the condition under which that is true.Read and resolved like
INSTALL_REMOVE_BLOCKED_WHEN, throughupgrade_all_skipped(). Such a manager cannot complete a full upgrade either, but the cap ofUPGRADE_ALL_BLOCKED_WHENdoes not fit it. When mpm kills it at the cap, the kill can also stop the installer it runs, and leave that application half installed on the host. The destructive upgrade tests leave such a manager out.Warning
On a runner, the damaged application can be one that the next steps of the job need. On a windows-2025 runner with an outdated Git for Windows (
2.56.0.windows.2),usr\bin\bash.exewas missing after the capped run. Each latershell: bashstep of the job then failed to start.
- tests.destructive_plan.upgrade_all_skipped(manager_id)[source]¶
Whether the
upgrade --allofmanager_idmust not run here.Resolves the
UPGRADE_ALL_SKIPPED_WHENcondition, which is either a constant or a callable evaluated against the running host. A manager with no entry is not skipped.- Return type: