diff options
author | Peter Scheibel <scheibel1@llnl.gov> | 2019-06-29 16:04:15 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2019-06-29 16:04:15 -0700 |
commit | 9c16b4a7f6527db3f30e79b14a0d066084c8508f (patch) | |
tree | 103aced0b1f21dd0e166b85ef36190ed9cebe13c /lib | |
parent | 7f2e364fa1aa573579916aa4f3acd4c020e18358 (diff) | |
download | spack-9c16b4a7f6527db3f30e79b14a0d066084c8508f.tar.gz spack-9c16b4a7f6527db3f30e79b14a0d066084c8508f.tar.bz2 spack-9c16b4a7f6527db3f30e79b14a0d066084c8508f.tar.xz spack-9c16b4a7f6527db3f30e79b14a0d066084c8508f.zip |
Allow uninstalling missing packages (#11874)
Remove package access from directory_layout; add regression test to ensure
that specs can be uninstalled without a package being known
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/directory_layout.py | 11 | ||||
-rw-r--r-- | lib/spack/spack/test/install.py | 14 |
2 files changed, 19 insertions, 6 deletions
diff --git a/lib/spack/spack/directory_layout.py b/lib/spack/spack/directory_layout.py index 4f77e618ce..60bc18a5b8 100644 --- a/lib/spack/spack/directory_layout.py +++ b/lib/spack/spack/directory_layout.py @@ -78,10 +78,13 @@ class DirectoryLayout(object): if spec.external: return spec.external_path - if self.check_upstream and spec.package.installed_upstream: - raise SpackError( - "Internal error: attempted to call path_for_spec on" - " upstream-installed package.") + if self.check_upstream: + upstream, record = spack.store.db.query_by_spec_hash( + spec.dag_hash()) + if upstream: + raise SpackError( + "Internal error: attempted to call path_for_spec on" + " upstream-installed package.") path = self.relative_path_for_spec(spec) assert(not path.startswith(self.root)) diff --git a/lib/spack/spack/test/install.py b/lib/spack/spack/test/install.py index 79287c2adf..8e1d5c7940 100644 --- a/lib/spack/spack/test/install.py +++ b/lib/spack/spack/test/install.py @@ -12,17 +12,27 @@ import spack.store from spack.spec import Spec -def test_install_and_uninstall(install_mockery, mock_fetch): +def test_install_and_uninstall(install_mockery, mock_fetch, monkeypatch): # Get a basic concrete spec for the trivial install package. spec = Spec('trivial-install-test-package') spec.concretize() assert spec.concrete # Get the package - pkg = spack.repo.get(spec) + pkg = spec.package + + def find_nothing(*args): + raise spack.repo.UnknownPackageError( + 'Repo package access is disabled for test') try: pkg.do_install() + + spec._package = None + monkeypatch.setattr(spack.repo, 'get', find_nothing) + with pytest.raises(spack.repo.UnknownPackageError): + spec.package + pkg.do_uninstall() except Exception: pkg.remove_prefix() |