2012-04-10 12:18:20 +00:00
|
|
|
have_target {
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
check.files =
|
|
|
|
check.path = .
|
|
|
|
|
|
|
|
# If the test ends up in a different directory, we should cd to that directory.
|
|
|
|
# Note that qmake modifies DESTDIR after this file is processed,
|
|
|
|
# therefore, testing DESTDIR for emptiness is not sufficient.
|
|
|
|
# Also note that in debug-and-release mode we don't want to cd into the debug/release
|
|
|
|
# directory (e.g. if the test goes to foo/release/tst_thing.exe, we want to do
|
|
|
|
# cd foo && release/tst_thing.exe ).
|
|
|
|
MUNGED_DESTDIR=$$DESTDIR
|
|
|
|
MUNGED_TARGET=$$TARGET
|
|
|
|
win32:debug_and_release {
|
|
|
|
contains(DESTDIR,^release$)|contains(DESTDIR,^debug$):MUNGED_DESTDIR=
|
|
|
|
|
|
|
|
# In debug-and-release mode, the first ../ in TARGET breaks out of the debug/release
|
|
|
|
# subdirectory. However, since make's working directory is already outside of the
|
|
|
|
# debug/release subdirectory, this first ../ should be ignored when deciding if
|
|
|
|
# we have to change directory before running the test.
|
|
|
|
MUNGED_TARGET=$$replace(MUNGED_TARGET,^\\.\\./,)
|
|
|
|
}
|
|
|
|
!isEmpty(MUNGED_DESTDIR):!contains(MUNGED_DESTDIR,^\\./?):check.commands = cd $(DESTDIR) &&
|
|
|
|
contains(MUNGED_TARGET,.*/.*):check.commands = cd $(DESTDIR) &&
|
|
|
|
|
|
|
|
# Allow for a custom test runner script
|
|
|
|
check.commands += $(TESTRUNNER)
|
|
|
|
|
|
|
|
macx {
|
|
|
|
app_bundle: check.commands += ./$(QMAKE_TARGET).app/Contents/MacOS/$(QMAKE_TARGET)
|
|
|
|
else: check.commands += ./$(QMAKE_TARGET)
|
|
|
|
}
|
|
|
|
else:unix: check.commands += ./$(QMAKE_TARGET)
|
|
|
|
else: check.commands += $(DESTDIR_TARGET)
|
|
|
|
|
|
|
|
# Allow for custom arguments to tests
|
|
|
|
check.commands += $(TESTARGS)
|
2011-05-19 01:42:31 +00:00
|
|
|
|
|
|
|
# If the test is marked as insignificant, discard the exit code
|
|
|
|
insignificant_test:check.commands = -$${check.commands}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
QMAKE_EXTRA_TARGETS *= check
|
|
|
|
|
|
|
|
!debug_and_release|build_pass {
|
|
|
|
check.depends = first
|
|
|
|
} else {
|
|
|
|
check.CONFIG = recursive
|
|
|
|
# In debug and release mode, only run the test once.
|
2012-02-17 08:48:22 +00:00
|
|
|
# Run debug if that is the preferred config, release otherwise.
|
2011-04-27 10:05:43 +00:00
|
|
|
debug_and_release {
|
|
|
|
check.target = dummy_check
|
|
|
|
check.recurse_target = check
|
2012-02-17 08:48:22 +00:00
|
|
|
CONFIG(debug, debug|release) {
|
2011-04-27 10:05:43 +00:00
|
|
|
real_check.depends = debug-check
|
|
|
|
real_check.target = check
|
|
|
|
QMAKE_EXTRA_TARGETS += real_check
|
|
|
|
} else {
|
|
|
|
real_check.depends = release-check
|
|
|
|
real_check.target = check
|
|
|
|
QMAKE_EXTRA_TARGETS += real_check
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-17 05:39:19 +00:00
|
|
|
!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) {
|
2012-03-10 09:04:04 +00:00
|
|
|
tnam = $$file
|
|
|
|
tnam ~= s,\\.\\.,dotdot,
|
|
|
|
tnam ~= s,[?*],wildcard,
|
|
|
|
tnam ~= s,[^A-Za-z0-9],_,
|
|
|
|
tdi = testdata_$$tnam
|
2011-11-17 05:39:19 +00:00
|
|
|
tdif = $${tdi}.files
|
|
|
|
tdip = $${tdi}.path
|
|
|
|
|
|
|
|
# TESTDATA consists of the files to install (source)...
|
|
|
|
$$tdif = $$file
|
|
|
|
|
2011-11-24 00:31:24 +00:00
|
|
|
# ... and the destination preserves the relative path.
|
|
|
|
# Strip any leading ../ from the testdata, so that installation does not escape
|
|
|
|
# the test's directory in the case of e.g.
|
|
|
|
#
|
|
|
|
# TARGET = ../tst_qprocess
|
|
|
|
# TESTDATA = ../thing1 ../thing2
|
|
|
|
#
|
|
|
|
# The testdata should end up at $$[QT_INSTALL_TESTS]/tst_qprocess/thing1,
|
|
|
|
# rather than $$[QT_INSTALL_TESTS]/tst_qprocess/../thing1.
|
|
|
|
#
|
|
|
|
# Note that this does not guarantee the same relative path between test binary
|
|
|
|
# and testdata in the build and install tree, but should cover most cases.
|
|
|
|
#
|
|
|
|
file = $$replace(file, ^(\\.\\./)+, )
|
2011-11-17 05:39:19 +00:00
|
|
|
$$tdip = $${target.path}/$$dirname(file)
|
|
|
|
|
|
|
|
INSTALLS += $$tdi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-10 12:18:20 +00:00
|
|
|
} # have_target
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-01-10 00:38:51 +00:00
|
|
|
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
|
|
|
|
win32: extension = .exe
|
|
|
|
$$subTarget = $${2}/$${3}$${extension}
|
2012-03-22 02:46:19 +00:00
|
|
|
$$subFiles = $${OUT_PWD}/$${1}$${extension}
|
2012-01-10 00:38:51 +00:00
|
|
|
$$subPath = $${target.path}/$${2}
|
|
|
|
$$subConfig += no_check_exist executable
|
|
|
|
INSTALLS += $${subInstall}
|
|
|
|
export(INSTALLS)
|
|
|
|
export($$subTarget)
|
|
|
|
export($$subFiles)
|
|
|
|
export($$subPath)
|
|
|
|
export($$subConfig)
|
|
|
|
}
|
|
|
|
|