Skip to content

Commit 731649d

Browse files
authored
Merge pull request #4361 from Flamefire/improve-error-check
deduplicate warnings & errors found in logs and add initial newline + tab in output
2 parents 685467c + 96c7a04 commit 731649d

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

easybuild/tools/run.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
from easybuild.tools.config import ERROR, IGNORE, WARN, build_option
5353
from easybuild.tools.hooks import RUN_SHELL_CMD, load_hooks, run_hook
5454
from easybuild.tools.py2vs3 import string_type
55-
from easybuild.tools.utilities import trace_msg
55+
from easybuild.tools.utilities import nub, trace_msg
5656

5757

5858
_log = fancylogger.getLogger('run', fname=False)
@@ -790,7 +790,7 @@ def extract_errors_from_log(log_txt, reg_exps):
790790
elif action == WARN:
791791
warnings.append(line)
792792
break
793-
return warnings, errors
793+
return nub(warnings), nub(errors)
794794

795795

796796
def check_log_for_errors(log_txt, reg_exps):
@@ -805,8 +805,8 @@ def check_log_for_errors(log_txt, reg_exps):
805805

806806
errors_found_in_log += len(warnings) + len(errors)
807807
if warnings:
808-
_log.warning("Found %s potential error(s) in command output (output: %s)",
808+
_log.warning("Found %s potential error(s) in command output:\n\t%s",
809809
len(warnings), "\n\t".join(warnings))
810810
if errors:
811-
raise EasyBuildError("Found %s error(s) in command output (output: %s)",
811+
raise EasyBuildError("Found %s error(s) in command output:\n\t%s",
812812
len(errors), "\n\t".join(errors))

test/framework/run.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,9 @@ def test_check_log_for_errors(self):
705705
"enabling -Werror",
706706
"the process crashed with 0"
707707
])
708-
expected_msg = r"Found 2 error\(s\) in command output "\
709-
r"\(output: error found\n\tthe process crashed with 0\)"
708+
expected_msg = r"Found 2 error\(s\) in command output:\n"\
709+
r"\terror found\n"\
710+
r"\tthe process crashed with 0"
710711

711712
# String promoted to list
712713
self.assertErrorRegex(EasyBuildError, expected_msg, check_log_for_errors, input_text,
@@ -718,14 +719,17 @@ def test_check_log_for_errors(self):
718719
self.assertErrorRegex(EasyBuildError, expected_msg, check_log_for_errors, input_text,
719720
[(r"\b(error|crashed)\b", ERROR)])
720721

721-
expected_msg = "Found 2 potential error(s) in command output " \
722-
"(output: error found\n\tthe process crashed with 0)"
722+
expected_msg = "Found 2 potential error(s) in command output:\n"\
723+
"\terror found\n"\
724+
"\tthe process crashed with 0"
723725
init_logging(logfile, silent=True)
724726
check_log_for_errors(input_text, [(r"\b(error|crashed)\b", WARN)])
725727
stop_logging(logfile)
726728
self.assertIn(expected_msg, read_file(logfile))
727729

728-
expected_msg = r"Found 2 error\(s\) in command output \(output: error found\n\ttest failed\)"
730+
expected_msg = r"Found 2 error\(s\) in command output:\n"\
731+
r"\terror found\n"\
732+
r"\ttest failed"
729733
write_file(logfile, '')
730734
init_logging(logfile, silent=True)
731735
self.assertErrorRegex(EasyBuildError, expected_msg, check_log_for_errors, input_text, [
@@ -735,7 +739,7 @@ def test_check_log_for_errors(self):
735739
"fail"
736740
])
737741
stop_logging(logfile)
738-
expected_msg = "Found 1 potential error(s) in command output (output: the process crashed with 0)"
742+
expected_msg = "Found 1 potential error(s) in command output:\n\tthe process crashed with 0"
739743
self.assertIn(expected_msg, read_file(logfile))
740744

741745
def test_run_cmd_with_hooks(self):

0 commit comments

Comments
 (0)