From b99e2f653b3268908f357653f80ec7128c699dc8 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Fri, 29 May 2015 21:15:26 +0200 Subject: [PATCH] build a combined executable for all tests --- tests/BooleanExpression.cpp | 2 +- tests/CMakeLists.txt | 67 ++++++++++++++++++++++++++----------- tests/CustomQuery.cpp | 2 +- tests/Function.cpp | 2 +- tests/Insert.cpp | 2 +- tests/Interpret.cpp | 2 +- tests/Minimalistic.cpp | 3 +- tests/Prepared.cpp | 2 +- tests/Remove.cpp | 2 +- tests/Result.cpp | 2 +- tests/Select.cpp | 2 +- tests/SelectType.cpp | 2 +- tests/Union.cpp | 2 +- tests/Update.cpp | 2 +- tests/With.cpp | 2 +- 15 files changed, 62 insertions(+), 34 deletions(-) diff --git a/tests/BooleanExpression.cpp b/tests/BooleanExpression.cpp index c8b5c20e..5f55d2e3 100644 --- a/tests/BooleanExpression.cpp +++ b/tests/BooleanExpression.cpp @@ -29,7 +29,7 @@ #include -int main() +int BooleanExpression(int, char**) { MockDb db = {}; test::TabBar t; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index eab34265..d6a594a4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,25 +1,52 @@ +# Copyright (c) 2013-2015, Roland Bock +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# Redistributions in binary form must reproduce the above copyright notice, this +# list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -macro (build_and_run arg) - # Add headers to sources to enable file browsing in IDEs - include_directories("${CMAKE_BINARY_DIR}/tests") - add_executable("${arg}" "${arg}.cpp" ${sqlpp_headers} "${CMAKE_CURRENT_LIST_DIR}/Sample.h") - add_test("${arg}" "${CMAKE_BINARY_DIR}/tests/${arg}") -endmacro () +set(test_names + BooleanExpression + CustomQuery + Interpret + Insert + Remove + Update + Select + SelectType + Function + Prepared + Minimalistic + Result + Union + With + ) -build_and_run(BooleanExpression) -build_and_run(CustomQuery) -build_and_run(Interpret) -build_and_run(Insert) -build_and_run(Remove) -build_and_run(Update) -build_and_run(Select) -build_and_run(SelectType) -build_and_run(Function) -build_and_run(Prepared) -build_and_run(Minimalistic) -build_and_run(Result) -build_and_run(Union) -build_and_run(With) +create_test_sourcelist(test_sources test_main.cpp ${test_names}) +add_executable(sqlpp11_tests ${test_sources}) + +foreach(test IN LISTS test_names) + add_test(NAME sqlpp11.tests.${test} + COMMAND sqlpp11_tests ${test} + ) +endforeach() # if you want to use the generator, you can do something like this: #find_package(PythonInterp REQUIRED) diff --git a/tests/CustomQuery.cpp b/tests/CustomQuery.cpp index 73ef6b77..f8781145 100644 --- a/tests/CustomQuery.cpp +++ b/tests/CustomQuery.cpp @@ -29,7 +29,7 @@ #include #include -int main() +int CustomQuery(int, char**) { MockDb db = {}; MockDb::_serializer_context_t printer; diff --git a/tests/Function.cpp b/tests/Function.cpp index 891e16d8..4d1b2679 100644 --- a/tests/Function.cpp +++ b/tests/Function.cpp @@ -34,7 +34,7 @@ SQLPP_ALIAS_PROVIDER(kaesekuchen) -int main() +int Function(int, char**) { MockDb db = {}; test::TabFoo f; diff --git a/tests/Insert.cpp b/tests/Insert.cpp index 5f7e849a..76dafa4b 100644 --- a/tests/Insert.cpp +++ b/tests/Insert.cpp @@ -31,7 +31,7 @@ #include -int main() +int Insert(int, char**) { MockDb db; MockDb::_serializer_context_t printer; diff --git a/tests/Interpret.cpp b/tests/Interpret.cpp index 715e2822..d2a597f6 100644 --- a/tests/Interpret.cpp +++ b/tests/Interpret.cpp @@ -29,7 +29,7 @@ #include -int main() +int Interpret(int, char**) { MockDb db = {}; MockDb::_serializer_context_t printer; diff --git a/tests/Minimalistic.cpp b/tests/Minimalistic.cpp index c30384c0..78b086a5 100644 --- a/tests/Minimalistic.cpp +++ b/tests/Minimalistic.cpp @@ -1,5 +1,6 @@ #include -int main() +int Minimalistic(int, char**) { + return 0; } diff --git a/tests/Prepared.cpp b/tests/Prepared.cpp index 4e391a53..af5eadfd 100644 --- a/tests/Prepared.cpp +++ b/tests/Prepared.cpp @@ -29,7 +29,7 @@ #include #include -int main() +int Prepared(int, char**) { MockDb db = {}; //test::TabFoo f; diff --git a/tests/Remove.cpp b/tests/Remove.cpp index 4fe220d9..e8092462 100644 --- a/tests/Remove.cpp +++ b/tests/Remove.cpp @@ -30,7 +30,7 @@ #include "is_regular.h" -int main() +int Remove(int, char**) { MockDb db; MockDb::_serializer_context_t printer; diff --git a/tests/Result.cpp b/tests/Result.cpp index daa918df..3bee2429 100644 --- a/tests/Result.cpp +++ b/tests/Result.cpp @@ -32,7 +32,7 @@ static_assert(not sqlpp::enforce_null_result_treatment_t::value, "MockDb interprets NULL as trivial"); static_assert(sqlpp::enforce_null_result_treatment_t::value, "MockDb does not interpret NULL as trivial"); -int main() +int Result(int, char**) { MockDb db = {}; EnforceDb edb {}; diff --git a/tests/Select.cpp b/tests/Select.cpp index 8d82c1b2..460a85b3 100644 --- a/tests/Select.cpp +++ b/tests/Select.cpp @@ -43,7 +43,7 @@ int64_t getColumn(Db&& db, const Column& column) return 0; } -int main() +int Select(int, char**) { MockDb db = {}; MockDb::_serializer_context_t printer; diff --git a/tests/SelectType.cpp b/tests/SelectType.cpp index 67b3f689..4afc20b7 100644 --- a/tests/SelectType.cpp +++ b/tests/SelectType.cpp @@ -41,7 +41,7 @@ namespace alias SQLPP_ALIAS_PROVIDER(right) } -int main() +int SelectType(int, char**) { MockDb db = {}; MockDb::_serializer_context_t printer; diff --git a/tests/Union.cpp b/tests/Union.cpp index 4a3d54ad..caa7f9ff 100644 --- a/tests/Union.cpp +++ b/tests/Union.cpp @@ -29,7 +29,7 @@ #include #include -int main() +int Union(int, char**) { MockDb db; MockDb::_serializer_context_t printer; diff --git a/tests/Update.cpp b/tests/Update.cpp index 4cc7f455..da93415a 100644 --- a/tests/Update.cpp +++ b/tests/Update.cpp @@ -29,7 +29,7 @@ #include "MockDb.h" #include "is_regular.h" -int main() +int Update(int, char**) { MockDb db; MockDb::_serializer_context_t printer; diff --git a/tests/With.cpp b/tests/With.cpp index cde6b262..5c251293 100644 --- a/tests/With.cpp +++ b/tests/With.cpp @@ -29,7 +29,7 @@ #include #include -int main() +int With(int, char**) { MockDb db; MockDb::_serializer_context_t printer;