From b856e24444c0bd9933abfd6f54551259e2dcf1dc Mon Sep 17 00:00:00 2001 From: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com> Date: Wed, 17 Jul 2019 13:08:08 -0700 Subject: tests: uninstall_by_spec error and rpath_args tests (#11971) * tests: Add uninstall_by_spec error tests. These tests were originally included in PR #11797. --- lib/spack/spack/test/install.py | 16 ++++++++++++++++ lib/spack/spack/test/packages.py | 10 ++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/spack/spack/test/install.py b/lib/spack/spack/test/install.py index ec70bdec42..296322b7ed 100644 --- a/lib/spack/spack/test/install.py +++ b/lib/spack/spack/test/install.py @@ -9,6 +9,7 @@ import shutil from llnl.util.filesystem import mkdirp, touch, working_dir +from spack.package import InstallError, PackageBase, PackageStillNeededError import spack.patch import spack.repo import spack.store @@ -275,6 +276,21 @@ class MockInstallError(spack.error.SpackError): pass +def test_uninstall_by_spec_errors(mutable_database): + """Test exceptional cases with the uninstall command.""" + + # Try to uninstall a spec that has not been installed + rec = mutable_database.get_record('zmpi') + with pytest.raises(InstallError, matches="not installed"): + PackageBase.uninstall_by_spec(rec.spec) + + # Try an unforced uninstall of a spec with dependencies + rec = mutable_database.get_record('mpich') + + with pytest.raises(PackageStillNeededError, matches="cannot uninstall"): + PackageBase.uninstall_by_spec(rec.spec) + + def test_pkg_build_paths(install_mockery): # Get a basic concrete spec for the trivial install package. spec = Spec('trivial-install-test-package').concretized() diff --git a/lib/spack/spack/test/packages.py b/lib/spack/spack/test/packages.py index d0b570e2af..43f1719ca3 100644 --- a/lib/spack/spack/test/packages.py +++ b/lib/spack/spack/test/packages.py @@ -353,3 +353,13 @@ def test_git_url_top_level_conflicts(mock_packages, config): with pytest.raises(spack.fetch_strategy.FetcherConflict): spack.fetch_strategy.for_package_version(pkg, '1.3') + + +def test_rpath_args(mutable_database): + """Test a package's rpath_args property.""" + + rec = mutable_database.get_record('mpich') + + rpath_args = rec.spec.package.rpath_args + assert '-rpath' in rpath_args + assert 'mpich' in rpath_args -- cgit v1.2.3-60-g2f50