From 9ffd7a339f0da644c95e71583134263c06745ed5 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 17 Nov 2011 15:39:19 +1000 Subject: 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 --- mkspecs/features/testcase.prf | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'mkspecs/features/testcase.prf') 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 + } +} + } -- cgit v1.2.3