Minor tweaks after spec update.
- spack find -p works properly (get path from spec, not package) - directory layout and PackageDB normalize things automatically unless they're unknown packages (need to do this for spack find -l) - install test made robust to mock/main package conflicts
This commit is contained in:
		@@ -89,7 +89,7 @@ def find(parser, args):
 | 
				
			|||||||
                format = "    %-{}s%s".format(width)
 | 
					                format = "    %-{}s%s".format(width)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                for abbrv, spec in zip(abbreviated, specs):
 | 
					                for abbrv, spec in zip(abbreviated, specs):
 | 
				
			||||||
                    print format % (abbrv, spec.package.prefix)
 | 
					                    print format % (abbrv, spec.prefix)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            elif args.full_specs:
 | 
					            elif args.full_specs:
 | 
				
			||||||
                for spec in specs:
 | 
					                for spec in specs:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,6 +29,7 @@
 | 
				
			|||||||
import shutil
 | 
					import shutil
 | 
				
			||||||
from contextlib import closing
 | 
					from contextlib import closing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import llnl.util.tty as tty
 | 
				
			||||||
from llnl.util.filesystem import join_path, mkdirp
 | 
					from llnl.util.filesystem import join_path, mkdirp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import spack
 | 
					import spack
 | 
				
			||||||
@@ -163,6 +164,11 @@ def read_spec(self, path):
 | 
				
			|||||||
        if not spack.db.exists(spec.name):
 | 
					        if not spack.db.exists(spec.name):
 | 
				
			||||||
            spec._normal = True
 | 
					            spec._normal = True
 | 
				
			||||||
            spec._concrete = True
 | 
					            spec._concrete = True
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            spec.normalize()
 | 
				
			||||||
 | 
					            if not spec.concrete:
 | 
				
			||||||
 | 
					                tty.warn("Spec read from installed package is not concrete:",
 | 
				
			||||||
 | 
					                         path, spec)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return spec
 | 
					        return spec
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -115,7 +115,13 @@ def installed_package_specs(self):
 | 
				
			|||||||
        """Read installed package names straight from the install directory
 | 
					        """Read installed package names straight from the install directory
 | 
				
			||||||
           layout.
 | 
					           layout.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        return spack.install_layout.all_specs()
 | 
					        # Get specs from the directory layout but ensure that they're
 | 
				
			||||||
 | 
					        # all normalized properly.
 | 
				
			||||||
 | 
					        installed = []
 | 
				
			||||||
 | 
					        for spec in spack.install_layout.all_specs():
 | 
				
			||||||
 | 
					            spec.normalize()
 | 
				
			||||||
 | 
					            installed.append(spec)
 | 
				
			||||||
 | 
					        return installed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @memoized
 | 
					    @memoized
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,15 +25,18 @@
 | 
				
			|||||||
import os
 | 
					import os
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
import shutil
 | 
					import shutil
 | 
				
			||||||
 | 
					import tempfile
 | 
				
			||||||
from contextlib import closing
 | 
					from contextlib import closing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from llnl.util.filesystem import *
 | 
					from llnl.util.filesystem import *
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import spack
 | 
					import spack
 | 
				
			||||||
from spack.stage import Stage
 | 
					from spack.stage import Stage
 | 
				
			||||||
 | 
					from spack.directory_layout import SpecHashDirectoryLayout
 | 
				
			||||||
from spack.util.executable import which
 | 
					from spack.util.executable import which
 | 
				
			||||||
from spack.test.mock_packages_test import *
 | 
					from spack.test.mock_packages_test import *
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
dir_name = 'trivial-1.0'
 | 
					dir_name = 'trivial-1.0'
 | 
				
			||||||
archive_name = 'trivial-1.0.tar.gz'
 | 
					archive_name = 'trivial-1.0.tar.gz'
 | 
				
			||||||
install_test_package = 'trivial_install_test_package'
 | 
					install_test_package = 'trivial_install_test_package'
 | 
				
			||||||
@@ -66,9 +69,16 @@ def setUp(self):
 | 
				
			|||||||
            tar = which('tar')
 | 
					            tar = which('tar')
 | 
				
			||||||
            tar('-czf', archive_name, dir_name)
 | 
					            tar('-czf', archive_name, dir_name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # We use a fake pacakge, so skip the checksum.
 | 
					        # We use a fake package, so skip the checksum.
 | 
				
			||||||
        spack.do_checksum = False
 | 
					        spack.do_checksum = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # Use a fake install directory to avoid conflicts bt/w
 | 
				
			||||||
 | 
					        # installed pkgs and mock packages.
 | 
				
			||||||
 | 
					        self.tmpdir = tempfile.mkdtemp()
 | 
				
			||||||
 | 
					        self.orig_layout = spack.install_layout
 | 
				
			||||||
 | 
					        spack.install_layout = SpecHashDirectoryLayout(self.tmpdir)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def tearDown(self):
 | 
					    def tearDown(self):
 | 
				
			||||||
        super(InstallTest, self).tearDown()
 | 
					        super(InstallTest, self).tearDown()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -78,6 +88,10 @@ def tearDown(self):
 | 
				
			|||||||
        # Turn checksumming back on
 | 
					        # Turn checksumming back on
 | 
				
			||||||
        spack.do_checksum = True
 | 
					        spack.do_checksum = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # restore spack's layout.
 | 
				
			||||||
 | 
					        spack.install_layout = self.orig_layout
 | 
				
			||||||
 | 
					        shutil.rmtree(self.tmpdir, ignore_errors=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_install_and_uninstall(self):
 | 
					    def test_install_and_uninstall(self):
 | 
				
			||||||
        # Get a basic concrete spec for the trivial install package.
 | 
					        # Get a basic concrete spec for the trivial install package.
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user