From 9503d681ad5fc425e17dfee6ea9a30667dc111e2 Mon Sep 17 00:00:00 2001 From: Mathieu Courtois <mathieu.courtois@edf.fr> Date: Tue, 18 Dec 2018 16:39:54 +0100 Subject: [PATCH] [#28360] Report ParserMsg in case of error in the fortran parser. --HG-- branch : edf/mc --- bin/maint/mergexx | 4 ++-- lib/aslint/fortran/check_source.py | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/bin/maint/mergexx b/bin/maint/mergexx index 6ce1e66e..6029c03f 100755 --- a/bin/maint/mergexx +++ b/bin/maint/mergexx @@ -48,7 +48,7 @@ run_main() [ $# -ne 1 ] && _error "exactly one argument is expected." tag="$1" - if [ $(hg status | wc -l) -ne 0 ]; then + if [ $(hg status -ardm | wc -l) -ne 0 ]; then _error "uncommitted changes! Please discard or commit first." fi @@ -65,7 +65,7 @@ run_main() printf "\ncommitting with message '${msg}'...\n" hg ci -m "${msg}" || _error "failed" - printf "\nDo forget to submit the new revision!\n" + printf "\nDo not forget to submit the new revision!\n" return ${?} } diff --git a/lib/aslint/fortran/check_source.py b/lib/aslint/fortran/check_source.py index 1b377d6a..a05873f6 100644 --- a/lib/aslint/fortran/check_source.py +++ b/lib/aslint/fortran/check_source.py @@ -15,15 +15,27 @@ from aslint.config import ASCFG from aslint.decorators import interrupt_decorator from aslint.utils import apply_in_sandbox from aslint.base_checkers import ( - Report, MsgList, CheckList, CompilMsg, + Report, MsgList, CheckList, CompilMsg, GenericMsg, call_checkers, check_file_content, check_filename, check_disabled, check_fortran_code, ) +from aslint.fortran.free.fortran_code import FortranParserError import aslint.fortran.gfortran_checkers as GFORT import aslint.fortran.static_fortran_checkers as STAT import aslint.common_checkers as COMM +class ParserMsg(GenericMsg): + """Fortran parser error + There is probably an error reported by the compiler. Otherwise, please + report this error.""" + id = 'C1011' + + def search(self, txt): + """Returns the error message""" + return [": " + txt] + + @interrupt_decorator def check_fortran_source(fname, flags, incdir, checklist, tmpdir=None): """Check a fortran source file.""" @@ -42,9 +54,12 @@ def check_fortran_source(fname, flags, incdir, checklist, tmpdir=None): lmsg.extend(check_file_content(fname, checklist.on_content())) lmsg.extend(check_fortran_code(fname, checklist.on_fortran_code())) lmsg.extend(check_filename(fname, checklist.on_filename())) - except: + except FortranParserError as exc: + checker = ParserMsg(None) + checker.check(lmsg, exc.msg) + except Exception as exc: logger.error(_("cannot check %r"), fname) - raise + raise RuntimeError(exc) check_disabled(fname, checklist, lmsg) report = Report() report.set(fname, lmsg) -- GitLab