test/cli: Improved proj2 testing. fixed bug for relative path when vs-solution is imported with relative path
This commit is contained in:
parent
6549aed6f4
commit
83f8d7fab9
|
@ -1007,9 +1007,10 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti
|
|||
guiProject.analyzeAllVsConfigs.clear();
|
||||
|
||||
for (const tinyxml2::XMLElement *node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) {
|
||||
if (strcmp(node->Name(), RootPathName) == 0 && node->Attribute(RootPathNameAttrib))
|
||||
if (strcmp(node->Name(), RootPathName) == 0 && node->Attribute(RootPathNameAttrib)) {
|
||||
temp.basePaths.push_back(joinRelativePath(path, node->Attribute(RootPathNameAttrib)));
|
||||
else if (strcmp(node->Name(), BuildDirElementName) == 0)
|
||||
temp.relativePaths = true;
|
||||
} else if (strcmp(node->Name(), BuildDirElementName) == 0)
|
||||
temp.buildDir = joinRelativePath(path, node->GetText() ? node->GetText() : "");
|
||||
else if (strcmp(node->Name(), IncludeDirElementName) == 0)
|
||||
temp.includePaths = readXmlStringList(node, path, DirElementName, DirNameAttrib);
|
||||
|
@ -1050,6 +1051,7 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti
|
|||
return false;
|
||||
}
|
||||
settings->basePaths = temp.basePaths;
|
||||
settings->relativePaths |= temp.relativePaths;
|
||||
settings->buildDir = temp.buildDir;
|
||||
settings->includePaths = temp.includePaths;
|
||||
settings->userDefines = temp.userDefines;
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
x = 3 / 0;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
x = 3 / 0;
|
||||
|
|
@ -163,6 +163,7 @@ def test_suppress_project():
|
|||
assert ret == 0
|
||||
assert stderr == ''
|
||||
|
||||
# Absolute path
|
||||
ret, stdout, stderr = cppcheck('--project=%s' % (os.path.join(os.getcwd(), '1-helloworld', 'test.cppcheck')))
|
||||
assert ret == 0
|
||||
assert stderr == ''
|
||||
|
|
|
@ -77,17 +77,41 @@ def test_gui_project_loads_compile_commands_2():
|
|||
assert stdout.find('Checking %s ...' % (file1)) >= 0
|
||||
assert stdout.find('Checking %s ...' % (file2)) < 0
|
||||
|
||||
def test_gui_project_loads_compile_commands_2():
|
||||
create_compile_commands()
|
||||
exclude_path_1 = os.path.join(os.getcwd(), 'proj2', 'b').replace('\\', '/')
|
||||
create_gui_project_file('proj2/test.cppcheck',
|
||||
import_project='compile_commands.json',
|
||||
exclude_paths=[exclude_path_1])
|
||||
ret, stdout, stderr = cppcheck('--project=proj2/test.cppcheck')
|
||||
cwd = os.getcwd()
|
||||
file1 = os.path.join(cwd, 'proj2', 'a', 'a.c')
|
||||
file2 = os.path.join(cwd, 'proj2', 'b', 'b.c') # Excluded by test.cppcheck
|
||||
assert ret == 0
|
||||
assert stdout.find('Checking %s ...' % (file1)) >= 0
|
||||
assert stdout.find('Checking %s ...' % (file2)) < 0
|
||||
|
||||
def test_gui_project_loads_relative_vs_solution():
|
||||
create_gui_project_file('test.cppcheck', import_project='proj2/proj2.sln')
|
||||
ret, stdout, stderr = cppcheck('--project=test.cppcheck')
|
||||
file1 = os.path.join('proj2', 'a', 'a.c')
|
||||
file2 = os.path.join('proj2', 'b', 'b.c')
|
||||
assert ret == 0
|
||||
assert stdout.find('Checking %s Debug|Win32...' % (file1)) >= 0
|
||||
assert stdout.find('Checking %s Debug|x64...' % (file1)) >= 0
|
||||
assert stdout.find('Checking %s Release|Win32...' % (file1)) >= 0
|
||||
assert stdout.find('Checking %s Release|x64...' % (file1)) >= 0
|
||||
assert stdout.find('Checking %s Debug|Win32...' % (file2)) >= 0
|
||||
assert stdout.find('Checking %s Debug|x64...' % (file2)) >= 0
|
||||
assert stdout.find('Checking %s Release|Win32...' % (file2)) >= 0
|
||||
assert stdout.find('Checking %s Release|x64...' % (file2)) >= 0
|
||||
|
||||
def test_gui_project_loads_absolute_vs_solution():
|
||||
create_gui_project_file('test.cppcheck', import_project=os.path.join(os.getcwd(),'proj2', 'proj2.sln').replace('\\', '/'))
|
||||
ret, stdout, stderr = cppcheck('--project=test.cppcheck')
|
||||
file1 = os.path.join(os.getcwd(), 'proj2', 'a', 'a.c')
|
||||
file2 = os.path.join(os.getcwd(), 'proj2', 'b', 'b.c')
|
||||
print(stdout)
|
||||
assert ret == 0
|
||||
assert stdout.find('Checking %s Debug|Win32...' % (file1)) >= 0
|
||||
assert stdout.find('Checking %s Debug|x64...' % (file1)) >= 0
|
||||
assert stdout.find('Checking %s Release|Win32...' % (file1)) >= 0
|
||||
assert stdout.find('Checking %s Release|x64...' % (file1)) >= 0
|
||||
assert stdout.find('Checking %s Debug|Win32...' % (file2)) >= 0
|
||||
assert stdout.find('Checking %s Debug|x64...' % (file2)) >= 0
|
||||
assert stdout.find('Checking %s Release|Win32...' % (file2)) >= 0
|
||||
assert stdout.find('Checking %s Release|x64...' % (file2)) >= 0
|
||||
|
||||
def test_gui_project_loads_relative_vs_solution():
|
||||
create_gui_project_file('test.cppcheck', root_path='proj2', import_project='proj2/proj2.sln')
|
||||
ret, stdout, stderr = cppcheck('--project=test.cppcheck')
|
||||
assert stderr == ('[a/a.c:1]: (error) Division by zero.\n'
|
||||
'[b/b.c:1]: (error) Division by zero.\n')
|
||||
|
||||
|
|
Loading…
Reference in New Issue