Skip to content

Commit 322d512

Browse files
committed
Promote single string to list
1 parent a85a51a commit 322d512

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

easybuild/tools/run.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,10 @@ def extract_errors_from_log(log_txt, reg_exps):
600600
:return (warnings, errors) as lists of lines containing a match
601601
"""
602602

603-
# Avoid accidentally passing a single element
604-
assert isinstance(reg_exps, list), "reg_exps must be a list"
603+
# promote single string value to list, since code below expects a list
604+
if isinstance(reg_exps, string_type):
605+
reg_exps = [reg_exps]
606+
605607
re_tuples = []
606608
for cur in reg_exps:
607609
try:
@@ -614,6 +616,7 @@ def extract_errors_from_log(log_txt, reg_exps):
614616
re_tuples.append((re.compile(reg_exp), action))
615617
except Exception as e:
616618
raise EasyBuildError("Invalid input: No RegExp or tuple of RegExp and action '%s' (%s)", str(cur), e)
619+
617620
warnings = []
618621
errors = []
619622
for line in log_txt.split('\n'):

test/framework/run.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,13 @@ def test_check_log_for_errors(self):
540540
])
541541
expected_error_msg = r"Found 2 error\(s\) in command output \(output: error found, the process crashed with 0\)"
542542

543+
# String promoted to list
544+
self.assertErrorRegex(EasyBuildError, expected_error_msg, check_log_for_errors, input_text,
545+
r"\b(error|crashed)\b")
546+
# List of string(s)
543547
self.assertErrorRegex(EasyBuildError, expected_error_msg, check_log_for_errors, input_text,
544548
[r"\b(error|crashed)\b"])
549+
# List of tuple(s)
545550
self.assertErrorRegex(EasyBuildError, expected_error_msg, check_log_for_errors, input_text,
546551
[(r"\b(error|crashed)\b", ERROR)])
547552

0 commit comments

Comments
 (0)