From 306096bded87aef600a9ade66962310433bbba5b Mon Sep 17 00:00:00 2001 From: Mathieu Courtois <mathieu.courtois@edf.fr> Date: Tue, 8 Jan 2019 11:28:08 +0100 Subject: [PATCH] [#28360] Remove installation directory to check the code_aster messages. --HG-- branch : edf/mc --- lib/aslint/check_global.py | 23 ++++------------------- share/test/aslint/test_check_files.py | 6 ++++++ 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/lib/aslint/check_global.py b/lib/aslint/check_global.py index 23293015..ff633476 100644 --- a/lib/aslint/check_global.py +++ b/lib/aslint/check_global.py @@ -31,24 +31,8 @@ class ErrorMessages(DirnameCat, GenericMsg): # only in 'src' if not osp.isdir(osp.join(srcdir, 'bibpyt', 'Messages')): return result - found = False - subdirs = ['build', 'build/std', 'build/mpi'] - if ASCFG.get('waf.builddir') not in subdirs: - subdirs.insert(0, ASCFG.get('waf.builddir')) - for bld in ('release', 'debug'): - for sub in subdirs: - instdir = osp.join(srcdir, sub, bld) - fconf = osp.join(instdir, 'data', 'config.txt') - if osp.isfile(osp.join(instdir, 'config.txt')) or \ - osp.isfile(fconf): - found = True - break - if not found: - return [": can not check messages, 'config.txt' not found in " - "debug/release of this directories {0}" - .format(tuple(subdirs))] try: - unused, not_found = check_messages(instdir, srcdir) + unused, not_found = check_messages(srcdir) result.extend([': %s (unused)' % msg for msg in unused]) result.extend([': %s (missing)' % msg for msg in not_found]) except ValueError, exc: @@ -87,14 +71,15 @@ class Supv002aRequirement(DirnameCat, GenericMsg): CHECK_LIST = checkers_from_context(globals(), TextMsg) -def check_messages(instdir, srcdir): +def check_messages(srcdir): """Check the errors messages""" from aslint.messages import MessagesManager, CataMessageError tmpcache = tempfile.NamedTemporaryFile(prefix='cachedict.').name catapy = osp.abspath(osp.join(srcdir, 'code_aster')) if not osp.exists(catapy): catapy = osp.abspath(osp.join(srcdir, 'catapy')) - msgman = MessagesManager(repref=instdir, + # repref is not necessary because fort, pyt and capy are absolute paths + msgman = MessagesManager(repref="__unused__", fort=osp.abspath(osp.join(srcdir, 'bibfor')), pyt=osp.abspath(osp.join(srcdir, 'bibpyt')), capy=catapy, diff --git a/share/test/aslint/test_check_files.py b/share/test/aslint/test_check_files.py index e53c4269..17359c70 100644 --- a/share/test/aslint/test_check_files.py +++ b/share/test/aslint/test_check_files.py @@ -108,6 +108,12 @@ def test_check_files(): assert_that(parser_error, has_length(1)) +def test_check_messages(): + # useful to increase coverage without an installation directory + from aslint.check_global import check_messages + check_messages(CODEASTER_SRC) + + if __name__ == "__main__": import sys from testutils import get_test_suite -- GitLab