summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarmen Stoppels <harmenstoppels@gmail.com>2021-09-10 20:32:46 +0200
committerGitHub <noreply@github.com>2021-09-10 11:32:46 -0700
commit729726d157a458471741cfd4980ccb17cffc8de5 (patch)
tree8721d8d5d6b4e696b79d283d7d51de33346896e8
parent81962f100ce412985863211f2646e1295fe6ee7e (diff)
downloadspack-729726d157a458471741cfd4980ccb17cffc8de5.tar.gz
spack-729726d157a458471741cfd4980ccb17cffc8de5.tar.bz2
spack-729726d157a458471741cfd4980ccb17cffc8de5.tar.xz
spack-729726d157a458471741cfd4980ccb17cffc8de5.zip
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).
-rw-r--r--lib/spack/spack/directory_layout.py12
-rw-r--r--lib/spack/spack/installer.py15
-rw-r--r--lib/spack/spack/test/installer.py42
3 files changed, 0 insertions, 69 deletions
diff --git a/lib/spack/spack/directory_layout.py b/lib/spack/spack/directory_layout.py
index 3db001da90..563cf84f4c 100644
--- a/lib/spack/spack/directory_layout.py
+++ b/lib/spack/spack/directory_layout.py
@@ -217,10 +217,6 @@ class DirectoryLayout(object):
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 @@ class InconsistentInstallDirectoryError(DirectoryLayoutError):
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."""
diff --git a/lib/spack/spack/installer.py b/lib/spack/spack/installer.py
index eb409caffe..d6a0bcabd7 100644
--- a/lib/spack/spack/installer.py
+++ b/lib/spack/spack/installer.py
@@ -1590,21 +1590,6 @@ class PackageInstaller(object):
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.
diff --git a/lib/spack/spack/test/installer.py b/lib/spack/spack/test/installer.py
index 485fbb1536..37ce6f5bdb 100644
--- a/lib/spack/spack/test/installer.py
+++ b/lib/spack/spack/test/installer.py
@@ -14,7 +14,6 @@ import llnl.util.tty as tty
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 test_install_read_locked_requeue(install_mockery, monkeypatch, capfd):
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'