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:
Todd Gamblin 2014-08-09 17:41:56 -07:00
parent 5f073ae220
commit 98797459f3
4 changed files with 29 additions and 3 deletions

View file

@ -89,7 +89,7 @@ def find(parser, args):
format = " %-{}s%s".format(width)
for abbrv, spec in zip(abbreviated, specs):
print format % (abbrv, spec.package.prefix)
print format % (abbrv, spec.prefix)
elif args.full_specs:
for spec in specs:

View file

@ -29,6 +29,7 @@
import shutil
from contextlib import closing
import llnl.util.tty as tty
from llnl.util.filesystem import join_path, mkdirp
import spack
@ -163,6 +164,11 @@ def read_spec(self, path):
if not spack.db.exists(spec.name):
spec._normal = 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

View file

@ -115,7 +115,13 @@ def installed_package_specs(self):
"""Read installed package names straight from the install directory
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

View file

@ -25,15 +25,18 @@
import os
import unittest
import shutil
import tempfile
from contextlib import closing
from llnl.util.filesystem import *
import spack
from spack.stage import Stage
from spack.directory_layout import SpecHashDirectoryLayout
from spack.util.executable import which
from spack.test.mock_packages_test import *
dir_name = 'trivial-1.0'
archive_name = 'trivial-1.0.tar.gz'
install_test_package = 'trivial_install_test_package'
@ -66,9 +69,16 @@ def setUp(self):
tar = which('tar')
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
# 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):
super(InstallTest, self).tearDown()
@ -78,6 +88,10 @@ def tearDown(self):
# Turn checksumming back on
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):
# Get a basic concrete spec for the trivial install package.