Skip malformed spec strings when searching for externals (#19438)

fixes #19266

fzf search method has also been updated

Co-authored-by: Tom Scogland <tom.scogland@gmail.com>
This commit is contained in:
Massimiliano Culpo
2020-10-21 21:35:02 +02:00
committed by GitHub
parent 2bb775496e
commit c696518efd
2 changed files with 17 additions and 12 deletions

View File

@@ -202,14 +202,19 @@ def determine_spec_details(cls, prefix, exes_in_prefix):
external_modules = extra_attributes.pop( external_modules = extra_attributes.pop(
'modules', None 'modules', None
) )
spec = spack.spec.Spec( try:
spec_str, spec = spack.spec.Spec(
external_path=external_path, spec_str,
external_modules=external_modules external_path=external_path,
) external_modules=external_modules
specs.append(spack.spec.Spec.from_detection( )
spec, extra_attributes=extra_attributes except Exception as e:
)) msg = 'Parsing failed [spec_str="{0}", error={1}]'
tty.debug(msg.format(spec_str, str(e)))
else:
specs.append(spack.spec.Spec.from_detection(
spec, extra_attributes=extra_attributes
))
return sorted(specs) return sorted(specs)

View File

@@ -2,12 +2,10 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details. # Spack Project Developers. See the top-level COPYRIGHT file for details.
# #
# SPDX-License-Identifier: (Apache-2.0 OR MIT) # SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os import os
import re
import shutil import shutil
from spack import *
class Fzf(MakefilePackage): class Fzf(MakefilePackage):
"""fzf is a general-purpose command-line fuzzy finder.""" """fzf is a general-purpose command-line fuzzy finder."""
@@ -37,7 +35,9 @@ class Fzf(MakefilePackage):
@classmethod @classmethod
def determine_version(cls, exe): def determine_version(cls, exe):
return Executable(exe)('--version', output=str, error=str).rstrip() candidate = Executable(exe)('--version', output=str, error=str)
match = re.match(r'(^[\d.]+)', candidate)
return match.group(1) if match else None
@when('@:0.17.5') @when('@:0.17.5')
def patch(self): def patch(self):