test/cli: Add test for cppcheck gui project with addons
This commit is contained in:
parent
2156dd7a40
commit
9a563a7d60
|
@ -81,6 +81,16 @@ def test_addon_relative_path():
|
|||
assert stderr == ('[%s:5]: (error) Division by zero.\n'
|
||||
'[%s:1]: (style) misra violation (use --rule-texts=<file> to get proper output)\n' % (filename, filename))
|
||||
|
||||
def test_addon_relative_path():
|
||||
project_file = '1-helloworld/test.cppcheck'
|
||||
create_gui_project_file(project_file, paths=['.'], addon='misra')
|
||||
ret, stdout, stderr = cppcheck('--project=%s' % (project_file))
|
||||
filename = os.path.join('1-helloworld', 'main.c')
|
||||
assert ret == 0
|
||||
assert stdout == 'Checking %s ...\n' % (filename)
|
||||
assert stderr == ('[%s:5]: (error) Division by zero.\n'
|
||||
'[%s:1]: (style) misra violation (use --rule-texts=<file> to get proper output)\n' % (filename, filename))
|
||||
|
||||
def test_basepath_relative_path():
|
||||
prjpath = getRelativeProjectPath()
|
||||
ret, stdout, stderr = cppcheck('%s -rp=%s' % (prjpath, prjpath))
|
||||
|
|
|
@ -4,7 +4,7 @@ import os
|
|||
import subprocess
|
||||
|
||||
# Create Cppcheck project file
|
||||
def create_gui_project_file(project_file, root_path=None, import_project=None, paths=None, exclude_paths=None, suppressions=None):
|
||||
def create_gui_project_file(project_file, root_path=None, import_project=None, paths=None, exclude_paths=None, suppressions=None, addon=None):
|
||||
cppcheck_xml = ('<?xml version="1.0" encoding="UTF-8"?>\n'
|
||||
'<project version="1">\n')
|
||||
if root_path:
|
||||
|
@ -29,6 +29,10 @@ def create_gui_project_file(project_file, root_path=None, import_project=None, p
|
|||
cppcheck_xml += ' fileName="' + suppression['fileName'] + '"'
|
||||
cppcheck_xml += '>' + suppression['id'] + '</suppression>\n'
|
||||
cppcheck_xml += ' </suppressions>\n'
|
||||
if addon:
|
||||
cppcheck_xml += ' <addons>\n'
|
||||
cppcheck_xml += ' <addon>%s</addon>\n' % (addon)
|
||||
cppcheck_xml += ' </addons>\n'
|
||||
cppcheck_xml += '</project>\n'
|
||||
|
||||
f = open(project_file, 'wt')
|
||||
|
|
Loading…
Reference in New Issue