2012-04-10 12:18:20 +00:00
|
|
|
have_target {
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-09-18 20:01:10 +00:00
|
|
|
# qt_build_config.prf disables execptions for all Qt modules which don't
|
|
|
|
# explicitly turn it on again, while the qmake default is to build with
|
|
|
|
# exceptions. As we want tests to be built like 3rd party applications,
|
|
|
|
# qt_build_config tells us to re-enable exceptions here.
|
|
|
|
testcase_exceptions: CONFIG += exceptions
|
|
|
|
|
2016-02-24 12:13:09 +00:00
|
|
|
benchmark: type = benchmark
|
|
|
|
else: type = check
|
|
|
|
|
|
|
|
$${type}.files =
|
|
|
|
$${type}.path = .
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2015-11-23 13:14:46 +00:00
|
|
|
# Add environment for non-installed builds. Do this first, so the
|
|
|
|
# 'make' variable expansions don't end up in a batch file/script.
|
|
|
|
QT_TOOL_NAME = target
|
2016-02-24 12:13:09 +00:00
|
|
|
qtAddTargetEnv($${type}.commands, QT)
|
2015-11-23 13:14:46 +00:00
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
# If the test ends up in a different directory, we should cd to that directory.
|
2013-10-07 15:55:45 +00:00
|
|
|
TESTRUN_CWD = $$DESTDIR
|
|
|
|
|
|
|
|
debug_and_release:debug_and_release_target {
|
|
|
|
# But in debug-and-release-target 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', not 'cd foo/release && tst_thing.exe').
|
|
|
|
|
|
|
|
TESTRUN_CWD ~= s/(release|debug)$//
|
|
|
|
TEST_TARGET_DIR = $$relative_path($$absolute_path($$DESTDIR, $$OUT_PWD), $$absolute_path($$TESTRUN_CWD, $$OUT_PWD))
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2013-10-07 15:55:45 +00:00
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
# Allow for a custom test runner script
|
2016-02-24 12:13:09 +00:00
|
|
|
$${type}.commands += $(TESTRUNNER)
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2013-10-07 15:55:45 +00:00
|
|
|
unix {
|
|
|
|
isEmpty(TEST_TARGET_DIR): TEST_TARGET_DIR = .
|
|
|
|
|
2015-11-19 15:53:50 +00:00
|
|
|
app_bundle: \
|
2016-02-24 12:13:09 +00:00
|
|
|
$${type}.commands += $${TEST_TARGET_DIR}/$(QMAKE_TARGET).app/Contents/MacOS/$(QMAKE_TARGET)
|
2013-10-07 15:55:45 +00:00
|
|
|
else: \
|
2016-02-24 12:13:09 +00:00
|
|
|
$${type}.commands += $${TEST_TARGET_DIR}/$(QMAKE_TARGET)
|
2013-10-07 15:55:45 +00:00
|
|
|
} else {
|
|
|
|
# Windows
|
|
|
|
!isEmpty(TEST_TARGET_DIR): TEST_TARGET_DIR = $${TEST_TARGET_DIR}$${QMAKE_DIR_SEP}
|
2016-02-24 12:13:09 +00:00
|
|
|
$${type}.commands += $${TEST_TARGET_DIR}$(TARGET)
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Allow for custom arguments to tests
|
2016-02-24 12:13:09 +00:00
|
|
|
$${type}.commands += $(TESTARGS)
|
2012-09-14 13:39:49 +00:00
|
|
|
|
2015-01-29 16:25:31 +00:00
|
|
|
!isEmpty(TESTRUN_CWD):!contains(TESTRUN_CWD, ^\\./?): \
|
2016-02-24 12:13:09 +00:00
|
|
|
$${type}.commands = cd $$shell_path($$TESTRUN_CWD) && $$eval($${type}.commands)
|
2015-01-29 16:25:31 +00:00
|
|
|
|
2011-05-19 01:42:31 +00:00
|
|
|
# If the test is marked as insignificant, discard the exit code
|
2016-02-24 12:13:09 +00:00
|
|
|
insignificant_test: $${type}.commands = -$$eval($${type}.commands)
|
2011-05-19 01:42:31 +00:00
|
|
|
|
2016-02-24 12:13:09 +00:00
|
|
|
QMAKE_EXTRA_TARGETS *= $${type}
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2015-03-02 17:14:04 +00:00
|
|
|
isEmpty(BUILDS)|build_pass {
|
2016-02-24 12:13:09 +00:00
|
|
|
$${type}.depends = first
|
2011-04-27 10:05:43 +00:00
|
|
|
} else {
|
2015-03-02 17:14:04 +00:00
|
|
|
# For exclusive builds, only run the test once.
|
2016-02-24 12:13:09 +00:00
|
|
|
$${type}.CONFIG = recursive
|
|
|
|
$${type}.target = $${type}_all
|
|
|
|
$${type}.recurse_target = $${type}
|
|
|
|
$${type}.commands =
|
|
|
|
|
|
|
|
$${type}_first.depends = $$eval($$first(BUILDS).target)-$${type}
|
|
|
|
$${type}_first.target = $${type}
|
|
|
|
QMAKE_EXTRA_TARGETS += $${type}_first
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2015-11-18 12:09:26 +00:00
|
|
|
!builtin_testdata:contains(INSTALLS, target) {
|
2012-06-22 02:03:39 +00:00
|
|
|
# Install testdata and helpers as well, but only if we're actually installing the test.
|
2011-11-17 05:39:19 +00:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
|
|
# TESTDATA consists of the files to install (source)...
|
2015-11-18 11:14:10 +00:00
|
|
|
$${tdi}.files = $$file
|
2011-11-17 05:39:19 +00:00
|
|
|
|
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, ^(\\.\\./)+, )
|
2015-11-18 11:14:10 +00:00
|
|
|
$${tdi}.path = $${target.path}/$$dirname(file)
|
2011-11-17 05:39:19 +00:00
|
|
|
|
|
|
|
INSTALLS += $$tdi
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2014-02-25 08:25:23 +00:00
|
|
|
# Install GENERATED_TESTDATA.
|
|
|
|
# Logic is copied from the TESTDATA installation, only difference being that
|
|
|
|
# INSTALL target is added with CONFIG = no_check_exist
|
|
|
|
for(file, GENERATED_TESTDATA) {
|
|
|
|
tnam = $$file
|
|
|
|
tnam ~= s,\\.\\.,dotdot,
|
|
|
|
tnam ~= s,[?*],wildcard,
|
|
|
|
tnam ~= s,[^A-Za-z0-9],_,
|
|
|
|
tdi = testdata_$$tnam
|
|
|
|
|
2015-11-18 11:14:10 +00:00
|
|
|
$${tdi}.files = $$file
|
|
|
|
$${tdi}.CONFIG = no_check_exist
|
2014-02-25 08:25:23 +00:00
|
|
|
|
|
|
|
file = $$replace(file, ^(\\.\\./)+, )
|
2015-11-18 11:14:10 +00:00
|
|
|
$${tdi}.path = $${target.path}/$$dirname(file)
|
2014-02-25 08:25:23 +00:00
|
|
|
|
|
|
|
INSTALLS += $$tdi
|
|
|
|
}
|
|
|
|
|
2012-06-22 02:03:39 +00:00
|
|
|
# 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
|
|
|
|
#
|
2012-01-10 00:38:51 +00:00
|
|
|
win32: extension = .exe
|
2012-06-22 02:03:39 +00:00
|
|
|
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}
|
|
|
|
}
|
2012-01-10 00:38:51 +00:00
|
|
|
}
|
|
|
|
|
2015-11-18 12:09:26 +00:00
|
|
|
builtin_testdata {
|
|
|
|
ALL_TESTDATA = $$TESTDATA $$GENERATED_TESTDATA
|
2016-09-01 09:04:33 +00:00
|
|
|
|
|
|
|
# BLACKLIST needs to be added to the testdata
|
|
|
|
BLACKLISTPATH = $$_PRO_FILE_PWD_/BLACKLIST
|
|
|
|
exists($$BLACKLISTPATH): ALL_TESTDATA *= $$BLACKLISTPATH
|
|
|
|
|
2015-11-18 12:09:26 +00:00
|
|
|
# RESOURCES does not support wildcards (for good reasons)
|
|
|
|
for(td, ALL_TESTDATA): \
|
|
|
|
testdata.files += $$files($$absolute_path($$td, $$_PRO_FILE_PWD_))
|
|
|
|
!isEmpty(testdata.files) {
|
|
|
|
testdata.base = $$_PRO_FILE_PWD_
|
|
|
|
RESOURCES += testdata
|
|
|
|
}
|
|
|
|
|
|
|
|
!isEmpty(TEST_HELPER_INSTALLS): \
|
|
|
|
error("This platform does not support tests which require helpers.")
|
|
|
|
}
|
|
|
|
|
2015-02-13 14:28:32 +00:00
|
|
|
macx-xcode:bundle:isEmpty(QMAKE_BUNDLE_EXTENSION) {
|
|
|
|
QMAKE_PBX_PRODUCT_TYPE = com.apple.product-type.bundle.unit-test
|
|
|
|
QMAKE_PBX_BUNDLE_TYPE = wrapper.cfbundle
|
|
|
|
QMAKE_BUNDLE_EXTENSION = .xctest
|
|
|
|
}
|
|
|
|
|
2012-06-22 02:03:39 +00:00
|
|
|
} # have_target
|
|
|
|
|