From 9fc9fefdc9f598f8d223dc6eab533be4d0abc762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 11 Feb 2020 14:52:49 +0100 Subject: Restructure testlib selftest project The use of a single subdirectory only for the test binary, but not the actual source file, just made things harder to discover when looking for the test code. Now all subdirectories are actual sub-tests. Change-Id: Ia3e308ba8d231cc8ead1491b10a34801f76669b0 Reviewed-by: Alexandru Croitor --- tests/auto/testlib/selftests/CMakeLists.txt | 65 ++++++++++++++++++---- tests/auto/testlib/selftests/selftest.pro | 22 ++++++++ tests/auto/testlib/selftests/selftests.pri | 4 +- tests/auto/testlib/selftests/selftests.pro | 8 ++- .../testlib/selftests/test/.prev_CMakeLists.txt | 45 --------------- tests/auto/testlib/selftests/test/CMakeLists.txt | 61 -------------------- tests/auto/testlib/selftests/test/test.pro | 22 -------- 7 files changed, 84 insertions(+), 143 deletions(-) create mode 100644 tests/auto/testlib/selftests/selftest.pro delete mode 100644 tests/auto/testlib/selftests/test/.prev_CMakeLists.txt delete mode 100644 tests/auto/testlib/selftests/test/CMakeLists.txt delete mode 100644 tests/auto/testlib/selftests/test/test.pro (limited to 'tests/auto/testlib/selftests') diff --git a/tests/auto/testlib/selftests/CMakeLists.txt b/tests/auto/testlib/selftests/CMakeLists.txt index a1f6cd5457..4126014efd 100644 --- a/tests/auto/testlib/selftests/CMakeLists.txt +++ b/tests/auto/testlib/selftests/CMakeLists.txt @@ -1,19 +1,64 @@ -# Generated from selftests.pro. +# The whole file is written manually. +# special case skip regeneration -# special case begin include(../../../../src/testlib/selfcover.cmake) -# special case end -add_subdirectory(test) +# ------------- Test runner ------------- -if(NOT WINRT) +qt_add_test(tst_selftests + OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/" + SOURCES + ../../../shared/emulationdetector.h + tst_selftests.cpp + INCLUDE_DIRECTORIES + ../../../shared + PUBLIC_LIBRARIES + Qt::TestPrivate + # special case begin + # These lines need to be commented out as they need to be enabled + # COMPILE_OPTIONS + # conditionally + # --cs-exclude-file-abs-wildcard=${QT_SOURCE_TREE}/* + # --cs-include-file-abs-wildcard=*/src/testlib/* + # --cs-mcc + # --cs-mcdc + # LINK_OPTIONS + # "$$COVERAGE_OPTIONS" + # special case end +) - if(TARGET Qt::Gui) - endif() -endif() -# special case begin +file(GLOB resource_glob_0 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "expected_*") +foreach(file IN LISTS resource_glob_0) + set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/${file}" PROPERTIES QT_RESOURCE_ALIAS "${file}") +endforeach() -# The whole file is written manually. +# Resources: +set(qmake_expected_files_resource_files + ${resource_glob_0} +) + +qt_add_resource(tst_selftests "qmake_expected_files" + PREFIX + "/" + BASE + "${CMAKE_CURRENT_SOURCE_DIR}" # special case + FILES + ${qmake_expected_files_resource_files} +) + + +## Scopes: +##################################################################### + +#### Keys ignored in scope 5:.:.:test.pro:NOT ANDROID AND NOT WINRT AND for(file,SUBPROGRAMS): +# TEST_HELPER_INSTALLS = "../$${file}/$${file}" + +#### Keys ignored in scope 7:.:..:../selftests.pri:TARGET Qt::Gui: +# SUBPROGRAMS = "keyboard" "mouse" + +qt_apply_testlib_coverage_options(tst_selftests) + +# ------------- Sub tests ------------- if(NOT WINRT) add_subdirectory(assert) diff --git a/tests/auto/testlib/selftests/selftest.pro b/tests/auto/testlib/selftests/selftest.pro new file mode 100644 index 0000000000..4216e17293 --- /dev/null +++ b/tests/auto/testlib/selftests/selftest.pro @@ -0,0 +1,22 @@ +CONFIG += testcase +SOURCES += tst_selftests.cpp +QT = core testlib-private + +TARGET = tst_selftests + +win32 { + CONFIG(debug, debug|release) { + TARGET = ../debug/tst_selftests +} else { + TARGET = ../release/tst_selftests + } +} + +expected_files.files = $$files($$PWD/expected_*) +expected_files.base = $$PWD +RESOURCES += expected_files + +include(selftests.pri) +!android:!winrt: for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "$${file}/$${file}" + +include($$QT_SOURCE_TREE/src/testlib/selfcover.pri) diff --git a/tests/auto/testlib/selftests/selftests.pri b/tests/auto/testlib/selftests/selftests.pri index b124b21981..fb456d541b 100644 --- a/tests/auto/testlib/selftests/selftests.pri +++ b/tests/auto/testlib/selftests/selftests.pri @@ -59,5 +59,5 @@ qtHaveModule(gui): SUBPROGRAMS += \ keyboard \ mouse -INCLUDEPATH += ../../../../shared/ -HEADERS += ../../../../shared/emulationdetector.h +INCLUDEPATH += ../../../shared/ +HEADERS += ../../../shared/emulationdetector.h diff --git a/tests/auto/testlib/selftests/selftests.pro b/tests/auto/testlib/selftests/selftests.pro index 7a61916535..235967ebe9 100644 --- a/tests/auto/testlib/selftests/selftests.pro +++ b/tests/auto/testlib/selftests/selftests.pro @@ -2,10 +2,12 @@ TEMPLATE = subdirs !winrt: include(selftests.pri) -SUBDIRS = $$SUBPROGRAMS test +selftest.file = selftest.pro +selftest.makefile = Makefile.selftest +selftest.target = selftest + +SUBDIRS = $$SUBPROGRAMS selftest INSTALLS = QT = core - - diff --git a/tests/auto/testlib/selftests/test/.prev_CMakeLists.txt b/tests/auto/testlib/selftests/test/.prev_CMakeLists.txt deleted file mode 100644 index 02d87aa45b..0000000000 --- a/tests/auto/testlib/selftests/test/.prev_CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ -# Generated from test.pro. - -##################################################################### -## tst_selftests Test: -##################################################################### - -qt_add_test(tst_selftests - OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../" - SOURCES - ../../../../shared/emulationdetector.h - ../tst_selftests.cpp - INCLUDE_DIRECTORIES - ../../../../shared - PUBLIC_LIBRARIES - Qt::TestPrivate -) - -file(GLOB resource_glob_0 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "../expected_*") -foreach(file IN LISTS resource_glob_0) - set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/${file}" PROPERTIES QT_RESOURCE_ALIAS "${file}") -endforeach() - -# Resources: -set(qmake_expected_files_resource_files - ${resource_glob_0} -) - -qt_add_resource(tst_selftests "qmake_expected_files" - PREFIX - "/" - BASE - "$$PWD/.." - FILES - ${qmake_expected_files_resource_files} -) - - -## Scopes: -##################################################################### - -#### Keys ignored in scope 5:.:.:test.pro:NOT ANDROID AND NOT WINRT AND for(file,SUBPROGRAMS): -# TEST_HELPER_INSTALLS = "../$${file}/$${file}" - -#### Keys ignored in scope 7:.:..:../selftests.pri:TARGET Qt::Gui: -# SUBPROGRAMS = "keyboard" "mouse" diff --git a/tests/auto/testlib/selftests/test/CMakeLists.txt b/tests/auto/testlib/selftests/test/CMakeLists.txt deleted file mode 100644 index 986e3cfd2f..0000000000 --- a/tests/auto/testlib/selftests/test/CMakeLists.txt +++ /dev/null @@ -1,61 +0,0 @@ -# Generated from test.pro. - -##################################################################### -## tst_selftests Test: -##################################################################### - -qt_add_test(tst_selftests - OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../" - SOURCES - ../../../../shared/emulationdetector.h - ../tst_selftests.cpp - INCLUDE_DIRECTORIES - ../../../../shared - PUBLIC_LIBRARIES - Qt::TestPrivate - # special case begin - # These lines need to be commented out as they need to be enabled - # COMPILE_OPTIONS - # conditionally - # --cs-exclude-file-abs-wildcard=${QT_SOURCE_TREE}/* - # --cs-include-file-abs-wildcard=*/src/testlib/* - # --cs-mcc - # --cs-mcdc - # LINK_OPTIONS - # "$$COVERAGE_OPTIONS" - # special case end -) - -file(GLOB resource_glob_0 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "../expected_*") -foreach(file IN LISTS resource_glob_0) - set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/${file}" PROPERTIES QT_RESOURCE_ALIAS "${file}") -endforeach() - -# Resources: -set(qmake_expected_files_resource_files - ${resource_glob_0} -) - -qt_add_resource(tst_selftests "qmake_expected_files" - PREFIX - "/" - BASE - "${CMAKE_CURRENT_SOURCE_DIR}" # special case - FILES - ${qmake_expected_files_resource_files} -) - - -## Scopes: -##################################################################### - -#### Keys ignored in scope 5:.:.:test.pro:NOT ANDROID AND NOT WINRT AND for(file,SUBPROGRAMS): -# TEST_HELPER_INSTALLS = "../$${file}/$${file}" - -#### Keys ignored in scope 7:.:..:../selftests.pri:TARGET Qt::Gui: -# SUBPROGRAMS = "keyboard" "mouse" - -# special case begin -qt_apply_testlib_coverage_options(tst_selftests) -# special case end - diff --git a/tests/auto/testlib/selftests/test/test.pro b/tests/auto/testlib/selftests/test/test.pro deleted file mode 100644 index fce8e48ca2..0000000000 --- a/tests/auto/testlib/selftests/test/test.pro +++ /dev/null @@ -1,22 +0,0 @@ -CONFIG += testcase -SOURCES += ../tst_selftests.cpp -QT = core testlib-private - -TARGET = ../tst_selftests - -win32 { - CONFIG(debug, debug|release) { - TARGET = ../../debug/tst_selftests -} else { - TARGET = ../../release/tst_selftests - } -} - -expected_files.files = $$files($$PWD/../expected_*) -expected_files.base = $$PWD/.. -RESOURCES += expected_files - -include(../selftests.pri) -!android:!winrt: for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../$${file}/$${file}" - -include($$QT_SOURCE_TREE/src/testlib/selfcover.pri) -- cgit v1.2.3