Last active
February 11, 2022 16:33
-
-
Save firewave/beaf1c53a9cd5de01cf4ab3c1e526547 to your computer and use it in GitHub Desktop.
Cppcheck version compare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os.path | |
import subprocess | |
from distutils.version import StrictVersion | |
input_file = 's:/___temp/input.cpp' | |
directory = 'c:/Apps/cppcheck_versions' | |
versions = [] | |
for filename in os.listdir(directory): | |
f = os.path.join(directory, filename) | |
if not os.path.isdir(f): | |
continue | |
versions.append(filename) | |
versions.sort(key=StrictVersion) | |
for version in versions: | |
exe = os.path.join(directory, version, 'cppcheck') | |
cmd = exe | |
cmd += ' --enable=all ' | |
if StrictVersion(version) >= StrictVersion('1.48'): | |
cmd += '--suppress=missingInclude --suppress=unusedFunction --suppress=unmatchedSuppression ' | |
if StrictVersion(version) >= StrictVersion('1.49'): | |
cmd += '--inconclusive ' | |
cmd += input_file | |
p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=None, universal_newlines=True) | |
try: | |
comm = p.communicate(timeout=2) | |
except subprocess.TimeoutExpired: | |
print('timeout') | |
p.kill() | |
comm = p.communicate() | |
print(version) | |
print(p.returncode) | |
print(comm[0] + '\n' + comm[1]) |
Sorry, I don't get it. What is this?
@chrchr-github
I threw this together to run code against multiple versions of Cppcheck.
directory
contains versioned folders with the respective Cppcheck release.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@chrchr-github FYI