diff options
author | Greg Becker <becker33@llnl.gov> | 2019-12-06 12:29:57 -0800 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2019-12-06 12:29:57 -0800 |
commit | 99c9365974c4a4e282b7e988bb1942c19129cb02 (patch) | |
tree | e739c13cefb987636070a1751a711c97237b59d2 | |
parent | 65a292fbbf90c89c27a6e253c7e85651451c8c6c (diff) | |
download | spack-99c9365974c4a4e282b7e988bb1942c19129cb02.tar.gz spack-99c9365974c4a4e282b7e988bb1942c19129cb02.tar.bz2 spack-99c9365974c4a4e282b7e988bb1942c19129cb02.tar.xz spack-99c9365974c4a4e282b7e988bb1942c19129cb02.zip |
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
-rw-r--r-- | lib/spack/spack/cmd/__init__.py | 3 | ||||
-rw-r--r-- | lib/spack/spack/cmd/find.py | 8 | ||||
-rw-r--r-- | lib/spack/spack/test/cmd/find.py | 16 |
3 files changed, 26 insertions, 1 deletions
diff --git a/lib/spack/spack/cmd/__init__.py b/lib/spack/spack/cmd/__init__.py index 0d2e92940b..87526e32d9 100644 --- a/lib/spack/spack/cmd/__init__.py +++ b/lib/spack/spack/cmd/__init__.py @@ -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) diff --git a/lib/spack/spack/cmd/find.py b/lib/spack/spack/cmd/find.py index 37cfcd30d5..65946e2a4c 100644 --- a/lib/spack/spack/cmd/find.py +++ b/lib/spack/spack/cmd/find.py @@ -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, diff --git a/lib/spack/spack/test/cmd/find.py b/lib/spack/spack/test/cmd/find.py index 45b065fce9..fe29d12d59 100644 --- a/lib/spack/spack/test/cmd/find.py +++ b/lib/spack/spack/test/cmd/find.py @@ -12,9 +12,12 @@ import spack.cmd.find 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 |