From 03b9b423b07a21916b8204047dbc34bf74f914fe Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 29 Oct 2012 15:46:26 +0100 Subject: Generate instances of types in the CMake tests. All modules currently have a test_modules CMake test. The new module_includes test has very similar requirements, and can obsolete the hand-maintained test_modules tests in all modules. After all test_modules have been removed in other repos, the module_includes test can be renamed to that name. The types chosen need to have a constructor which can be invoked with no arguments. QtConcurrent has no public classes which fit that description so it is still tested separately Change-Id: Id7929cd32b3112c293cbf5e6964cc894a697f9b1 Reviewed-by: Rohan McGovern --- src/corelib/Qt5CTestMacros.cmake | 7 +- tests/auto/cmake/CMakeLists.txt | 9 ++- .../cmake/test_concurrent_module/CMakeLists.txt | 22 ++++++ tests/auto/cmake/test_concurrent_module/main.cpp | 53 ++++++++++++++ tests/auto/cmake/test_modules/CMakeLists.txt | 44 ------------ tests/auto/cmake/test_modules/main.cpp | 82 ---------------------- 6 files changed, 85 insertions(+), 132 deletions(-) create mode 100644 tests/auto/cmake/test_concurrent_module/CMakeLists.txt create mode 100644 tests/auto/cmake/test_concurrent_module/main.cpp delete mode 100644 tests/auto/cmake/test_modules/CMakeLists.txt delete mode 100644 tests/auto/cmake/test_modules/main.cpp diff --git a/src/corelib/Qt5CTestMacros.cmake b/src/corelib/Qt5CTestMacros.cmake index 0db83e3fb3..715ad9356e 100644 --- a/src/corelib/Qt5CTestMacros.cmake +++ b/src/corelib/Qt5CTestMacros.cmake @@ -102,6 +102,7 @@ function(test_module_includes) set(all_args ${ARGN}) set(includes_string "") + set(instances_string "") while(all_args) list(GET all_args 0 qtmodule) list(GET all_args 1 qtinclude) @@ -113,6 +114,10 @@ function(test_module_includes) #include #include " ) + set(instances_string + "${instances_string} + ${qtinclude} local${qtinclude}; + ") endwhile() file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/module_includes/main.cpp" @@ -120,7 +125,7 @@ function(test_module_includes) ${includes_string} - int main(int, char **) { return 0; }\n" + int main(int, char **) { ${instances_string} return 0; }\n" ) add_test(module_includes ${CMAKE_CTEST_COMMAND} diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 367832efb6..46dcdcca2b 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -74,7 +74,6 @@ if (NOT WIN32) expect_pass(test_add_resources_delayed_file) endif() expect_pass(test_private_includes) -expect_pass(test_modules) expect_pass(test_testlib_definitions) expect_pass(test_json_plugin_includes) @@ -92,23 +91,23 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E copy set(qt_module_includes Core QObject - Concurrent QtConcurrentRun Gui QImage Widgets QWidget Network QHostInfo - OpenGL QGLContext + OpenGL QGLBuffer Sql QSqlError - Test QSignalSpy + Test QTestEventList Xml QDomDocument PrintSupport QPrintDialog ) if (UNIX AND NOT APPLE AND NOT QNXNTO) list(APPEND qt_module_includes - DBus QDBusConnection + DBus QDBusMessage ) endif() test_module_includes( ${qt_module_includes} ) +expect_pass(test_concurrent_module) diff --git a/tests/auto/cmake/test_concurrent_module/CMakeLists.txt b/tests/auto/cmake/test_concurrent_module/CMakeLists.txt new file mode 100644 index 0000000000..efd7b725ea --- /dev/null +++ b/tests/auto/cmake/test_concurrent_module/CMakeLists.txt @@ -0,0 +1,22 @@ + +cmake_minimum_required(VERSION 2.8) + +project(test_concurrent_module) + +find_package(Qt5Concurrent REQUIRED) + +include_directories( + ${Qt5Concurrent_INCLUDE_DIRS} +) + +add_definitions( + ${Qt5Concurrent_DEFINITIONS} +) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") + +add_executable(mainapp main.cpp) + +target_link_libraries(mainapp + ${Qt5Concurrent_LIBRARIES} +) diff --git a/tests/auto/cmake/test_concurrent_module/main.cpp b/tests/auto/cmake/test_concurrent_module/main.cpp new file mode 100644 index 0000000000..e5693be9bf --- /dev/null +++ b/tests/auto/cmake/test_concurrent_module/main.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + QByteArray bytearray = "hello world"; + QtConcurrent::run(bytearray, &QByteArray::split, ','); + + return 0; +} diff --git a/tests/auto/cmake/test_modules/CMakeLists.txt b/tests/auto/cmake/test_modules/CMakeLists.txt deleted file mode 100644 index 30a726b10f..0000000000 --- a/tests/auto/cmake/test_modules/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ - -cmake_minimum_required(VERSION 2.8) - -project(test_modules) - -set(qtbase_modules - Core - Concurrent - Gui - Widgets - Network - OpenGL - Sql - Test - Xml - PrintSupport -) - -if (UNIX AND NOT APPLE AND NOT QNXNTO) - add_definitions(-DEXPECT_DBUS_AVAILABLE) - list(APPEND qtbase_modules DBus) -endif() - -foreach(_module ${qtbase_modules}) - find_package(Qt5${_module} REQUIRED) - - include_directories( - ${Qt5${_module}_INCLUDE_DIRS} - ) - - add_definitions( - ${Qt5${_module}_DEFINITIONS} - ) -endforeach() - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") - -add_executable(mainapp main.cpp) - -foreach(_module ${qtbase_modules}) - target_link_libraries(mainapp - ${Qt5${_module}_LIBRARIES} - ) -endforeach() diff --git a/tests/auto/cmake/test_modules/main.cpp b/tests/auto/cmake/test_modules/main.cpp deleted file mode 100644 index 2bb885dd5c..0000000000 --- a/tests/auto/cmake/test_modules/main.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly -** Contact: http://www.qt-project.org/legal -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef EXPECT_DBUS_AVAILABLE -#include -#endif - -int main(int argc, char **argv) -{ - QObject object; - - QtConcurrent::BlockSizeManager blockSizeManager(42); - - QHostAddress hostAddress; - - QGLBuffer glBuffer; - - QSqlQuery sqlQuery; - - QSignalSpy signalSpy(&object, SIGNAL(destroyed())); - - QWidget widget; - - QDomDocument domDocument; - - QPrintDialog printDialog; - -#ifdef EXPECT_DBUS_AVAILABLE - QDBusMessage dBusMessage; -#endif - - return 0; -} -- cgit v1.2.3