test/cli: better handling of absolute ignored paths
This commit is contained in:
parent
0c3a6b44f8
commit
15eba39963
|
@ -37,7 +37,8 @@ void ImportProject::ignorePaths(const std::vector<std::string> &ipaths)
|
|||
for (std::list<FileSettings>::iterator it = fileSettings.begin(); it != fileSettings.end();) {
|
||||
bool ignore = false;
|
||||
for (std::string i : ipaths) {
|
||||
i = mPath + i;
|
||||
if (!Path::isAbsolute(i))
|
||||
i = mPath + i;
|
||||
if (it->filename.size() > i.size() && it->filename.compare(0,i.size(),i)==0) {
|
||||
ignore = true;
|
||||
break;
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="1">
|
||||
<root name="."/>
|
||||
<importproject>compile_commands.json</importproject>
|
||||
<exclude>
|
||||
<path name="b"/>
|
||||
</exclude>
|
||||
</project>
|
||||
|
|
@ -75,11 +75,25 @@ def test_project_1():
|
|||
|
||||
def test_project_2():
|
||||
create_compile_commands(os.path.join(os.getcwd(), 'proj2'))
|
||||
ret, stdout, stderr = cppcheck('--project=proj2/proj2-exclude.cppcheck')
|
||||
|
||||
# create cppcheck gui project file
|
||||
cppcheck_xml = ('<?xml version="1.0" encoding="UTF-8"?>'
|
||||
'<project version="1">'
|
||||
' <root name="."/>'
|
||||
' <importproject>compile_commands.json</importproject>'
|
||||
' <exclude>'
|
||||
' <path name="' + os.path.join(os.getcwd(), 'proj2', 'b') + '"/>'
|
||||
' </exclude>'
|
||||
'</project>')
|
||||
f = open('proj2/test.cppcheck', 'wt')
|
||||
f.write(cppcheck_xml)
|
||||
f.close()
|
||||
|
||||
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 proj2-exclude.cppcheck
|
||||
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
|
||||
assert stdout.find('Checking %s ...' % (file2)) < 0
|
||||
|
||||
|
|
Loading…
Reference in New Issue