|
9 | 9 |
|
10 | 10 |
|
11 | 11 | def test_unused_functions(): |
12 | | - ret, stdout, stderr = cppcheck(['--library=qt', '--enable=unusedFunction', PROJECT_DIR]) |
| 12 | + ret, stdout, stderr = cppcheck(['--template=simple', '--library=qt', '--enable=unusedFunction', PROJECT_DIR]) |
13 | 13 | # there are unused functions. But fillSampleData is not unused because that is referenced from main.qml |
14 | | - assert '[unusedFunction]' in stderr |
15 | | - assert 'fillSampleData' not in stderr |
| 14 | + 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]" |
| 18 | + ] |
| 19 | + assert ret == 0, stdout |
16 | 20 |
|
17 | 21 |
|
18 | 22 | @pytest.mark.xfail |
19 | 23 | def test_unused_functions_j(tmpdir): |
20 | 24 | build_dir = os.path.join(tmpdir, 'b1') |
21 | 25 | os.mkdir(build_dir) |
22 | | - ret, stdout, stderr = cppcheck(['--library=qt', '--enable=unusedFunction', '-j2', '--cppcheck-build-dir={}'.format(build_dir), PROJECT_DIR]) |
| 26 | + ret, stdout, stderr = cppcheck(['--template=simple', '--library=qt', '--enable=unusedFunction', '-j2', '--cppcheck-build-dir={}'.format(build_dir), PROJECT_DIR]) |
23 | 27 | # there are unused functions. But fillSampleData is not unused because that is referenced from main.qml |
24 | | - assert '[unusedFunction]' in stderr |
25 | | - assert 'fillSampleData' not in stderr |
| 28 | + 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]" |
| 32 | + ] |
| 33 | + assert ret == 0, stdout |
26 | 34 |
|
27 | 35 | # TODO: test with project file |
28 | 36 | # TODO: test with FileSettings |
0 commit comments