From ec44f76aafa7871f77e6e84071cb1f0faeb96c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 29 Sep 2023 13:49:01 +0200 Subject: [PATCH] test --- test/cli/test-proj2.py | 10 ++++++++++ test/cli/testutils.py | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/test/cli/test-proj2.py b/test/cli/test-proj2.py index 868d832ddf0..e152a819723 100644 --- a/test/cli/test-proj2.py +++ b/test/cli/test-proj2.py @@ -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') diff --git a/test/cli/testutils.py b/test/cli/testutils.py index 1e53c65db48..d58212c0607 100644 --- a/test/cli/testutils.py +++ b/test/cli/testutils.py @@ -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' @@ -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