Skip to content

Commit f3d2680

Browse files
committed
test/cli/qml_test.py: made it location-independent
1 parent efae93f commit f3d2680

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

test/cli/qml_test.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@
55
import pytest
66
from 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

1113
def 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

Comments
 (0)