Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def parse_version(cppcheck_output):
"""
Parse cppcheck version output and return the version number.
"""
version_re = re.compile(r'^Cppcheck (?P<version>[\d\.]+)')
version_re = re.compile(r'^Cppcheck(.*?)(?P<version>[\d\.]+)')
match = version_re.match(cppcheck_output)
if match:
return match.group('version')
Expand Down
25 changes: 25 additions & 0 deletions analyzer/tests/unit/test_cppcheck_version_parsing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -------------------------------------------------------------------------
#
# Part of the CodeChecker project, under the Apache License v2.0 with
# LLVM Exceptions. See LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# -------------------------------------------------------------------------

""" Test Cppcheck version parsing. """


import unittest

from codechecker_analyzer.analyzers.cppcheck.analyzer import parse_version


class CppcheckVersionTest(unittest.TestCase):
"""
Test the parsing of various possible version strings, which cppcheck
binaries can produce.
"""

def test_cppcheck_version(self):
self.assertEqual(parse_version('Cppcheck 1.2.3'), '1.2.3')
self.assertEqual(parse_version('Cppcheck Premium 1.2.3'), '1.2.3')