aboutsummaryrefslogtreecommitdiffstats
path: root/share/qtcreator/templates
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2019-05-20 10:31:53 +0200
committerChristian Stenger <christian.stenger@qt.io>2019-05-23 12:19:36 +0000
commita0b94384a6189543050c270df002a1e6c4d3de86 (patch)
tree57457228ca3f3e416d8397b197773cfde8d95dde /share/qtcreator/templates
parentbaca0a5d329c253ba238b3c57e427d2f57e27dbd (diff)
AutoTest: Add wizard for Boost test
Task-number: QTCREATORBUG-21169 Change-Id: I77936e3e47911cf724705c858b9897c74875c41e Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'share/qtcreator/templates')
-rw-r--r--share/qtcreator/templates/wizards/autotest/files/tst.pro20
-rw-r--r--share/qtcreator/templates/wizards/autotest/files/tst.qbs28
-rw-r--r--share/qtcreator/templates/wizards/autotest/files/tst.txt16
-rw-r--r--share/qtcreator/templates/wizards/autotest/files/tst_main.cpp12
-rw-r--r--share/qtcreator/templates/wizards/autotest/wizard.json24
5 files changed, 98 insertions, 2 deletions
diff --git a/share/qtcreator/templates/wizards/autotest/files/tst.pro b/share/qtcreator/templates/wizards/autotest/files/tst.pro
index a973d1a9cb..1d59f9c05f 100644
--- a/share/qtcreator/templates/wizards/autotest/files/tst.pro
+++ b/share/qtcreator/templates/wizards/autotest/files/tst.pro
@@ -44,3 +44,23 @@ HEADERS += \\
SOURCES += \\
%{MainCppName}
@endif
+@if "%{TestFrameWork}" == "BoostTest"
+TEMPLATE = app
+CONFIG -= qt
+CONFIG -= app_bundle
+CONFIG += console
+
+isEmpty(BOOST_INCLUDE_DIR): BOOST_INCLUDE_DIR=$$(BOOST_INCLUDE_DIR)
+@if "%{BoostIncDir}" != ""
+# set by Qt Creator wizard
+isEmpty(BOOST_INCLUDE_DIR): BOOST_INCLUDE_DIR="%{BoostIncDir}"
+@endif
+!isEmpty(BOOST_INCLUDE_DIR): INCLUDEPATH *= $${BOOST_INCLUDE_DIR}
+
+isEmpty(BOOST_INCLUDE_DIR): {
+ message("BOOST_INCLUDE_DIR is not set, assuming Boost can be found automatically in your system")
+}
+
+SOURCES += \\
+ %{MainCppName}
+@endif
diff --git a/share/qtcreator/templates/wizards/autotest/files/tst.qbs b/share/qtcreator/templates/wizards/autotest/files/tst.qbs
index 14d277a429..92a0656d65 100644
--- a/share/qtcreator/templates/wizards/autotest/files/tst.qbs
+++ b/share/qtcreator/templates/wizards/autotest/files/tst.qbs
@@ -3,6 +3,10 @@ import qbs
import qbs.Environment
import "googlecommon.js" as googleCommon
@endif
+@if "%{TestFrameWork}" == "BoostTest"
+import qbs.Environment
+import qbs.File
+@endif
CppApplication {
@if "%{TestFrameWork}" == "QtTest"
@@ -72,4 +76,28 @@ CppApplication {
cpp.defines: base.concat("QUICK_TEST_SOURCE_DIR=\\"" + path + "\\"")
@endif
+@if "%{TestFrameWork}" == "BoostTest"
+ type: "application"
+
+ property string boostIncDir: {
+ if (typeof Environment.getEnv("BOOST_INCLUDE_DIR") !== 'undefined')
+ return Environment.getEnv("BOOST_INCLUDE_DIR");
+ return "%{BoostIncDir}"; // set by Qt Creator wizard
+ }
+
+ Properties {
+ condition: boostIncDir && File.exists(boostIncDir)
+ cpp.includePaths: [boostIncDir];
+ }
+
+ condition: {
+ if (!boostIncDir)
+ console.log("BOOST_INCLUDE_DIR is not set, assuming Boost can be "
+ + "found automatically in your system");
+ return true;
+ }
+
+ files: [ "%{MainCppName}" ]
+
+@endif
}
diff --git a/share/qtcreator/templates/wizards/autotest/files/tst.txt b/share/qtcreator/templates/wizards/autotest/files/tst.txt
index 239e7087f8..150fc1d632 100644
--- a/share/qtcreator/templates/wizards/autotest/files/tst.txt
+++ b/share/qtcreator/templates/wizards/autotest/files/tst.txt
@@ -75,3 +75,19 @@ add_test(${PROJECT_NAME} COMMAND ${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads)
@endif
+@if "%{TestFrameWork}" == "BoostTest"
+SET(CMAKE_INCLUDE_CURRENT_DIR ON)
+ENABLE_TESTING()
+
+add_executable(${PROJECT_NAME} %{MainCppName})
+add_test(${PROJECT_NAME} COMMAND ${PROJECT_NAME})
+
+if ($ENV{BOOST_INC_DIR})
+ set(BOOST_INC_DIR $ENV{BOOST_INC_DIR})
+else ()
+ set(BOOST_INC_DIR "%{BoostIncDir}") # set by Qt Creator wizard
+endif ()
+if (EXISTS ${BOOST_INC_DIR})
+ include_directories(${BOOST_INC_DIR})
+endif ()
+@endif
diff --git a/share/qtcreator/templates/wizards/autotest/files/tst_main.cpp b/share/qtcreator/templates/wizards/autotest/files/tst_main.cpp
index d918350551..923fad9f9b 100644
--- a/share/qtcreator/templates/wizards/autotest/files/tst_main.cpp
+++ b/share/qtcreator/templates/wizards/autotest/files/tst_main.cpp
@@ -2,7 +2,8 @@
#include <QtQuickTest/quicktest.h>
QUICK_TEST_MAIN(example)
-@else
+@endif
+@if "%{TestFrameWork}" == "GTest"
%{Cpp:LicenseTemplate}\
#include "%{TestCaseFileWithHeaderSuffix}"
@@ -14,3 +15,12 @@ int main(int argc, char *argv[])
return RUN_ALL_TESTS();
}
@endif
+@if "%{TestFrameWork}" == "BoostTest"
+#define BOOST_TEST_MODULE %{TestSuiteName}
+#include <boost/test/included/unit_test.hpp>
+
+BOOST_AUTO_TEST_CASE( %{TestCaseName} )
+{
+ BOOST_TEST( true /* test assertion */ );
+}
+@endif
diff --git a/share/qtcreator/templates/wizards/autotest/wizard.json b/share/qtcreator/templates/wizards/autotest/wizard.json
index fd56df0578..efaa6b36a0 100644
--- a/share/qtcreator/templates/wizards/autotest/wizard.json
+++ b/share/qtcreator/templates/wizards/autotest/wizard.json
@@ -87,6 +87,10 @@
{
"trKey": "Qt Quick Test",
"value": "QtQuickTest"
+ },
+ {
+ "trKey": "Boost Test",
+ "value": "BoostTest"
}
]
@@ -102,6 +106,14 @@
}
},
{
+ "name": "TestSuiteName",
+ "trDisplayName": "Test suite name:",
+ "visible": "%{JS: value('TestFrameWork') === 'BoostTest'}",
+ "mandatory": true,
+ "type": "LineEdit",
+ "data": { "validator": "^[a-zA-Z_0-9]+$" }
+ },
+ {
"name": "TestCaseName",
"trDisplayName": "Test case name:",
"mandatory": true,
@@ -152,6 +164,16 @@
}
},
{
+ "name": "BoostIncDir",
+ "trDisplayName": "Boost include dir (optional):",
+ "visible": "%{JS: value('TestFrameWork') == 'BoostTest'}",
+ "mandatory": false,
+ "type": "PathChooser",
+ "data": {
+ "kind": "existingDirectory"
+ }
+ },
+ {
"name": "BuildSystem",
"trDisplayName": "Build system:",
"type": "ComboBox",
@@ -250,7 +272,7 @@
{
"source": "files/tst_main.cpp",
"target": "%{MainCppName}",
- "condition": "%{JS: ['GTest', 'QtQuickTest'].indexOf(value('TestFrameWork')) >= 0}",
+ "condition": "%{JS: ['GTest', 'QtQuickTest', 'BoostTest'].indexOf(value('TestFrameWork')) >= 0}",
"openInEditor": true
},
{