@@ -432,3 +432,75 @@ def test_project_file_order(tmpdir):
432432 '4/4 files checked 0% done'
433433 ]
434434 assert stderr == ''
435+
436+
437+ def test_project_file_duplicate (tmpdir ):
438+ test_file_a = os .path .join (tmpdir , 'a.c' )
439+ with open (test_file_a , 'wt' ):
440+ pass
441+
442+ project_file = os .path .join (tmpdir , 'test.cppcheck' )
443+ with open (project_file , 'wt' ) as f :
444+ f .write (
445+ """<?xml version="1.0" encoding="UTF-8"?>
446+ <project>
447+ <paths>
448+ <dir name="{}"/>
449+ <dir name="{}"/>
450+ <dir name="{}"/>
451+ </paths>
452+ </project>""" .format (test_file_a , test_file_a , tmpdir ))
453+
454+ args = ['--project={}' .format (project_file )]
455+
456+ exitcode , stdout , stderr = cppcheck (args )
457+ assert exitcode == 0
458+ lines = stdout .splitlines ()
459+ assert lines == [
460+ 'Checking {} ...' .format (test_file_a )
461+ ]
462+ assert stderr == ''
463+
464+
465+ def test_project_file_duplicate_2 (tmpdir ):
466+ test_file_a = os .path .join (tmpdir , 'a.c' )
467+ with open (test_file_a , 'wt' ):
468+ pass
469+ test_file_b = os .path .join (tmpdir , 'b.c' )
470+ with open (test_file_b , 'wt' ):
471+ pass
472+ test_file_c = os .path .join (tmpdir , 'c.c' )
473+ with open (test_file_c , 'wt' ):
474+ pass
475+
476+ project_file = os .path .join (tmpdir , 'test.cppcheck' )
477+ with open (project_file , 'wt' ) as f :
478+ f .write (
479+ """<?xml version="1.0" encoding="UTF-8"?>
480+ <project>
481+ <paths>
482+ <dir name="{}"/>
483+ <dir name="{}"/>
484+ <dir name="{}"/>
485+ <dir name="{}"/>
486+ <dir name="{}"/>
487+ <dir name="{}"/>
488+ <dir name="{}"/>
489+ <dir name="{}"/>
490+ </paths>
491+ </project>""" .format (test_file_c , test_file_a , test_file_b , tmpdir , test_file_b , test_file_c , test_file_a , tmpdir ))
492+
493+ args = ['--project={}' .format (project_file )]
494+
495+ exitcode , stdout , stderr = cppcheck (args )
496+ assert exitcode == 0
497+ lines = stdout .splitlines ()
498+ assert lines == [
499+ 'Checking {} ...' .format (test_file_c ),
500+ '1/3 files checked 0% done' ,
501+ 'Checking {} ...' .format (test_file_a ),
502+ '2/3 files checked 0% done' ,
503+ 'Checking {} ...' .format (test_file_b ),
504+ '3/3 files checked 0% done'
505+ ]
506+ assert stderr == ''
0 commit comments