Remove dead code in installer (#24035)
Currently as part of installing a package, we lock a prefix, check if it exists, and create it if not; the logic for creating the prefix included a check for the existence of that prefix (and raised an exception if it did), which was redundant. This also includes removal of tests which were not verifying anything (they pass with or without the modifications in this PR).
This commit is contained in:
parent
81962f100c
commit
729726d157
3 changed files with 0 additions and 69 deletions
|
@ -217,10 +217,6 @@ def build_packages_path(self, spec):
|
|||
def create_install_directory(self, spec):
|
||||
_check_concrete(spec)
|
||||
|
||||
prefix = self.check_installed(spec)
|
||||
if prefix:
|
||||
raise InstallDirectoryAlreadyExistsError(prefix)
|
||||
|
||||
# Create install directory with properly configured permissions
|
||||
# Cannot import at top of file
|
||||
from spack.package_prefs import get_package_dir_permissions, get_package_group
|
||||
|
@ -597,14 +593,6 @@ def __init__(self, message, long_msg=None):
|
|||
message, long_msg)
|
||||
|
||||
|
||||
class InstallDirectoryAlreadyExistsError(DirectoryLayoutError):
|
||||
"""Raised when create_install_directory is called unnecessarily."""
|
||||
|
||||
def __init__(self, path):
|
||||
super(InstallDirectoryAlreadyExistsError, self).__init__(
|
||||
"Install path %s already exists!" % path)
|
||||
|
||||
|
||||
class SpecReadError(DirectoryLayoutError):
|
||||
"""Raised when directory layout can't read a spec."""
|
||||
|
||||
|
|
|
@ -1590,21 +1590,6 @@ def install(self):
|
|||
keep_prefix = keep_prefix or \
|
||||
(stop_before_phase is None and last_phase is None)
|
||||
|
||||
except spack.directory_layout.InstallDirectoryAlreadyExistsError \
|
||||
as exc:
|
||||
tty.debug('Install prefix for {0} exists, keeping {1} in '
|
||||
'place.'.format(pkg.name, pkg.prefix))
|
||||
self._update_installed(task)
|
||||
|
||||
# Only terminate at this point if a single build request was
|
||||
# made.
|
||||
if task.explicit and single_explicit_spec:
|
||||
spack.hooks.on_install_failure(task.request.pkg.spec)
|
||||
raise
|
||||
|
||||
if task.explicit:
|
||||
exists_errors.append((pkg_id, str(exc)))
|
||||
|
||||
except KeyboardInterrupt as exc:
|
||||
# The build has been terminated with a Ctrl-C so terminate
|
||||
# regardless of the number of remaining specs.
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
import spack.binary_distribution
|
||||
import spack.compilers
|
||||
import spack.directory_layout as dl
|
||||
import spack.installer as inst
|
||||
import spack.package_prefs as prefs
|
||||
import spack.repo
|
||||
|
@ -1167,47 +1166,6 @@ def _requeued(installer, task):
|
|||
assert exp in ln
|
||||
|
||||
|
||||
def test_install_dir_exists(install_mockery, monkeypatch):
|
||||
"""Cover capture of install directory exists error."""
|
||||
def _install(installer, task):
|
||||
raise dl.InstallDirectoryAlreadyExistsError(task.pkg.prefix)
|
||||
|
||||
# Ensure raise the desired exception
|
||||
monkeypatch.setattr(inst.PackageInstaller, '_install_task', _install)
|
||||
|
||||
const_arg = installer_args(['b'], {})
|
||||
installer = create_installer(const_arg)
|
||||
|
||||
err = 'already exists'
|
||||
with pytest.raises(dl.InstallDirectoryAlreadyExistsError, match=err):
|
||||
installer.install()
|
||||
|
||||
b, _ = const_arg[0]
|
||||
assert inst.package_id(b.package) in installer.installed
|
||||
|
||||
|
||||
def test_install_dir_exists_multi(install_mockery, monkeypatch, capfd):
|
||||
"""Cover capture of install directory exists error for multiple specs."""
|
||||
def _install(installer, task):
|
||||
raise dl.InstallDirectoryAlreadyExistsError(task.pkg.prefix)
|
||||
|
||||
# Skip the actual installation though should never reach it
|
||||
monkeypatch.setattr(inst.PackageInstaller, '_install_task', _install)
|
||||
|
||||
# Use two packages to ensure multiple specs
|
||||
const_arg = installer_args(['b', 'c'], {})
|
||||
installer = create_installer(const_arg)
|
||||
|
||||
with pytest.raises(inst.InstallError, match='Installation request failed'):
|
||||
installer.install()
|
||||
|
||||
err = capfd.readouterr()[1]
|
||||
assert 'already exists' in err
|
||||
for spec, install_args in const_arg:
|
||||
pkg_id = inst.package_id(spec.package)
|
||||
assert pkg_id in installer.installed
|
||||
|
||||
|
||||
def test_install_skip_patch(install_mockery, mock_fetch):
|
||||
"""Test the path skip_patch install path."""
|
||||
spec_name = 'b'
|
||||
|
|
Loading…
Reference in a new issue