summaryrefslogtreecommitdiffstats
path: root/mkspecs/features/testcase.prf
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2011-11-17 15:39:19 +1000
committerQt by Nokia <qt-info@nokia.com>2011-11-23 00:13:46 +0100
commit9ffd7a339f0da644c95e71583134263c06745ed5 (patch)
tree4407a01b28fffdd0474f60ae367ec6551737f82f /mkspecs/features/testcase.prf
parenta25d0ef3c24286602f7d9e80206b37f8ada7ac04 (diff)
Added build system support for installing tests.
Tests will install under $$[QT_INSTALL_TESTS]. TESTDATA may be used to install additional testdata required by the test. The default install rule may be disabled by CONFIG+=no_testcase_installs. Change-Id: I204de60c8e844775906ffd016ca50bffbb414142 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Diffstat (limited to 'mkspecs/features/testcase.prf')
-rw-r--r--mkspecs/features/testcase.prf46
1 files changed, 46 insertions, 0 deletions
diff --git a/mkspecs/features/testcase.prf b/mkspecs/features/testcase.prf
index eb0aa9fb85..b3ccbd4a51 100644
--- a/mkspecs/features/testcase.prf
+++ b/mkspecs/features/testcase.prf
@@ -65,5 +65,51 @@ QMAKE_EXTRA_TARGETS *= check
}
}
+!no_testcase_installs:!contains(INSTALLS, target) {
+ # Install tests unless no_testcase_installs is set, or there is already
+ # a `target' in INSTALLS.
+ #
+ # Tests are installed under a directory named after the target so that each
+ # test has its own directory for testdata etc.
+ #
+ load(resolve_target)
+ TARGET_BASENAME = $$basename(QMAKE_RESOLVED_TARGET)
+ target.path = $$[QT_INSTALL_TESTS]/$$TARGET_BASENAME
+ INSTALLS += target
+}
+
+contains(INSTALLS, target) {
+ # Install testdata as well, but only if we're actually installing the test.
+ #
+ # Testdata is installed relative to the directory containing the testcase
+ # binary itself, e.g. this:
+ #
+ # CONFIG += testcase
+ # TARGET = tst_qxmlreader
+ #
+ # TESTDATA += testdata/test1.xml testdata/test2.xml
+ #
+ # ... will result in:
+ #
+ # /usr/lib/qt5/tests/tst_qxmlreader/tst_qxmlreader
+ # /usr/lib/qt5/tests/tst_qxmlreader/testdata/test1.xml
+ # /usr/lib/qt5/tests/tst_qxmlreader/testdata/test2.xml
+ # ...
+ #
+ for(file, TESTDATA) {
+ tdi = testdata_install_$${elem}
+ tdif = $${tdi}.files
+ tdip = $${tdi}.path
+
+ # TESTDATA consists of the files to install (source)...
+ $$tdif = $$file
+
+ # ... and the destination preserves the relative path
+ $$tdip = $${target.path}/$$dirname(file)
+
+ INSTALLS += $$tdi
+ }
+}
+
}