From 92c5f3fb7b3f3a90e27be71e73395ac517f0b3ea Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 28 Jun 2018 18:03:43 +0200 Subject: [PATCH] Add qt_test_helper feature To avoid (even more) duplicated code, "qt_test_helper" ensures the policy of putting a test's helper application next to the test's own executable. The helper executable is suffixed with "_helper" to avoid name clashes with its folder. Change-Id: Ic50cb1daa257e7ffc75440c10a3b90fd39424683 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/qt_test_helper.prf | 35 +++++++++++++++++++ tests/auto/corelib/io/qfile/qfile.pro | 2 +- .../io/qfile/stdinprocess/stdinprocess.pro | 16 +-------- tests/auto/corelib/io/qfile/test.pro | 26 ++++++++++++++ tests/auto/corelib/io/qfile/test/test.pro | 32 ----------------- 5 files changed, 63 insertions(+), 48 deletions(-) create mode 100644 mkspecs/features/qt_test_helper.prf create mode 100644 tests/auto/corelib/io/qfile/test.pro delete mode 100644 tests/auto/corelib/io/qfile/test/test.pro diff --git a/mkspecs/features/qt_test_helper.prf b/mkspecs/features/qt_test_helper.prf new file mode 100644 index 0000000000..5daa14731d --- /dev/null +++ b/mkspecs/features/qt_test_helper.prf @@ -0,0 +1,35 @@ +# +# W A R N I N G +# ------------- +# +# This file is not part of the Qt API. It exists purely as an +# implementation detail. It may change from version to version +# without notice, or even be removed. +# +# We mean it. +# + +# If an auto test needs a helper application, this helper should +# be put into the same directory as the test itself. This common +# folder should be the test's "main directory" or a "debug" or "release" +# subfolder inside this main directory if debug_and_release is enabled. +# Additionally the helper's executable is suffixed with "_helper" to +# avoid name clashes with its folder. + +CONFIG -= app_bundle +CONFIG += console + +debug_and_release { + CONFIG(debug, debug|release) { + TARGET = ../../debug/$${TARGET}_helper + } else { + TARGET = ../../release/$${TARGET}_helper + } +} else { + TARGET = ../$${TARGET}_helper +} + +parentFolder = $$dirname(_PRO_FILE_PWD_) +testFolder = $$basename(parentFolder) +target.path = $$[QT_INSTALL_TESTS]/$$testFolder +INSTALLS += target diff --git a/tests/auto/corelib/io/qfile/qfile.pro b/tests/auto/corelib/io/qfile/qfile.pro index d2bfc08372..91c5c15f66 100644 --- a/tests/auto/corelib/io/qfile/qfile.pro +++ b/tests/auto/corelib/io/qfile/qfile.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs -SUBDIRS = test +SUBDIRS = test.pro !winrt: SUBDIRS += stdinprocess diff --git a/tests/auto/corelib/io/qfile/stdinprocess/stdinprocess.pro b/tests/auto/corelib/io/qfile/stdinprocess/stdinprocess.pro index 4029701943..512da8939b 100644 --- a/tests/auto/corelib/io/qfile/stdinprocess/stdinprocess.pro +++ b/tests/auto/corelib/io/qfile/stdinprocess/stdinprocess.pro @@ -1,18 +1,4 @@ SOURCES += main.cpp QT = core -CONFIG -= app_bundle -CONFIG += console -debug_and_release { - CONFIG(debug, debug|release) { - TARGET = ../../debug/stdinprocess_helper - } else { - TARGET = ../../release/stdinprocess_helper - } -} else { - TARGET = ../stdinprocess_helper -} - -# This app is testdata for tst_qfile -target.path = $$[QT_INSTALL_TESTS]/tst_qfile/$$TARGET -INSTALLS += target +load(qt_test_helper) diff --git a/tests/auto/corelib/io/qfile/test.pro b/tests/auto/corelib/io/qfile/test.pro new file mode 100644 index 0000000000..95389ab3e2 --- /dev/null +++ b/tests/auto/corelib/io/qfile/test.pro @@ -0,0 +1,26 @@ +CONFIG += testcase +QT = core-private testlib +qtHaveModule(network): QT += network +else: DEFINES += QT_NO_NETWORK + +contains(CONFIG, builtin_testdata) { + DEFINES += BUILTIN_TESTDATA +} + +TESTDATA += BLACKLIST + +TARGET = tst_qfile + +SOURCES = tst_qfile.cpp +INCLUDEPATH += ../../../../shared/ +HEADERS += ../../../../shared/emulationdetector.h + +RESOURCES += qfile.qrc rename-fallback.qrc copy-fallback.qrc + +TESTDATA += \ + dosfile.txt noendofline.txt testfile.txt \ + testlog.txt two.dots.file tst_qfile.cpp \ + Makefile forCopying.txt forRenaming.txt \ + resources/file1.ext1 + +win32:!winrt: LIBS += -lole32 -luuid diff --git a/tests/auto/corelib/io/qfile/test/test.pro b/tests/auto/corelib/io/qfile/test/test.pro deleted file mode 100644 index 7b952b0283..0000000000 --- a/tests/auto/corelib/io/qfile/test/test.pro +++ /dev/null @@ -1,32 +0,0 @@ -CONFIG += testcase -QT = core-private core testlib -qtHaveModule(network): QT += network -else: DEFINES += QT_NO_NETWORK - -contains(CONFIG, builtin_testdata) { - DEFINES += BUILTIN_TESTDATA -} - -TESTDATA += ../BLACKLIST - -debug_and_release { - CONFIG(debug, debug|release) { - TARGET = ../../debug/tst_qfile - } else { - TARGET = ../../release/tst_qfile - } -} else { - TARGET = ../tst_qfile -} -SOURCES = ../tst_qfile.cpp -INCLUDEPATH += ../../../../../shared/ -HEADERS += ../../../../../shared/emulationdetector.h - -RESOURCES += ../qfile.qrc ../rename-fallback.qrc ../copy-fallback.qrc - -TESTDATA += ../dosfile.txt ../noendofline.txt ../testfile.txt \ - ../testlog.txt ../two.dots.file ../tst_qfile.cpp \ - ../Makefile ../forCopying.txt ../forRenaming.txt \ - ../resources/file1.ext1 - -win32:!winrt: LIBS+=-lole32 -luuid