99
1010from testutils import create_gui_project_file , cppcheck
1111
12- # Run Cppcheck from project path
13- def cppcheck_local (args ):
14- cwd = os .getcwd ()
15- os .chdir ('helloworld' )
16- ret , stdout , stderr = cppcheck (args )
17- os .chdir (cwd )
18- return ret , stdout , stderr
1912
2013def getRelativeProjectPath ():
2114 return 'helloworld'
@@ -46,7 +39,7 @@ def test_relative_path():
4639
4740
4841def test_local_path ():
49- ret , stdout , stderr = cppcheck_local (['--template=cppcheck1' , '.' ])
42+ ret , stdout , stderr = cppcheck (['--template=cppcheck1' , '.' ], cwd = 'helloworld' )
5043 assert ret == 0 , stdout
5144 assert stderr == '[main.c:5]: (error) Division by zero.\n '
5245
@@ -58,13 +51,13 @@ def test_absolute_path():
5851 assert stderr == '[%s:5]: (error) Division by zero.\n ' % filename
5952
6053def test_addon_local_path ():
61- ret , stdout , stderr = cppcheck_local (['--addon=misra' , '--enable=style' , '--template=cppcheck1' , '.' ])
54+ ret , stdout , stderr = cppcheck (['--addon=misra' , '--enable=style' , '--template=cppcheck1' , '.' ], cwd = 'helloworld' )
6255 assert ret == 0 , stdout
6356 assert stderr == ('[main.c:5]: (error) Division by zero.\n '
6457 '[main.c:1]: (style) misra violation (use --rule-texts=<file> to get proper output)\n ' )
6558
6659def test_addon_local_path_not_enable ():
67- ret , stdout , stderr = cppcheck_local (['--addon=misra' , '--template=cppcheck1' , '.' ])
60+ ret , stdout , stderr = cppcheck (['--addon=misra' , '--template=cppcheck1' , '.' ], cwd = 'helloworld' )
6861 assert ret == 0 , stdout
6962 assert stderr == '[main.c:5]: (error) Division by zero.\n '
7063
@@ -109,7 +102,7 @@ def test_basepath_absolute_path():
109102 assert stderr == '[main.c:5]: (error) Division by zero.\n '
110103
111104def test_vs_project_local_path ():
112- ret , stdout , stderr = cppcheck_local (['--template=cppcheck1' , '--project=helloworld.vcxproj' ])
105+ ret , stdout , stderr = cppcheck (['--template=cppcheck1' , '--project=helloworld.vcxproj' ], cwd = 'helloworld' )
113106 assert ret == 0 , stdout
114107 assert getVsConfigs (stdout , 'main.c' ) == 'Debug|Win32 Debug|x64 Release|Win32 Release|x64'
115108 assert stderr == '[main.c:5]: (error) Division by zero.\n '
@@ -131,7 +124,7 @@ def test_vs_project_absolute_path():
131124 assert stderr == '[%s:5]: (error) Division by zero.\n ' % filename
132125
133126def test_cppcheck_project_local_path ():
134- ret , stdout , stderr = cppcheck_local (['--template=cppcheck1' , '--platform=win64' , '--project=helloworld.cppcheck' ])
127+ ret , stdout , stderr = cppcheck (['--template=cppcheck1' , '--platform=win64' , '--project=helloworld.cppcheck' ], cwd = 'helloworld' )
135128 assert ret == 0 , stdout
136129 assert getVsConfigs (stdout , 'main.c' ) == 'Debug|x64'
137130 assert stderr == '[main.c:5]: (error) Division by zero.\n '
0 commit comments