From 7efce45f7d5b8e9d7989dff637219fe8435aa09c Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Fri, 29 May 2015 17:52:34 +0200 Subject: [PATCH 01/10] update .travis.yml --- .travis.yml | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index 24420177..e19ad40a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,39 +2,42 @@ language: cpp os: - linux + - osx compiler: - # - clang # disabled clang due to missing libc++ + - clang - gcc +env: + - CONFIG=Release + - CONFIG=Debug + notifications: email: on_success: change on_failure: always -before_install: - # install boost 1.50 (headers only), travis currently offers 1.46 and 1.48 - - wget http://sourceforge.net/projects/boost/files/boost/1.50.0/boost_1_50_0.tar.bz2/download -O /tmp/boost.tar.bz2 - - mkdir -p temp - - cd temp - - tar jxf /tmp/boost.tar.bz2 boost_1_50_0/boost # extract headers only - - sudo mkdir -p /usr/local/include/ - - sudo ln -s $PWD/boost_1_50_0/boost /usr/local/include - - cd .. - #install g++-4.8 - - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - - sudo apt-get update - - if [ "$CXX" = "g++" ]; then sudo apt-get install g++-4.8; fi - - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi - install: - - "mkdir -p $TRAVIS_BUILD_DIR/build/scripts" - - "cd $TRAVIS_BUILD_DIR/build/scripts" - - "cmake $TRAVIS_BUILD_DIR" + - CMAKE_VERSION_MM=3.2 + - CMAKE_VERSION_FULL=$CMAKE_VERSION_MM.2 + - if [ "$TRAVIS_OS_NAME" == "linux" ]; then + sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + && sudo add-apt-repository -y ppa:apokluda/boost1.53 + && sudo apt-get update -qq + && sudo apt-get install -qq g++-4.8 libboost1.53-dev --no-install-recommends + && sudo update-alternatives --quiet --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6 --slave /usr/bin/gcov gcov /usr/bin/gcov-4.6 + && sudo update-alternatives --quiet --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8 --slave /usr/bin/gcov gcov /usr/bin/gcov-4.8 + && sudo update-alternatives --quiet --set gcc /usr/bin/gcc-4.8 + && wget http://www.cmake.org/files/v${CMAKE_VERSION_MM}/cmake-${CMAKE_VERSION_FULL}-Linux-x86_64.sh + && sudo sh cmake-${CMAKE_VERSION_FULL}-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir; + fi + - if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install boost cmake; fi + +before_script: + - mkdir build + - cd build + - cmake .. -DCMAKE_BUILD_TYPE=$CONFIG script: - - "cd $TRAVIS_BUILD_DIR/build/scripts" - - "make -j3" - # test compile-time constraints - - "make test_sqlpp_constraints" - + - cmake --build . --config $CONFIG + - ctest --output-on-failure From 5692a71c38a330b0a87280962da1de8e37fb8e13 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Fri, 29 May 2015 20:27:38 +0200 Subject: [PATCH 02/10] don't tell clang which standard library to use --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f5266c2..f9384b48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ enable_testing() message(STATUS "Using ${CMAKE_CXX_COMPILER} (compiler id: ${CMAKE_CXX_COMPILER_ID})") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ -Wall ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "-std=c++11 -Wall ${CMAKE_CXX_FLAGS}") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(CMAKE_CXX_FLAGS "-std=c++11 -Wall ${CMAKE_CXX_FLAGS}") endif () From 036d63e6cfb1138d78df471e8926a428842bdb93 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Fri, 29 May 2015 20:40:38 +0200 Subject: [PATCH 03/10] drop suffix 'Test' from tests --- ...pressionTest.cpp => BooleanExpression.cpp} | 0 tests/CMakeLists.txt | 26 +++++++++---------- .../{CustomQueryTest.cpp => CustomQuery.cpp} | 0 tests/{FunctionTest.cpp => Function.cpp} | 0 tests/{InsertTest.cpp => Insert.cpp} | 0 tests/{InterpretTest.cpp => Interpret.cpp} | 0 tests/{PreparedTest.cpp => Prepared.cpp} | 0 tests/{RemoveTest.cpp => Remove.cpp} | 0 tests/{ResultTest.cpp => Result.cpp} | 0 tests/{SelectTest.cpp => Select.cpp} | 0 tests/{SelectTypeTest.cpp => SelectType.cpp} | 0 tests/{UnionTest.cpp => Union.cpp} | 0 tests/{UpdateTest.cpp => Update.cpp} | 0 tests/{WithTest.cpp => With.cpp} | 0 14 files changed, 13 insertions(+), 13 deletions(-) rename tests/{BooleanExpressionTest.cpp => BooleanExpression.cpp} (100%) rename tests/{CustomQueryTest.cpp => CustomQuery.cpp} (100%) rename tests/{FunctionTest.cpp => Function.cpp} (100%) rename tests/{InsertTest.cpp => Insert.cpp} (100%) rename tests/{InterpretTest.cpp => Interpret.cpp} (100%) rename tests/{PreparedTest.cpp => Prepared.cpp} (100%) rename tests/{RemoveTest.cpp => Remove.cpp} (100%) rename tests/{ResultTest.cpp => Result.cpp} (100%) rename tests/{SelectTest.cpp => Select.cpp} (100%) rename tests/{SelectTypeTest.cpp => SelectType.cpp} (100%) rename tests/{UnionTest.cpp => Union.cpp} (100%) rename tests/{UpdateTest.cpp => Update.cpp} (100%) rename tests/{WithTest.cpp => With.cpp} (100%) diff --git a/tests/BooleanExpressionTest.cpp b/tests/BooleanExpression.cpp similarity index 100% rename from tests/BooleanExpressionTest.cpp rename to tests/BooleanExpression.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4461ce0d..eab34265 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,20 +6,20 @@ macro (build_and_run arg) add_test("${arg}" "${CMAKE_BINARY_DIR}/tests/${arg}") endmacro () -build_and_run(BooleanExpressionTest) -build_and_run(CustomQueryTest) -build_and_run(InterpretTest) -build_and_run(InsertTest) -build_and_run(RemoveTest) -build_and_run(UpdateTest) -build_and_run(SelectTest) -build_and_run(SelectTypeTest) -build_and_run(FunctionTest) -build_and_run(PreparedTest) +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(ResultTest) -build_and_run(UnionTest) -build_and_run(WithTest) +build_and_run(Result) +build_and_run(Union) +build_and_run(With) # if you want to use the generator, you can do something like this: #find_package(PythonInterp REQUIRED) diff --git a/tests/CustomQueryTest.cpp b/tests/CustomQuery.cpp similarity index 100% rename from tests/CustomQueryTest.cpp rename to tests/CustomQuery.cpp diff --git a/tests/FunctionTest.cpp b/tests/Function.cpp similarity index 100% rename from tests/FunctionTest.cpp rename to tests/Function.cpp diff --git a/tests/InsertTest.cpp b/tests/Insert.cpp similarity index 100% rename from tests/InsertTest.cpp rename to tests/Insert.cpp diff --git a/tests/InterpretTest.cpp b/tests/Interpret.cpp similarity index 100% rename from tests/InterpretTest.cpp rename to tests/Interpret.cpp diff --git a/tests/PreparedTest.cpp b/tests/Prepared.cpp similarity index 100% rename from tests/PreparedTest.cpp rename to tests/Prepared.cpp diff --git a/tests/RemoveTest.cpp b/tests/Remove.cpp similarity index 100% rename from tests/RemoveTest.cpp rename to tests/Remove.cpp diff --git a/tests/ResultTest.cpp b/tests/Result.cpp similarity index 100% rename from tests/ResultTest.cpp rename to tests/Result.cpp diff --git a/tests/SelectTest.cpp b/tests/Select.cpp similarity index 100% rename from tests/SelectTest.cpp rename to tests/Select.cpp diff --git a/tests/SelectTypeTest.cpp b/tests/SelectType.cpp similarity index 100% rename from tests/SelectTypeTest.cpp rename to tests/SelectType.cpp diff --git a/tests/UnionTest.cpp b/tests/Union.cpp similarity index 100% rename from tests/UnionTest.cpp rename to tests/Union.cpp diff --git a/tests/UpdateTest.cpp b/tests/Update.cpp similarity index 100% rename from tests/UpdateTest.cpp rename to tests/Update.cpp diff --git a/tests/WithTest.cpp b/tests/With.cpp similarity index 100% rename from tests/WithTest.cpp rename to tests/With.cpp From b99e2f653b3268908f357653f80ec7128c699dc8 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Fri, 29 May 2015 21:15:26 +0200 Subject: [PATCH 04/10] 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; From ec20a8a627a9e56fce6091f75bbde94c2a5b7697 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Fri, 29 May 2015 21:31:32 +0200 Subject: [PATCH 05/10] build examples to a single, combined executable --- examples/CMakeLists.txt | 54 +++++++++++++++++++++++++++++++---------- examples/insert.cpp | 3 ++- examples/ppgen.cpp | 3 ++- examples/remove.cpp | 3 ++- examples/select.cpp | 3 ++- examples/update.cpp | 3 ++- 6 files changed, 51 insertions(+), 18 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 33b8e65f..589a0b52 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,23 +1,51 @@ +# 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 arg) - # Add headers to sources to enable file browsing in IDEs - include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../tests") - add_executable("Sqlpp11Example${arg}" "${arg}.cpp" ${sqlpp_headers} "${CMAKE_CURRENT_SOURCE_DIR}/../tests/MockDb.h" "${CMAKE_CURRENT_LIST_DIR}/Sample.h") - add_test("${arg}" "Sqlpp11Example${arg}") -endmacro () +include_directories(../tests) + +set(example_names + #sample + insert + update + remove + select + ) -#build(sample) -build(insert) -build(update) -build(remove) -build(select) find_package(Boost 1.50) if(Boost_FOUND) - MESSAGE(${Boost_INCLUDE_DIRS}) include_directories(${Boost_INCLUDE_DIRS}) - build(ppgen) + list(APPEND example_names ppgen) endif() +create_test_sourcelist(example_sources example_main.cpp ${example_names}) +add_executable(sqlpp11_examples ${example_sources}) + +foreach(example IN LISTS example_names) + add_test(NAME sqlpp11.examples.${example} + COMMAND sqlpp11_examples ${example} + ) +endforeach() #find_package(PythonInterp REQUIRED) diff --git a/examples/insert.cpp b/examples/insert.cpp index 2cf32f68..6aa85f9c 100644 --- a/examples/insert.cpp +++ b/examples/insert.cpp @@ -27,7 +27,7 @@ #include "MockDb.h" #include -int main() +int insert(int, char**) { MockDb db; @@ -64,4 +64,5 @@ int main() pi.params.feature = true; db(pi); + return 0; } diff --git a/examples/ppgen.cpp b/examples/ppgen.cpp index d865f4e8..48ca5610 100644 --- a/examples/ppgen.cpp +++ b/examples/ppgen.cpp @@ -61,7 +61,7 @@ SQLPP_DECLARE_TABLE( (fatal, bool , SQLPP_NOT_NULL ) ) -int main() +int ppgen(int, char**) { MockDb db; tab_person::tab_person p; @@ -97,4 +97,5 @@ int main() pi.params.feature = true; db(pi); + return 0; } diff --git a/examples/remove.cpp b/examples/remove.cpp index 8bec39c3..3788e7e8 100644 --- a/examples/remove.cpp +++ b/examples/remove.cpp @@ -27,7 +27,7 @@ #include "MockDb.h" #include -int main() +int remove(int, char**) { MockDb db; @@ -37,4 +37,5 @@ int main() db(remove_from(p) .using_(p, q) .where(p.feature == q.id and q.fatal == true)); + return 0; } diff --git a/examples/select.cpp b/examples/select.cpp index 10d756bb..8607f7a1 100644 --- a/examples/select.cpp +++ b/examples/select.cpp @@ -36,7 +36,7 @@ SQLPP_ALIAS_PROVIDER(cheesecake) -int main() +int select(int, char**) { static constexpr bool some_condition = true; static constexpr bool some_other_condition = false; @@ -153,4 +153,5 @@ int main() + return 0; } diff --git a/examples/update.cpp b/examples/update.cpp index e9bad556..ed3de0a2 100644 --- a/examples/update.cpp +++ b/examples/update.cpp @@ -27,7 +27,7 @@ #include "MockDb.h" #include -int main() +int update(int, char**) { MockDb db; @@ -35,4 +35,5 @@ int main() //test::TabFeature q; db(update(p).set(p.feature = 7).where(p.id == 23)); + return 0; } From b8a93a8aa3eb3a10de6a06b2138fcf5d4814ac45 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Fri, 29 May 2015 21:39:03 +0200 Subject: [PATCH 06/10] add constraint tests as test cases --- test_constraints/CMakeLists.txt | 58 +++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/test_constraints/CMakeLists.txt b/test_constraints/CMakeLists.txt index 20e699d9..9f388e28 100644 --- a/test_constraints/CMakeLists.txt +++ b/test_constraints/CMakeLists.txt @@ -1,31 +1,41 @@ -include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../tests") +# 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. -add_custom_target(test_sqlpp_constraints COMMAND true) +include_directories(../tests) function(test_constraint name pattern) + set(test sqlpp11.test_constraints.${name}) + set(target sqlpp11_${name}) + add_executable(${target} EXCLUDE_FROM_ALL ${name}.cpp) + add_test(NAME ${test} + COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target ${target} + ) + set_property(TEST ${test} PROPERTY PASS_REGULAR_EXPRESSION ${pattern}) +endfunction() - add_executable( - "${name}" - EXCLUDE_FROM_ALL - "${name}.cpp" - ) - - add_custom_command(OUTPUT "${name}.out" - COMMAND "${CMAKE_MAKE_PROGRAM}" "${name}" > "${CMAKE_CURRENT_BINARY_DIR}/${name}.out" 2>&1 || true - COMMAND grep "${pattern}" "${CMAKE_CURRENT_BINARY_DIR}/${name}.out" > /dev/null - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${name}.cpp" - COMMENT "${name}" - VERBATIM) - - add_custom_target("test_${name}" DEPENDS "${name}.out" COMMAND true) - - - add_dependencies(test_sqlpp_constraints "test_${name}") - -endfunction(test_constraint) - -test_constraint(count_of_count "count() cannot be used on an aggregate function") -test_constraint(max_of_max "max() cannot be used on an aggregate function") +test_constraint(count_of_count "count\\(\\) cannot be used on an aggregate function") +test_constraint(max_of_max "max\\(\\) cannot be used on an aggregate function") test_constraint(no_conversion_operator_if_null_not_trivial "int i = row.alpha") test_constraint(require_insert "required column is missing") test_constraint(must_not_insert "one assignment is prohibited") From b0453ffb1c228e7050cc5111da37fbcd8719bf0c Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Fri, 29 May 2015 22:10:04 +0200 Subject: [PATCH 07/10] make use of usage requirements --- CMakeLists.txt | 26 +++++++++++--------------- examples/CMakeLists.txt | 3 +-- test_constraints/CMakeLists.txt | 3 +-- tests/CMakeLists.txt | 5 +++++ 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f9384b48..5ceae772 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,25 +22,21 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 3.2 FATAL_ERROR) +project(sqlpp11 VERSION 0.1 LANGUAGES CXX) -# Cygwin does not define WIN32 and warn if not use with this flag -set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required - -project (sqlpp11) enable_testing() -message(STATUS "Using ${CMAKE_CXX_COMPILER} (compiler id: ${CMAKE_CXX_COMPILER_ID})") -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(CMAKE_CXX_FLAGS "-std=c++11 -Wall ${CMAKE_CXX_FLAGS}") -elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - set(CMAKE_CXX_FLAGS "-std=c++11 -Wall ${CMAKE_CXX_FLAGS}") -endif () -set(CMAKE_CXX_FLAGS "-Wconversion -Wpedantic -Wshadow ${CMAKE_CXX_FLAGS}") +add_library(sqlpp11 INTERFACE) + +target_include_directories(sqlpp11 INTERFACE + $ + ) + +target_compile_features(sqlpp11 INTERFACE + cxx_variadic_templates + ) -set(include_dir "${PROJECT_SOURCE_DIR}/include") -file(GLOB_RECURSE sqlpp_headers "${include_dir}/*.h") -include_directories("${include_dir}") add_subdirectory(tests) add_subdirectory(test_constraints) add_subdirectory(examples) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 589a0b52..3f6e46b5 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,8 +22,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -include_directories(../tests) - set(example_names #sample insert @@ -40,6 +38,7 @@ endif() create_test_sourcelist(example_sources example_main.cpp ${example_names}) add_executable(sqlpp11_examples ${example_sources}) +target_link_libraries(sqlpp11_examples PRIVATE sqlpp11 sqlpp11_testing) foreach(example IN LISTS example_names) add_test(NAME sqlpp11.examples.${example} diff --git a/test_constraints/CMakeLists.txt b/test_constraints/CMakeLists.txt index 9f388e28..87e7d197 100644 --- a/test_constraints/CMakeLists.txt +++ b/test_constraints/CMakeLists.txt @@ -22,12 +22,11 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -include_directories(../tests) - function(test_constraint name pattern) set(test sqlpp11.test_constraints.${name}) set(target sqlpp11_${name}) add_executable(${target} EXCLUDE_FROM_ALL ${name}.cpp) + target_link_libraries(${target} PRIVATE sqlpp11 sqlpp11_testing) add_test(NAME ${test} COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target ${target} ) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d6a594a4..669b2b9f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -22,6 +22,10 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +add_library(sqlpp11_testing INTERFACE) +target_include_directories(sqlpp11_testing INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +target_compile_options(sqlpp11_testing INTERFACE -Wall -Wextra -pedantic) + set(test_names BooleanExpression CustomQuery @@ -41,6 +45,7 @@ set(test_names create_test_sourcelist(test_sources test_main.cpp ${test_names}) add_executable(sqlpp11_tests ${test_sources}) +target_link_libraries(sqlpp11_tests PRIVATE sqlpp11 sqlpp11_testing) foreach(test IN LISTS test_names) add_test(NAME sqlpp11.tests.${test} From dcff4c2036a4d5bf2a8357b8a04ef6f8f7cf39aa Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Fri, 29 May 2015 23:16:50 +0200 Subject: [PATCH 08/10] add coveralls coverage reporting --- .travis.yml | 4 ++++ coveralls | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100755 coveralls diff --git a/.travis.yml b/.travis.yml index e19ad40a..4b221096 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,8 +36,12 @@ install: before_script: - mkdir build - cd build + - if [[ "$CXX" = "g++" && "$CONFIG" = "Debug" ]]; then export CXXFLAGS="--coverage"; fi - cmake .. -DCMAKE_BUILD_TYPE=$CONFIG script: - cmake --build . --config $CONFIG - ctest --output-on-failure + +after_script: + - ../coveralls diff --git a/coveralls b/coveralls new file mode 100755 index 00000000..301d67f7 --- /dev/null +++ b/coveralls @@ -0,0 +1,31 @@ +#!/bin/bash + +if [ 0 -eq $(find -iname *.gcda | wc -l) ] +then + exit 0 +fi + +gcov --source-prefix ${TRAVIS_BUILD_DIR} --preserve-paths --relative-only $(find -iname *.gcda) 1>/dev/null || exit 0 + +cat >coverage.json <>coverage.json <coverage.json <(head -n -1 coverage.json.tmp) <(echo -e " }\n ]\n}") +curl -F json_file=@coverage.json https://coveralls.io/api/v1/jobs From ee76176f7617eb5f6e823e067f838b0f1abedd11 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Fri, 29 May 2015 23:39:19 +0200 Subject: [PATCH 09/10] add status badges to README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 7e3020ed..57411d8f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ sqlpp11 ======= +[![Build Status](https://travis-ci.org/purpleKarrot/sqlpp11.svg?branch=develop)](https://travis-ci.org/purpleKarrot/sqlpp11) +[![Coverage Status](https://coveralls.io/repos/purpleKarrot/sqlpp11/badge.svg?branch=develop)](https://coveralls.io/r/purpleKarrot/sqlpp11?branch=develop) + A type safe embedded domain specific language for SQL queries and results in C++ Extensive documentation is found in the wiki, https://github.com/rbock/sqlpp11/wiki From 13d48c7204844b548dc411e4f488104bb4fb5564 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Fri, 29 May 2015 23:40:02 +0200 Subject: [PATCH 10/10] shamelessly adding myself to CREDITS --- CREDITS | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/CREDITS b/CREDITS index 3675cef0..fdfc9b58 100644 --- a/CREDITS +++ b/CREDITS @@ -3,14 +3,15 @@ Credits: This library evolved through several stages and would probably not exist without input from other people: * Michael Gmelin: Interface and requirements discussions - * Paul Körbitz: Feedback and extensions - * Peter Knoblach: Initial ideas - * Ulrich Küttler: Feedback and extensions + * Paul Körbitz: Feedback and extensions + * Peter Knoblach: Initial ideas + * Ulrich Küttler: Feedback and extensions + * Daniel Pfeifer: Buildsystem, Travis, Coveralls - * Metafeed GmbH: Production code using a forerunner version - * PPRO Financial Ltd: Production code using sqlpp11 and a forerunner version - * The boost community: Invaluable suggestions and critiques + * Metafeed GmbH: Production code using a forerunner version + * PPRO Financial Ltd: Production code using sqlpp11 and a forerunner version + * The boost community: Invaluable suggestions and critiques * Meeting C++ Munich: Hosted the first talk about sqlpp11