Avoid load(testcase) for installing test helper apps
authorRohan McGovern <rohan.mcgovern@nokia.com>
Fri, 22 Jun 2012 02:03:39 +0000 (12:03 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 4 Jul 2012 00:46:27 +0000 (02:46 +0200)
Make test projects declare TEST_HELPER_INSTALLS rather than calling a
function exported by testcase.prf.  load(testcase) may be unsafe, as
testcase.prf should be processed after default_post.prf.

Fixes silent disabling of various autotests.

Change-Id: I56b35ffd653a637ad5ab18d64dd1a1edadfac59f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Reviewed-by: Kurt Korbatits <kurt.korbatits@nokia.com>
mkspecs/features/testcase.prf
tests/auto/corelib/global/qlogging/test/test.pro
tests/auto/corelib/io/qprocess/test/test.pro
tests/auto/corelib/kernel/qobject/test/test.pro
tests/auto/corelib/thread/qthreadstorage/test/test.pro
tests/auto/corelib/tools/qlocale/test/test.pro
tests/auto/gui/kernel/qclipboard/test/test.pro
tests/auto/network/access/qnetworkreply/test/test.pro
tests/auto/network/bearer/qnetworksession/test/test.pro
tests/auto/testlib/selftests/test/test.pro
tests/auto/widgets/kernel/qapplication/test/test.pro

index c076882..f76018a 100644 (file)
@@ -76,7 +76,7 @@ QMAKE_EXTRA_TARGETS *= check
 }
 
 contains(INSTALLS, target) {
-    # Install testdata as well, but only if we're actually installing the test.
+    # Install testdata and helpers 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:
@@ -123,32 +123,36 @@ contains(INSTALLS, target) {
 
         INSTALLS += $$tdi
     }
-}
-
-} # have_target
 
-defineTest(installTestHelperApp) {
-    # args: relativeSource, relativeDestination, targetName
-    # description: install executables from other project directories as part of your installation.
-    # relativeSource - file to install including relative path
-    # relativeDestination - relative directory to install to
-    # targetName - executable without extension
-    targetName = $$replace(3, ' ', '_') # handle spaces in name
-    subTarget = $${targetName}.target
-    subInstall = $${targetName}_install
-    subConfig = $${subInstall}.CONFIG
-    subFiles = $${subInstall}.files
-    subPath = $${subInstall}.path
+    # TEST_HELPER_INSTALLS specifies additional test helper executables for installation.
+    #
+    # Typical usage is:
+    #
+    #   TEST_HELPER_INSTALLS += ../some/helper1 ../some/helper2
+    #
+    # Resulting in the test helpers being installed to:
+    #
+    #   $$[QT_INSTALL_TESTS]/$$TARGET/some/helper1
+    #   $$[QT_INSTALL_TESTS]/$$TARGET/some/helper2
+    #
     win32: extension = .exe
-    $$subTarget = $${2}/$${3}$${extension}
-    $$subFiles = $${OUT_PWD}/$${1}$${extension}
-    $$subPath = $${target.path}/$${2}
-    $$subConfig += no_check_exist executable
-    INSTALLS += $${subInstall}
-    export(INSTALLS)
-    export($$subTarget)
-    export($$subFiles)
-    export($$subPath)
-    export($$subConfig)
+    for(test_helper, TEST_HELPER_INSTALLS) {
+        test_helper_dir = $$dirname(test_helper)
+        output = $$basename(test_helper_dir)
+        target = $$basename(test_helper)
+        targetName = $$replace(target, ' ', '_') # handle spaces in name
+        subTarget = $${targetName}.target
+        subInstall = $${targetName}_install
+        subConfig = $${subInstall}.CONFIG
+        subFiles = $${subInstall}.files
+        subPath = $${subInstall}.path
+        $$subTarget = $${output}/$${target}$${extension}
+        $$subFiles = $${OUT_PWD}/$${test_helper}$${extension}
+        $$subPath = $${target.path}/$${output}
+        $$subConfig += no_check_exist executable
+        INSTALLS += $${subInstall}
+    }
 }
 
+} # have_target
+
index 57e9ba3..d791f9c 100644 (file)
@@ -4,5 +4,4 @@ TARGET = ../tst_qlogging
 QT = core testlib
 SOURCES = ../tst_qlogging.cpp
 
-load(testcase) # for target.path and installTestHelperApp()
-installTestHelperApp("../app/app",app,app)
+TEST_HELPER_INSTALLS = ../app/app
index b3eeb59..1ddd0ba 100644 (file)
@@ -14,10 +14,10 @@ include(../qprocess.pri)
 win32:CONFIG += insignificant_test # QTBUG-25342 - sometimes hangs
 mac:CONFIG += insignificant_test # QTBUG-25895 - sometimes hangs
 
