@@ -1138,6 +1138,97 @@ def test_file_duplicate_2(tmpdir):
11381138 assert stderr == ''
11391139
11401140
1141+ def test_file_duplicate_3 (tmpdir ):
1142+ test_file_a = os .path .join (tmpdir , 'a.c' )
1143+ with open (test_file_a , 'wt' ):
1144+ pass
1145+
1146+ # multiple ways to specify the same file
1147+ in_file_a = 'a.c'
1148+ in_file_b = os .path .join ('.' , 'a.c' )
1149+ in_file_c = os .path .join ('dummy' , '..' , 'a.c' )
1150+ in_file_d = os .path .join (tmpdir , 'a.c' )
1151+ in_file_e = os .path .join (tmpdir , '.' , 'a.c' )
1152+ in_file_f = os .path .join (tmpdir , 'dummy' , '..' , 'a.c' )
1153+
1154+ args = [in_file_a , in_file_b , in_file_c , in_file_d , in_file_e , in_file_f , str (tmpdir )]
1155+ args .append ('-j1' ) # TODO: remove when fixed
1156+
1157+ exitcode , stdout , stderr = cppcheck (args , cwd = tmpdir )
1158+ assert exitcode == 0
1159+ lines = stdout .splitlines ()
1160+ # TODO: only a single file should be checked
1161+ if sys .platform == 'win32' :
1162+ assert lines == [
1163+ 'Checking {} ...' .format ('a.c' ),
1164+ '1/6 files checked 0% done' ,
1165+ 'Checking {} ...' .format ('a.c' ),
1166+ '2/6 files checked 0% done' ,
1167+ 'Checking {} ...' .format ('a.c' ),
1168+ '3/6 files checked 0% done' ,
1169+ 'Checking {} ...' .format (test_file_a ),
1170+ '4/6 files checked 0% done' ,
1171+ 'Checking {} ...' .format (test_file_a ),
1172+ '5/6 files checked 0% done' ,
1173+ 'Checking {} ...' .format (test_file_a ),
1174+ '6/6 files checked 0% done'
1175+ ]
1176+ else :
1177+ assert lines == [
1178+ 'Checking {} ...' .format ('a.c' ),
1179+ '1/4 files checked 0% done' ,
1180+ 'Checking {} ...' .format ('a.c' ),
1181+ '2/4 files checked 0% done' ,
1182+ 'Checking {} ...' .format (test_file_a ),
1183+ '3/4 files checked 0% done' ,
1184+ 'Checking {} ...' .format (test_file_a ),
1185+ '4/4 files checked 0% done'
1186+ ]
1187+ assert stderr == ''
1188+
1189+
1190+ @pytest .mark .skipif (sys .platform != 'win32' , reason = "requires Windows" )
1191+ def test_file_duplicate_4 (tmpdir ):
1192+ test_file_a = os .path .join (tmpdir , 'a.c' )
1193+ with open (test_file_a , 'wt' ):
1194+ pass
1195+
1196+ # multiple ways to specify the same file
1197+ in_file_a = 'a.c'
1198+ in_file_b = os .path .join ('.' , 'a.c' )
1199+ in_file_c = os .path .join ('dummy' , '..' , 'a.c' )
1200+ in_file_d = os .path .join (tmpdir , 'a.c' )
1201+ in_file_e = os .path .join (tmpdir , '.' , 'a.c' )
1202+ in_file_f = os .path .join (tmpdir , 'dummy' , '..' , 'a.c' )
1203+
1204+ args1 = [in_file_a , in_file_b , in_file_c , in_file_d , in_file_e , in_file_f , str (tmpdir )]
1205+ args2 = []
1206+ for a in args1 :
1207+ args2 .append (a .replace ('\\ ' , '/' ))
1208+ args = args1 + args2
1209+ args .append ('-j1' ) # TODO: remove when fixed
1210+
1211+ exitcode , stdout , stderr = cppcheck (args , cwd = tmpdir )
1212+ assert exitcode == 0
1213+ lines = stdout .splitlines ()
1214+ # TODO: only a single file should be checked
1215+ assert lines == [
1216+ 'Checking {} ...' .format ('a.c' ),
1217+ '1/6 files checked 0% done' ,
1218+ 'Checking {} ...' .format ('a.c' ),
1219+ '2/6 files checked 0% done' ,
1220+ 'Checking {} ...' .format ('a.c' ),
1221+ '3/6 files checked 0% done' ,
1222+ 'Checking {} ...' .format (test_file_a ),
1223+ '4/6 files checked 0% done' ,
1224+ 'Checking {} ...' .format (test_file_a ),
1225+ '5/6 files checked 0% done' ,
1226+ 'Checking {} ...' .format (test_file_a ),
1227+ '6/6 files checked 0% done'
1228+ ]
1229+ assert stderr == ''
1230+
1231+
11411232def test_file_ignore (tmpdir ):
11421233 test_file = os .path .join (tmpdir , 'test.cpp' )
11431234 with open (test_file , 'wt' ):
0 commit comments