summaryrefslogtreecommitdiffstats
path: root/mkspecs/features/testcase.prf
diff options
context:
space:
mode:
Diffstat (limited to 'mkspecs/features/testcase.prf')
-rw-r--r--mkspecs/features/testcase.prf45
1 files changed, 23 insertions, 22 deletions
diff --git a/mkspecs/features/testcase.prf b/mkspecs/features/testcase.prf
index e31d1f4539..10f421a8e2 100644
--- a/mkspecs/features/testcase.prf
+++ b/mkspecs/features/testcase.prf
@@ -10,34 +10,35 @@ 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,^\\.\\./,)
+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))
}
-!isEmpty(MUNGED_DESTDIR):!contains(MUNGED_DESTDIR,^\\./?):check.commands = cd $(DESTDIR) &&
-contains(MUNGED_TARGET,.*/.*):check.commands = cd $(DESTDIR) &&
+
+!isEmpty(TESTRUN_CWD):!contains(TESTRUN_CWD,^\\./?): \
+ check.commands = cd $$system_path($$TESTRUN_CWD) &&
# Allow for a custom test runner script
check.commands += $(TESTRUNNER)
-mac {
- app_bundle: check.commands += ./$(QMAKE_TARGET).app/Contents/MacOS/$(QMAKE_TARGET)
- else: check.commands += ./$(QMAKE_TARGET)
+unix {
+ isEmpty(TEST_TARGET_DIR): TEST_TARGET_DIR = .
+
+ mac:app_bundle: \
+ check.commands += $${TEST_TARGET_DIR}/$(QMAKE_TARGET).app/Contents/MacOS/$(QMAKE_TARGET)
+ else: \
+ check.commands += $${TEST_TARGET_DIR}/$(QMAKE_TARGET)
+} else {
+ # Windows
+ !isEmpty(TEST_TARGET_DIR): TEST_TARGET_DIR = $${TEST_TARGET_DIR}$${QMAKE_DIR_SEP}
+ check.commands += $${TEST_TARGET_DIR}$(TARGET)
}
-else:unix: check.commands += ./$(QMAKE_TARGET)
-else: check.commands += $(DESTDIR_TARGET)
# Allow for custom arguments to tests
check.commands += $(TESTARGS)