diff options
author | Asher Mancinelli <ashermancinelli@gmail.com> | 2021-06-24 16:12:45 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-24 22:12:45 +0000 |
commit | 010b431692f5b7fd755e685cad057e6c288c161e (patch) | |
tree | 431b0dffbf839578e913d75efac65727f981e213 /lib | |
parent | e45800126a166822cc4ab5f2ed53ae71e9c9b369 (diff) | |
download | spack-010b431692f5b7fd755e685cad057e6c288c161e.tar.gz spack-010b431692f5b7fd755e685cad057e6c288c161e.tar.bz2 spack-010b431692f5b7fd755e685cad057e6c288c161e.tar.xz spack-010b431692f5b7fd755e685cad057e6c288c161e.zip |
Add Externally Findable section to info command (#24503)
* Add Externally Findable section to info command
* Use comma delimited detection attributes in addition to boolean value
* Unit test externally detectable part of spack info
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/cmd/info.py | 20 | ||||
-rw-r--r-- | lib/spack/spack/test/cmd/info.py | 17 |
2 files changed, 37 insertions, 0 deletions
diff --git a/lib/spack/spack/cmd/info.py b/lib/spack/spack/cmd/info.py index 441223b738..c3e5a51903 100644 --- a/lib/spack/spack/cmd/info.py +++ b/lib/spack/spack/cmd/info.py @@ -156,6 +156,26 @@ def print_text_info(pkg): color.cprint(section_title('Maintainers: ') + mnt) color.cprint('') + color.cprint(section_title('Externally Detectable: ')) + + # If the package has an 'executables' field, it can detect an installation + if hasattr(pkg, 'executables'): + find_attributes = [] + if hasattr(pkg, 'determine_version'): + find_attributes.append('version') + + if hasattr(pkg, 'determine_variants'): + find_attributes.append('variants') + + # If the package does not define 'determine_version' nor + # 'determine_variants', then it must use some custom detection + # mechanism. In this case, just inform the user it's detectable somehow. + color.cprint(' True{0}'.format( + ' (' + ', '.join(find_attributes) + ')' if find_attributes else '')) + else: + color.cprint(' False') + + color.cprint('') color.cprint(section_title("Tags: ")) if hasattr(pkg, 'tags'): tags = sorted(pkg.tags) diff --git a/lib/spack/spack/test/cmd/info.py b/lib/spack/spack/test/cmd/info.py index 0ff6857617..b62a842b8b 100644 --- a/lib/spack/spack/test/cmd/info.py +++ b/lib/spack/spack/test/cmd/info.py @@ -48,6 +48,22 @@ def test_it_just_runs(pkg): info(pkg) +@pytest.mark.parametrize('pkg_query,expected', [ + ('zlib', 'False'), + ('gcc', 'True (version, variants)'), +]) +@pytest.mark.usefixtures('mock_print') +def test_is_externally_detectable(pkg_query, expected, parser, info_lines): + args = parser.parse_args([pkg_query]) + spack.cmd.info.info(parser, args) + + line_iter = info_lines.__iter__() + for line in line_iter: + if 'Externally Detectable' in line: + is_externally_detectable = next(line_iter).strip() + assert is_externally_detectable == expected + + @pytest.mark.parametrize('pkg_query', [ 'hdf5', 'cloverleaf3d', @@ -59,6 +75,7 @@ def test_info_fields(pkg_query, parser, info_lines): expected_fields = ( 'Description:', 'Homepage:', + 'Externally Detectable:', 'Safe versions:', 'Variants:', 'Installation Phases:', |