Bugfix: spack find -p fails in environment (#13972)

* force spack find -p to print abstract specs without prefixes
* hashes have the same issue; improve handling of find -L to match find -l
This commit is contained in:
Greg Becker 2019-12-06 12:29:57 -08:00 committed by Todd Gamblin
parent 65a292fbbf
commit 99c9365974
3 changed files with 26 additions and 1 deletions

View File

@ -212,6 +212,9 @@ def disambiguate_spec(spec, env, local=False, installed=True):
def gray_hash(spec, length):
if not length:
# default to maximum hash length
length = 32
h = spec.dag_hash(length) if spec.concrete else '-' * length
return colorize('@K{%s}' % h)

View File

@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from __future__ import print_function
import copy
import llnl.util.tty as tty
import llnl.util.tty.color as color
@ -166,11 +167,16 @@ def display_env(env, args, decorator):
else:
tty.msg('Root specs')
# Root specs cannot be displayed with prefixes, since those are not
# set for abstract specs. Same for hashes
root_args = copy.copy(args)
root_args.paths = False
# Roots are displayed with variants, etc. so that we can see
# specifically what the user asked for.
cmd.display_specs(
env.user_specs,
args,
root_args,
decorator=lambda s, f: color.colorize('@*{%s}' % f),
namespace=True,
show_flags=True,

View File

@ -12,9 +12,12 @@
from spack.main import SpackCommand
from spack.spec import Spec
from spack.util.pattern import Bunch
import spack.environment as ev
find = SpackCommand('find')
env = SpackCommand('env')
install = SpackCommand('install')
base32_alphabet = 'abcdefghijklmnopqrstuvwxyz234567'
@ -302,3 +305,16 @@ def test_find_no_sections(database, config):
def test_find_command_basic_usage(database):
output = find()
assert 'mpileaks' in output
@pytest.mark.regression('9875')
def test_find_prefix_in_env(mutable_mock_env_path, install_mockery, mock_fetch,
mock_packages, mock_archive, config):
"""Test `find` formats requiring concrete specs work in environments."""
env('create', 'test')
with ev.read('test'):
install('mpileaks')
find('-p')
find('-l')
find('-L')
# Would throw error on regression