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
This commit is contained in:
parent
e45800126a
commit
010b431692
@ -155,6 +155,26 @@ def print_text_info(pkg):
|
||||
color.cprint('')
|
||||
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'):
|
||||
|
@ -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:',
|
||||
|
Loading…
Reference in New Issue
Block a user