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.
This commit is contained in:
		
				
					committed by
					
						
						Greg Becker
					
				
			
			
				
	
			
			
			
						parent
						
							5cf8878185
						
					
				
				
					commit
					b856e24444
				
			@@ -9,6 +9,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
from llnl.util.filesystem import mkdirp, touch, working_dir
 | 
					from llnl.util.filesystem import mkdirp, touch, working_dir
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from spack.package import InstallError, PackageBase, PackageStillNeededError
 | 
				
			||||||
import spack.patch
 | 
					import spack.patch
 | 
				
			||||||
import spack.repo
 | 
					import spack.repo
 | 
				
			||||||
import spack.store
 | 
					import spack.store
 | 
				
			||||||
@@ -275,6 +276,21 @@ class MockInstallError(spack.error.SpackError):
 | 
				
			|||||||
    pass
 | 
					    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):
 | 
					def test_pkg_build_paths(install_mockery):
 | 
				
			||||||
    # 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').concretized()
 | 
					    spec = Spec('trivial-install-test-package').concretized()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -353,3 +353,13 @@ def test_git_url_top_level_conflicts(mock_packages, config):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    with pytest.raises(spack.fetch_strategy.FetcherConflict):
 | 
					    with pytest.raises(spack.fetch_strategy.FetcherConflict):
 | 
				
			||||||
        spack.fetch_strategy.for_package_version(pkg, '1.3')
 | 
					        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
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user