Skip to content
Snippets Groups Projects
Commit 9c16b4a7 authored by Peter Scheibel's avatar Peter Scheibel Committed by Todd Gamblin
Browse files

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
parent 7f2e364f
No related branches found
No related tags found
No related merge requests found
...@@ -78,10 +78,13 @@ def path_for_spec(self, spec): ...@@ -78,10 +78,13 @@ def path_for_spec(self, spec):
if spec.external: if spec.external:
return spec.external_path return spec.external_path
if self.check_upstream and spec.package.installed_upstream: if self.check_upstream:
raise SpackError( upstream, record = spack.store.db.query_by_spec_hash(
"Internal error: attempted to call path_for_spec on" spec.dag_hash())
" upstream-installed package.") if upstream:
raise SpackError(
"Internal error: attempted to call path_for_spec on"
" upstream-installed package.")
path = self.relative_path_for_spec(spec) path = self.relative_path_for_spec(spec)
assert(not path.startswith(self.root)) assert(not path.startswith(self.root))
......
...@@ -12,17 +12,27 @@ ...@@ -12,17 +12,27 @@
from spack.spec import Spec 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. # Get a basic concrete spec for the trivial install package.
spec = Spec('trivial-install-test-package') spec = Spec('trivial-install-test-package')
spec.concretize() spec.concretize()
assert spec.concrete assert spec.concrete
# Get the package # 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: try:
pkg.do_install() pkg.do_install()
spec._package = None
monkeypatch.setattr(spack.repo, 'get', find_nothing)
with pytest.raises(spack.repo.UnknownPackageError):
spec.package
pkg.do_uninstall() pkg.do_uninstall()
except Exception: except Exception:
pkg.remove_prefix() pkg.remove_prefix()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment