Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Sep 29, 2023
1 parent a665d5b commit ec44f76
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions test/cli/test-proj2.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,13 @@ def test_gui_project_loads_absolute_vs_solution_2():
ret, stdout, stderr = cppcheck(['--project=test.cppcheck'])
assert ret == 0, stdout
assert stderr == ERR_A + ERR_B

def test_vs_project_missing_file():
with open('proj2/proj2.vcxproj', 'rt') as fin:
s = fin.read()
with open('proj2/test.vcxproj', 'wt') as fout:
fout.write(s.replace('a.c', 'a_missing.c'))
ret, stdout, stderr = cppcheck(['--project=proj2/test.vcxproj', '--file-filter=*/a*'], status_report=True)
assert 'proj2/a/a_missing.c:0:0: error: File not found [fileNotFound]' in stderr
assert 'There was critical errors' in stdout
os.remove('proj2/test.vcxproj')
4 changes: 2 additions & 2 deletions test/cli/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def lookup_cppcheck_exe():


# Run Cppcheck with args
def cppcheck(args, env=None):
def cppcheck(args, env=None, status_report=False):
exe = lookup_cppcheck_exe()
assert exe is not None, 'no cppcheck binary found'

Expand All @@ -72,6 +72,6 @@ def cppcheck(args, env=None):
comm = p.communicate()
stdout = comm[0].decode(encoding='utf-8', errors='ignore').replace('\r\n', '\n')
stderr = comm[1].decode(encoding='utf-8', errors='ignore').replace('\r\n', '\n')
if stdout.find('\nActive checkers:') > 0:
if (not status_report) and stdout.find('\nActive checkers:') > 0:
stdout = stdout[:1 + stdout.find('\nActive checkers:')]
return p.returncode, stdout, stderr

0 comments on commit ec44f76

Please sign in to comment.