-load(testcase) # for target.path and installTestHelperApp()
-for(file, SUBPROGRAMS): installTestHelperApp("../$${file}/$${file}",$${file},$${file})
-installTestHelperApp("../testProcessSpacesArgs/nospace",testProcessSpacesArgs,nospace)
-installTestHelperApp("../testProcessSpacesArgs/one space",testProcessSpacesArgs,"one space")
-installTestHelperApp("../testProcessSpacesArgs/two space s",testProcessSpacesArgs,"two space s")
-installTestHelperApp("../test Space In Name/testSpaceInName","test Space In Name",testSpaceInName)
+for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../$${file}/$${file}"
 
+TEST_HELPER_INSTALLS += \
+    ../testProcessSpacesArgs/nospace \
+    "../testProcessSpacesArgs/one space" \
+    "../testProcessSpacesArgs/two space s" \
+    "../test Space In Name/testSpaceInName"
index ba98bf3..c2f801b 100644 (file)
@@ -4,5 +4,4 @@ TARGET = ../tst_qobject
 QT = core-private network testlib
 SOURCES = ../tst_qobject.cpp
 
-load(testcase) # for target.path and installTestHelperApp()
-installTestHelperApp("../signalbug/signalbug",signalbug,signalbug)
+TEST_HELPER_INSTALLS = ../signalbug/signalbug
index 0dc8656..729241f 100644 (file)
@@ -5,6 +5,5 @@ CONFIG += console
 QT = core testlib
 SOURCES = ../tst_qthreadstorage.cpp
 
-load(testcase) # for installTestHelperApp()
-installTestHelperApp("../crashonexit/crashonexit",crashonexit,crashonexit)
+TEST_HELPER_INSTALLS = ../crashonexit/crashonexit
 
index 4bb409a..05c74d7 100644 (file)
@@ -14,7 +14,6 @@ win32 {
     }
 }
 
-load(testcase) # for target.path and installTestHelperApp()
-installTestHelperApp("../syslocaleapp/syslocaleapp",syslocaleapp,syslocaleapp)
+TEST_HELPER_INSTALLS = ../syslocaleapp/syslocaleapp
 
 win32:CONFIG+= insignificant_test # QTBUG-25284
index d7a67ae..5864048 100644 (file)
@@ -15,6 +15,6 @@ wince* {
   DEPLOYMENT += rsc reg_resource
 }
 
-load(testcase) # for target.path and installTestHelperApp()
-installTestHelperApp("../copier/copier",copier,copier)
-installTestHelperApp("../paster/paster",paster,paster)
+TEST_HELPER_INSTALLS = \
+    ../copier/copier \
+    ../paster/paster
index 2c43aa0..0a95e43 100644 (file)
@@ -15,5 +15,5 @@ TESTDATA += ../empty ../rfc3252.txt ../resource ../bigfile ../*.jpg ../certs \
             ../index.html ../smb-file.txt
 
 win32:CONFIG += insignificant_test # QTBUG-24226
-load(testcase) # for target.path and installTestHelperApp()
-installTestHelperApp("../echo/echo",echo,echo)
+
+TEST_HELPER_INSTALLS = ../echo/echo
index c87e8e9..dd7618b 100644 (file)
@@ -15,5 +15,4 @@ CONFIG(debug_and_release) {
   DESTDIR = ..
 }
 
-load(testcase) # for target.path and installTestHelperApp()
-installTestHelperApp("../lackey/lackey",lackey,lackey)
+TEST_HELPER_INSTALLS = ../lackey/lackey
index 30f18b1..0a31810 100644 (file)
@@ -16,6 +16,5 @@ win32 {
 RESOURCES += ../selftests.qrc
 
 include(../selftests.pri)
-load(testcase) # for target.path and installTestHelperApp()
-for(file, SUBPROGRAMS): installTestHelperApp("../$${file}/$${file}",$${file},$${file})
+for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../$${file}/$${file}"
 
index 37af570..6732f48 100644 (file)
@@ -12,7 +12,6 @@ TESTDATA = ../test/test.pro ../tmp/README
 SUBPROGRAMS = desktopsettingsaware modal
 win32: !wince*: SUBPROGRAMS += wincmdline
 
-load(testcase) # for target.path and installTestHelperApp()
-for(file, SUBPROGRAMS): installTestHelperApp("../$${file}/$${file}",$${file},$${file})
+for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../$${file}/$${file}"