donate-cpu: small `LibraryIncludes` regular expression improvements / fixed/improved tests (#4473)
* test_donate_cpu_lib.py: added more tests * test_donate_cpu_lib.py: fixed non-working assert * donate_cpu_lib.py: use `\t` in `LibraryIncludes` regular expressions instead of an actual TAB character * donate_cpu_lib.py: bumped version * donate_cpu_lib.py: use non-capturing group in `LibraryIncludes` regular expressions
This commit is contained in:
parent
897826006e
commit
21db0b98a6
|
@ -15,7 +15,7 @@ import shlex
|
||||||
# Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/
|
# Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/
|
||||||
# Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic
|
# Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic
|
||||||
# changes)
|
# changes)
|
||||||
CLIENT_VERSION = "1.3.35"
|
CLIENT_VERSION = "1.3.36"
|
||||||
|
|
||||||
# Timeout for analysis with Cppcheck in seconds
|
# Timeout for analysis with Cppcheck in seconds
|
||||||
CPPCHECK_TIMEOUT = 30 * 60
|
CPPCHECK_TIMEOUT = 30 * 60
|
||||||
|
@ -672,7 +672,7 @@ class LibraryIncludes:
|
||||||
|
|
||||||
for library, includes in include_mappings.items():
|
for library, includes in include_mappings.items():
|
||||||
re_includes = [re.escape(inc) for inc in includes]
|
re_includes = [re.escape(inc) for inc in includes]
|
||||||
re_expr = '^[ \t]*#[ \t]*include[ \t]*(' + '|'.join(re_includes) + ')'
|
re_expr = '^[ \\t]*#[ \\t]*include[ \\t]*(?:' + '|'.join(re_includes) + ')'
|
||||||
re_obj = re.compile(re_expr, re.MULTILINE)
|
re_obj = re.compile(re_expr, re.MULTILINE)
|
||||||
self.__library_includes_re[library] = re_obj
|
self.__library_includes_re[library] = re_obj
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,31 @@ def _test_library_includes(tmpdir, libs, content):
|
||||||
src_file = os.path.join(str(tmpdir), "file.cpp")
|
src_file = os.path.join(str(tmpdir), "file.cpp")
|
||||||
with open(src_file, 'w') as f:
|
with open(src_file, 'w') as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
assert libs.sort() == library_includes.get_libraries(str(tmpdir)).sort()
|
libs.sort()
|
||||||
|
libs_found = library_includes.get_libraries(str(tmpdir))
|
||||||
|
libs_found.sort()
|
||||||
|
assert libs == libs_found
|
||||||
|
|
||||||
def test_library_includes(tmpdir):
|
def test_library_includes(tmpdir):
|
||||||
_test_library_includes(tmpdir, ['posix', 'gnu'], '')
|
_test_library_includes(tmpdir, ['posix', 'gnu'], '')
|
||||||
_test_library_includes(tmpdir, ['posix', 'gnu'], '#include <stdio.h>')
|
_test_library_includes(tmpdir, ['posix', 'gnu'], '#include <stdio.h>')
|
||||||
_test_library_includes(tmpdir, ['posix', 'gnu', 'boost'], '#include <boost/regex.hpp>')
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'boost'], '#include <boost/regex.hpp>')
|
||||||
_test_library_includes(tmpdir, ['posix', 'gnu', 'python'], '#include "Python.h"')
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'python'], '#include "Python.h"')
|
||||||
_test_library_includes(tmpdir, ['posix', 'gnu', 'lua', 'opengl', 'qt'], '#include <QApplication>\n#include <GL/gl.h>\n#include "lua.h"')
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'libcerror', 'lua', 'opengl', 'qt'], '#include <QApplication>\n#include <GL/gl.h>\r#include "lua.h"\r\n#include <libcerror.h>')
|
||||||
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'microsoft_sal'], ' #include <sal.h>')
|
||||||
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'googletest'], '\t#include <gtest/gtest.h>')
|
||||||
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'microsoft_atl'], ' \t #include <atlbase.h>')
|
||||||
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'cairo'], '\t #include <cairo.h>')
|
||||||
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'gtk'], ' \t#include <glib-object.h>')
|
||||||
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'bsd'], '#include <sys/uio.h>\r\n')
|
||||||
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'libcurl'], '#include <curl/curl.h>\r')
|
||||||
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'sqlite3'], '#include <sqlite3.h>\n')
|
||||||
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'openmp'], '# include <omp.h>')
|
||||||
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'mfc'], '#\tinclude <afxwin.h>')
|
||||||
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'ruby'], '# \tinclude "ruby.h"')
|
||||||
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'zlib'], '#\t include <zlib.h>')
|
||||||
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'pcre'], '#include<pcre.h>')
|
||||||
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'pcre'], '#include "pcre.h"')
|
||||||
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'opengl'], '#include\t <GL/glut.h>')
|
||||||
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'nspr'], '#include\t"prtypes.h"')
|
||||||
|
_test_library_includes(tmpdir, ['posix', 'gnu', 'lua'], '#include \t<lua.h>')
|
||||||
|
|
Loading…
Reference in New Issue