summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <stephen.kelly@kdab.com>2012-06-23 09:48:19 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-26 11:49:52 +0200
commitc42a0a772911c1743d1f991dd460c1fff7d7e5e1 (patch)
tree695042d899872869a2f8bd67f874e9aec30d21b9
parenta9ba92740670ddbbcb0c68f80ad1a18cf2ff0598 (diff)
Factorize the cmake test infrastructure to be reusable.
This makes it easy to add cmake module tests for all modules. Change-Id: I303bf7674ca6ae7a8544488f96e8e02afbaa6ff0 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
-rw-r--r--mkspecs/features/ctest_testcase.prf51
-rw-r--r--tests/auto/cmake/cmake.pro51
2 files changed, 52 insertions, 50 deletions
diff --git a/mkspecs/features/ctest_testcase.prf b/mkspecs/features/ctest_testcase.prf
new file mode 100644
index 0000000000..46c175ec5f
--- /dev/null
+++ b/mkspecs/features/ctest_testcase.prf
@@ -0,0 +1,51 @@
+
+CMAKE_VERSION = $$system(cmake --version)
+
+check.commands =
+isEmpty(CMAKE_VERSION) {
+ message("cmake executable not found. Not running CMake unit tests")
+} else {
+ CTEST_VERSION = $$system(ctest --version)
+ isEmpty(CTEST_VERSION) {
+ message("ctest executable not found. Not running CMake unit tests")
+ } else {
+ CMAKE_VERSION = $$last(CMAKE_VERSION)
+ CMAKE_VERSION_MAJOR = $$section(CMAKE_VERSION, ., 0, 0)
+ CMAKE_VERSION_MINOR = $$section(CMAKE_VERSION, ., 1, 1)
+ CMAKE_VERSION_PATCH = $$section(CMAKE_VERSION, ., 2, 2)
+
+ VERSION_OK =
+ greaterThan(CMAKE_VERSION_MAJOR, 2) {
+ VERSION_OK = 1
+ } else:greaterThan(CMAKE_VERSION_MAJOR, 1):greaterThan(CMAKE_VERSION_MINOR, 8) {
+ VERSION_OK = 1
+ } else:greaterThan(CMAKE_VERSION_MAJOR, 1):greaterThan(CMAKE_VERSION_MINOR, 7):greaterThan(CMAKE_VERSION_PATCH, 2) {
+ VERSION_OK = 1
+ }
+
+ isEmpty(VERSION_OK) {
+ message("cmake $$CMAKE_VERSION is too old for this test.")
+ } else {
+ SET = set
+ equals(QMAKE_DIR_SEP, "/"):SET = export
+
+ CMAKE_BUILD_TYPE = Debug
+ CONFIG(release, debug|release):CMAKE_BUILD_TYPE = Release
+
+ BUILD_DIR = $$replace($$list($$OUT_PWD/build), /, $$QMAKE_DIR_SEP)
+
+ check.commands = \
+ cd . && $$SET CMAKE_PREFIX_PATH=$$[QT_INSTALL_PREFIX] && \
+ $(MKDIR) $$BUILD_DIR && cd $$BUILD_DIR && \
+ cmake $$_PRO_FILE_PWD_ -DCMAKE_BUILD_TYPE=$${CMAKE_BUILD_TYPE} && \
+ $(TESTRUNNER) ctest --output-on-failure
+
+ }
+ }
+}
+
+insignificant_test:!isEmpty(check.commands) {
+ check.commands = -$${check.commands}
+}
+
+QMAKE_EXTRA_TARGETS *= check
diff --git a/tests/auto/cmake/cmake.pro b/tests/auto/cmake/cmake.pro
index 0fe999b957..bf2dbcb772 100644
--- a/tests/auto/cmake/cmake.pro
+++ b/tests/auto/cmake/cmake.pro
@@ -1,54 +1,5 @@
-CMAKE_VERSION = $$system(cmake --version)
-
# Cause make to do nothing.
TEMPLATE = subdirs
-check.commands =
-isEmpty(CMAKE_VERSION) {
- message("cmake executable not found. Not running CMake unit tests")
-} else {
- CTEST_VERSION = $$system(ctest --version)
- isEmpty(CTEST_VERSION) {
- message("ctest executable not found. Not running CMake unit tests")
- } else {
- CMAKE_VERSION = $$last(CMAKE_VERSION)
- CMAKE_VERSION_MAJOR = $$section(CMAKE_VERSION, ., 0, 0)
- CMAKE_VERSION_MINOR = $$section(CMAKE_VERSION, ., 1, 1)
- CMAKE_VERSION_PATCH = $$section(CMAKE_VERSION, ., 2, 2)
-
- VERSION_OK =
- greaterThan(CMAKE_VERSION_MAJOR, 2) {
- VERSION_OK = 1
- } else:greaterThan(CMAKE_VERSION_MAJOR, 1):greaterThan(CMAKE_VERSION_MINOR, 8) {
- VERSION_OK = 1
- } else:greaterThan(CMAKE_VERSION_MAJOR, 1):greaterThan(CMAKE_VERSION_MINOR, 7):greaterThan(CMAKE_VERSION_PATCH, 2) {
- VERSION_OK = 1
- }
-
- isEmpty(VERSION_OK) {
- message("cmake $$CMAKE_VERSION is too old for this test.")
- } else {
- SET = set
- equals(QMAKE_DIR_SEP, "/"):SET = export
-
- CMAKE_BUILD_TYPE = Debug
- CONFIG(release, debug|release):CMAKE_BUILD_TYPE = Release
-
- BUILD_DIR = $$replace($$list($$OUT_PWD/build), /, $$QMAKE_DIR_SEP)
-
- check.commands = \
- cd . && $$SET CMAKE_PREFIX_PATH=$$[QT_INSTALL_PREFIX] && \
- $(MKDIR) $$BUILD_DIR && cd $$BUILD_DIR && \
- cmake $$_PRO_FILE_PWD_ -DCMAKE_BUILD_TYPE=$${CMAKE_BUILD_TYPE} && \
- $(TESTRUNNER) ctest --output-on-failure
-
- }
- }
-}
-
-insignificant_test:!isEmpty(check.commands) {
- check.commands = -$${check.commands}
-}
-
-QMAKE_EXTRA_TARGETS *= check
+CONFIG += ctest_testcase