aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/tests
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-10-19 15:22:17 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-10-20 11:09:44 +0000
commitb2d3a7dac9ca968b5800b6da1661e632a7ea9e90 (patch)
tree713dfd8335f364cd1c6556998b3aff2d051cb625 /sources/shiboken2/ApiExtractor/tests
parentc6fb7198d726d61d90a702aa66c89765c3f19e79 (diff)
shiboken/ApiExtractor tests: Use qrc files for test resources
This removes the need to copy around test files and the test will also run when launched from a different directory. Extend and fix the declare_test() CMake macro to also add resource files, add .qrc files and modify the tests accordingly. Task-number: PYSIDE-834 Change-Id: Id469e0b11837f7c6a7d71a20494ac019a32d8ed0 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/tests')
-rw-r--r--sources/shiboken2/ApiExtractor/tests/CMakeLists.txt17
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testcodeinjection.cpp6
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testcodeinjection.qrc5
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testmodifydocumentation.cpp2
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testmodifydocumentation.qrc5
5 files changed, 22 insertions, 13 deletions
diff --git a/sources/shiboken2/ApiExtractor/tests/CMakeLists.txt b/sources/shiboken2/ApiExtractor/tests/CMakeLists.txt
index 860a37d9d..e100ef493 100644
--- a/sources/shiboken2/ApiExtractor/tests/CMakeLists.txt
+++ b/sources/shiboken2/ApiExtractor/tests/CMakeLists.txt
@@ -4,13 +4,18 @@ find_package(Qt5Test)
find_package(Qt5Xml)
find_package(Qt5XmlPatterns)
+set(CMAKE_AUTORCC ON)
+
macro(declare_test testname)
# gone: qt4_automoc("${testname}.cpp")
- if (EXISTS "${testname}.h")
- add_executable(${testname} "${testname}.h ${testname}.cpp")
- else ()
- add_executable(${testname} "${testname}.cpp")
+ set(SOURCES "${testname}.cpp")
+ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${testname}.h")
+ list(APPEND SOURCES "${testname}.h")
+ endif ()
+ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${testname}.qrc")
+ list(APPEND SOURCES "${testname}.qrc")
endif ()
+ add_executable(${testname} ${SOURCES})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${apiextractor_SOURCE_DIR}
@@ -35,8 +40,6 @@ declare_test(testabstractmetatype)
declare_test(testaddfunction)
declare_test(testarrayargument)
declare_test(testcodeinjection)
-configure_file("${CMAKE_CURRENT_SOURCE_DIR}/utf8code.txt"
- "${CMAKE_CURRENT_BINARY_DIR}/utf8code.txt" COPYONLY)
declare_test(testcontainer)
declare_test(testconversionoperator)
declare_test(testconversionruletag)
@@ -68,7 +71,5 @@ declare_test(testvoidarg)
declare_test(testtyperevision)
if (NOT DISABLE_DOCSTRINGS)
declare_test(testmodifydocumentation)
- configure_file("${CMAKE_CURRENT_SOURCE_DIR}/a.xml"
- "${CMAKE_CURRENT_BINARY_DIR}/a.xml" COPYONLY)
endif()
diff --git a/sources/shiboken2/ApiExtractor/tests/testcodeinjection.cpp b/sources/shiboken2/ApiExtractor/tests/testcodeinjection.cpp
index bf1057ee9..68da25373 100644
--- a/sources/shiboken2/ApiExtractor/tests/testcodeinjection.cpp
+++ b/sources/shiboken2/ApiExtractor/tests/testcodeinjection.cpp
@@ -40,13 +40,11 @@ void TestCodeInjections::testReadFileUtf8()
int argc = 0;
char *argv[] = {NULL};
QCoreApplication app(argc, argv);
- QString filePath = QDir::currentPath();
QString xmlCode = QLatin1String("\
<typesystem package=\"Foo\">\n\
<value-type name='A'>\n\
- <conversion-rule file='") + filePath + QLatin1String("/utf8code.txt'/>\n\
- <inject-code class='target' file='") + filePath
- + QLatin1String("/utf8code.txt'/>\n\
+ <conversion-rule file=':/utf8code.txt'/>\n\
+ <inject-code class='target' file=':/utf8code.txt'/>\n\
</value-type>\n\
<value-type name='A::B'/>\n\
</typesystem>\n");
diff --git a/sources/shiboken2/ApiExtractor/tests/testcodeinjection.qrc b/sources/shiboken2/ApiExtractor/tests/testcodeinjection.qrc
new file mode 100644
index 000000000..61d59567b
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testcodeinjection.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource>
+ <file>utf8code.txt</file>
+ </qresource>
+</RCC>
diff --git a/sources/shiboken2/ApiExtractor/tests/testmodifydocumentation.cpp b/sources/shiboken2/ApiExtractor/tests/testmodifydocumentation.cpp
index 7911a5eb1..f615befb4 100644
--- a/sources/shiboken2/ApiExtractor/tests/testmodifydocumentation.cpp
+++ b/sources/shiboken2/ApiExtractor/tests/testmodifydocumentation.cpp
@@ -60,7 +60,7 @@ R"(<typesystem package="Foo">
QCOMPARE(docMods[1].code().trimmed(), QLatin1String("<para>Some changed contents here</para>"));
QCOMPARE(docMods[1].signature(), QString());
QtDocParser docParser;
- docParser.setDocumentationDataDirectory(QDir::currentPath());
+ docParser.setDocumentationDataDirectory(QLatin1String(":"));
docParser.fillDocumentation(classA);
const QString actualDocSimplified = classA->documentation().value().simplified();
diff --git a/sources/shiboken2/ApiExtractor/tests/testmodifydocumentation.qrc b/sources/shiboken2/ApiExtractor/tests/testmodifydocumentation.qrc
new file mode 100644
index 000000000..76b1bfc61
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/tests/testmodifydocumentation.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource>
+ <file>a.xml</file>
+ </qresource>
+</RCC>