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:
parent
65a292fbbf
commit
99c9365974
@ -212,6 +212,9 @@ def disambiguate_spec(spec, env, local=False, installed=True):
|
|||||||
|
|
||||||
|
|
||||||
def gray_hash(spec, length):
|
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
|
h = spec.dag_hash(length) if spec.concrete else '-' * length
|
||||||
return colorize('@K{%s}' % h)
|
return colorize('@K{%s}' % h)
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
import copy
|
||||||
|
|
||||||
import llnl.util.tty as tty
|
import llnl.util.tty as tty
|
||||||
import llnl.util.tty.color as color
|
import llnl.util.tty.color as color
|
||||||
@ -166,11 +167,16 @@ def display_env(env, args, decorator):
|
|||||||
else:
|
else:
|
||||||
tty.msg('Root specs')
|
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
|
# Roots are displayed with variants, etc. so that we can see
|
||||||
# specifically what the user asked for.
|
# specifically what the user asked for.
|
||||||
cmd.display_specs(
|
cmd.display_specs(
|
||||||
env.user_specs,
|
env.user_specs,
|
||||||
args,
|
root_args,
|
||||||
decorator=lambda s, f: color.colorize('@*{%s}' % f),
|
decorator=lambda s, f: color.colorize('@*{%s}' % f),
|
||||||
namespace=True,
|
namespace=True,
|
||||||
show_flags=True,
|
show_flags=True,
|
||||||
|
@ -12,9 +12,12 @@
|
|||||||
from spack.main import SpackCommand
|
from spack.main import SpackCommand
|
||||||
from spack.spec import Spec
|
from spack.spec import Spec
|
||||||
from spack.util.pattern import Bunch
|
from spack.util.pattern import Bunch
|
||||||
|
import spack.environment as ev
|
||||||
|
|
||||||
|
|
||||||
find = SpackCommand('find')
|
find = SpackCommand('find')
|
||||||
|
env = SpackCommand('env')
|
||||||
|
install = SpackCommand('install')
|
||||||
|
|
||||||
base32_alphabet = 'abcdefghijklmnopqrstuvwxyz234567'
|
base32_alphabet = 'abcdefghijklmnopqrstuvwxyz234567'
|
||||||
|
|
||||||
@ -302,3 +305,16 @@ def test_find_no_sections(database, config):
|
|||||||
def test_find_command_basic_usage(database):
|
def test_find_command_basic_usage(database):
|
||||||
output = find()
|
output = find()
|
||||||
assert 'mpileaks' in output
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user