@@ -372,6 +372,66 @@ def test_project_file_filter_3(tmpdir):
372372 assert_cppcheck (args , ec_exp = 0 , err_exp = [], out_exp = out_lines )
373373
374374
375+ def test_project_relpath_file_filter_abspath (tmpdir ):
376+ """
377+ relative paths in project file, absolute path in file filter
378+ """
379+ test_file_cpp = os .path .join (tmpdir , 'test.cpp' )
380+ with open (test_file_cpp , 'wt' ) as f :
381+ pass
382+ test_file_c = os .path .join (tmpdir , 'test.c' )
383+ with open (test_file_c , 'wt' ) as f :
384+ pass
385+
386+ project_file = os .path .join (tmpdir , 'test.cppcheck' )
387+ with open (project_file , 'wt' ) as f :
388+ f .write (
389+ """<?xml version="1.0" encoding="UTF-8"?>
390+ <project>
391+ <paths>
392+ <dir name="test.cpp"/>
393+ <dir name="test.c"/>
394+ </paths>
395+ </project>""" )
396+
397+ out_lines = [
398+ 'Checking test.c ...'
399+ ]
400+
401+ args = ['--file-filter={}' .format (test_file_c ), '--project=test.cppcheck' ]
402+ assert_cppcheck (args , ec_exp = 0 , err_exp = [], out_exp = out_lines , cwd = tmpdir )
403+
404+
405+ def test_project_abspath_file_filter_relpath (tmpdir ):
406+ """
407+ absolute paths in project file, relative path in file filter
408+ """
409+ test_file_cpp = os .path .join (tmpdir , 'test.cpp' )
410+ with open (test_file_cpp , 'wt' ) as f :
411+ pass
412+ test_file_c = os .path .join (tmpdir , 'test.c' )
413+ with open (test_file_c , 'wt' ) as f :
414+ pass
415+
416+ project_file = os .path .join (tmpdir , 'test.cppcheck' )
417+ with open (project_file , 'wt' ) as f :
418+ f .write (
419+ """<?xml version="1.0" encoding="UTF-8"?>
420+ <project>
421+ <paths>
422+ <dir name="{}"/>
423+ <dir name="{}"/>
424+ </paths>
425+ </project>""" .format (test_file_c , test_file_cpp ))
426+
427+ out_lines = [
428+ 'Checking {} ...' .format (test_file_c )
429+ ]
430+
431+ args = ['--file-filter=test.c' , '--project=test.cppcheck' ]
432+ assert_cppcheck (args , ec_exp = 0 , err_exp = [], out_exp = out_lines , cwd = tmpdir )
433+
434+
375435def test_project_file_filter_no_match (tmpdir ):
376436 test_file = os .path .join (tmpdir , 'test.cpp' )
377437 with open (test_file , 'wt' ) as f :
0 commit comments