@@ -1357,4 +1357,74 @@ def test_rule(tmpdir):
13571357 lines = stderr .splitlines ()
13581358 assert lines == [
13591359 "{}:4:0: style: found 'f' [rule]" .format (test_file )
1360- ]
1360+ ]
1361+
1362+
1363+ def test_filelist (tmpdir ):
1364+ list_dir = os .path .join (tmpdir , 'list-dir' )
1365+ os .mkdir (list_dir )
1366+
1367+ with open (os .path .join (list_dir , 'aaa.c' ), 'wt' ):
1368+ pass
1369+ with open (os .path .join (list_dir , 'zzz.c' ), 'wt' ):
1370+ pass
1371+ with open (os .path .join (list_dir , 'valueflow.cpp' ), 'wt' ):
1372+ pass
1373+ with open (os .path .join (list_dir , 'vfvalue.cpp' ), 'wt' ):
1374+ pass
1375+ with open (os .path .join (list_dir , 'vf_enumvalue.cpp' ), 'wt' ):
1376+ pass
1377+ with open (os .path .join (list_dir , 'vf_analyze.h' ), 'wt' ):
1378+ pass
1379+
1380+ sub_dir_1 = os .path .join (list_dir , 'valueflow' )
1381+ os .mkdir (sub_dir_1 )
1382+ with open (os .path .join (sub_dir_1 , 'file.cpp' ), 'wt' ):
1383+ pass
1384+ with open (os .path .join (sub_dir_1 , 'file.c' ), 'wt' ):
1385+ pass
1386+ with open (os .path .join (sub_dir_1 , 'file.h' ), 'wt' ):
1387+ pass
1388+
1389+ sub_dir_2 = os .path .join (list_dir , 'vfvalue' )
1390+ os .mkdir (sub_dir_2 )
1391+ with open (os .path .join (sub_dir_2 , 'file.cpp' ), 'wt' ):
1392+ pass
1393+ with open (os .path .join (sub_dir_2 , 'file.c' ), 'wt' ):
1394+ pass
1395+ with open (os .path .join (sub_dir_2 , 'file.h' ), 'wt' ):
1396+ pass
1397+
1398+ sub_dir_3 = os .path .join (list_dir , 'vf_enumvalue' )
1399+ os .mkdir (sub_dir_3 )
1400+ with open (os .path .join (sub_dir_3 , 'file.cpp' ), 'wt' ):
1401+ pass
1402+ with open (os .path .join (sub_dir_3 , 'file.c' ), 'wt' ):
1403+ pass
1404+ with open (os .path .join (sub_dir_3 , 'file.h' ), 'wt' ):
1405+ pass
1406+
1407+ # TODO: -rp is not applied to "Checking" messages
1408+ #exitcode, stdout, _ = cppcheck(['-j1', '-rp', list_dir])
1409+ exitcode , stdout , _ = cppcheck (['-j1' , '.' ], cwd = list_dir )
1410+ assert exitcode == 0 , stdout
1411+ if sys .platform == "win32" :
1412+ stdout = stdout .replace ('\\ ' , '/' )
1413+ lines = stdout .splitlines ()
1414+ expected = [
1415+ 'Checking aaa.c ...' ,
1416+ 'Checking valueflow.cpp ...' ,
1417+ 'Checking valueflow/file.c ...' ,
1418+ 'Checking valueflow/file.cpp ...' ,
1419+ 'Checking vf_enumvalue.cpp ...' ,
1420+ 'Checking vf_enumvalue/file.c ...' ,
1421+ 'Checking vf_enumvalue/file.cpp ...' ,
1422+ 'Checking vfvalue.cpp ...' ,
1423+ 'Checking vfvalue/file.c ...' ,
1424+ 'Checking vfvalue/file.cpp ...' ,
1425+ 'Checking zzz.c ...'
1426+ ]
1427+ assert len (expected ), len (lines )
1428+ for i in range (1 , len (expected )+ 1 ):
1429+ lines .remove ('{}/11 files checked 0% done' .format (i , len (expected )))
1430+ assert lines == expected
0 commit comments