55import pytest
66from testutils import cppcheck
77
8- PROJECT_DIR = 'QML-Samples-TableView'
8+ __script_dir = os .path .dirname (os .path .abspath (__file__ ))
9+
10+ PROJECT_DIR = os .path .join (__script_dir , 'QML-Samples-TableView' )
911
1012
1113def test_unused_functions ():
12- ret , stdout , stderr = cppcheck (['--template=simple' , '--library=qt' , '--enable=unusedFunction' , PROJECT_DIR ])
14+ ret , stdout , stderr = cppcheck (['-q' , '- -template=simple' , '--library=qt' , '--enable=unusedFunction' , PROJECT_DIR ])
1315 # there are unused functions. But fillSampleData is not unused because that is referenced from main.qml
1416 assert stderr .splitlines () == [
15- "QML-Samples-TableView /samplemodel.cpp:9:0: style: The function 'rowCount' is never used. [unusedFunction]" ,
16- "QML-Samples-TableView /samplemodel.cpp:15:0: style: The function 'data' is never used. [unusedFunction]" ,
17- "QML-Samples-TableView /samplemodel.cpp:38:0: style: The function 'roleNames' is never used. [unusedFunction]"
17+ "{} /samplemodel.cpp:9:0: style: The function 'rowCount' is never used. [unusedFunction]" . format ( PROJECT_DIR ) ,
18+ "{} /samplemodel.cpp:15:0: style: The function 'data' is never used. [unusedFunction]" . format ( PROJECT_DIR ) ,
19+ "{} /samplemodel.cpp:38:0: style: The function 'roleNames' is never used. [unusedFunction]" . format ( PROJECT_DIR )
1820 ]
1921 assert ret == 0 , stdout
2022
@@ -26,9 +28,9 @@ def test_unused_functions_j(tmpdir):
2628 ret , stdout , stderr = cppcheck (['--template=simple' , '--library=qt' , '--enable=unusedFunction' , '-j2' , '--cppcheck-build-dir={}' .format (build_dir ), PROJECT_DIR ])
2729 # there are unused functions. But fillSampleData is not unused because that is referenced from main.qml
2830 assert stderr .splitlines () == [
29- "QML-Samples-TableView /samplemodel.cpp:9:0: style: The function 'rowCount' is never used. [unusedFunction]" ,
30- "QML-Samples-TableView /samplemodel.cpp:15:0: style: The function 'data' is never used. [unusedFunction]" ,
31- "QML-Samples-TableView /samplemodel.cpp:38:0: style: The function 'roleNames' is never used. [unusedFunction]"
31+ "{} /samplemodel.cpp:9:0: style: The function 'rowCount' is never used. [unusedFunction]" . format ( PROJECT_DIR ) ,
32+ "{} /samplemodel.cpp:15:0: style: The function 'data' is never used. [unusedFunction]" . format ( PROJECT_DIR ) ,
33+ "{} /samplemodel.cpp:38:0: style: The function 'roleNames' is never used. [unusedFunction]" . format ( PROJECT_DIR )
3234 ]
3335 assert ret == 0 , stdout
3436
0 commit comments