diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | CMakeLists.txt | 14 | ||||
-rw-r--r-- | examples/CMakeLists.txt | 11 | ||||
-rw-r--r-- | examples/example_test.py (renamed from tests/test.py) | 0 | ||||
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 23 | ||||
-rw-r--r-- | tests/template/CMakeLists.txt | 29 | ||||
-rw-r--r-- | tests/template/mustachetest.cpp (renamed from tests/template/mustachetest.cc) | 4 | ||||
-rwxr-xr-x | tests/template/test.py | 15 |
9 files changed, 68 insertions, 32 deletions
@@ -26,8 +26,9 @@ unittest *.swp *.gcov -covtest *.gcda *.gcno +build + .directory diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fd219f..b517ae4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,14 +1,10 @@ cmake_minimum_required(VERSION 2.8) project (crow_all) - -find_package( Boost 1.40 COMPONENTS date_time filesystem system thread REQUIRED ) -#find_package( Tcmalloc ) -include_directories( ${Boost_INCLUDE_DIR} ) -#set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++1y") -#set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}) -#set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}) +find_package( Boost 1.40 COMPONENTS date_time filesystem system thread REQUIRED ) +include_directories( ${Boost_INCLUDE_DIR} ) set(PROJECT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include @@ -21,3 +17,7 @@ include_directories("${PROJECT_SOURCE_DIR}") add_subdirectory(src) add_subdirectory(tests) add_subdirectory(examples) + +enable_testing() +add_test(NAME crow_test COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/unittest) +add_test(NAME template_test COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/template/test.py WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests/template) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 7313adf..24150f0 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -4,16 +4,17 @@ project (crow_examples) add_executable(example example.cpp) target_link_libraries(example crow) target_link_libraries(example ${Boost_LIBRARIES} ) -set_target_properties(example PROPERTIES COMPILE_FLAGS "-Wall -std=c++1y") +add_custom_command(OUTPUT example_test.py + COMMAND ${CMAKE_COMMAND} -E + copy ${PROJECT_SOURCE_DIR}/example_test.py ${CMAKE_CURRENT_BINARY_DIR}/example_test.py + DEPENDS ${PROJECT_SOURCE_DIR}/example_test.py + ) +add_custom_target(example_copy ALL DEPENDS example_test.py) add_executable(example_chat example_chat.cpp) target_link_libraries(example_chat crow) target_link_libraries(example_chat ${Boost_LIBRARIES} ) -set_target_properties(example_chat PROPERTIES COMPILE_FLAGS "-Wall -std=c++1y") -message(${CMAKE_CURRENT_BINARY_DIR}) -message(${PROJECT_SOURCE_DIR}) add_custom_command(OUTPUT example_chat.html - #TARGET example_chat COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/example_chat.html ${CMAKE_CURRENT_BINARY_DIR}/example_chat.html DEPENDS ${PROJECT_SOURCE_DIR}/example_chat.html diff --git a/tests/test.py b/examples/example_test.py index e2bf651..e2bf651 100644 --- a/tests/test.py +++ b/examples/example_test.py diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bf74895..4ac6f63 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,4 +15,3 @@ include_directories("${PROJECT_INCLUDE_DIR}") add_library(${PROJECT_NAME} SHARED ${CROW_SRCS}) #target_link_libraries(${PROJECT_NAME} tcmalloc) -set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-Wall -std=c++1y") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 45943ed..d35925c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,16 +2,21 @@ cmake_minimum_required(VERSION 2.8) project (crow_test) -set(PROJECT_INCLUDE_DIR -${PROJECT_SOURCE_DIR}/include -${PROJECT_SOURCE_DIR}/http-parser -) - set(TEST_SRCS unittest.cpp ) -add_executable(test ${TEST_SRCS}) -target_link_libraries(test crow) -target_link_libraries( test ${Boost_LIBRARIES} ) -set_target_properties(test PROPERTIES COMPILE_FLAGS "-Wall -std=c++1y") +add_executable(unittest ${TEST_SRCS}) +target_link_libraries(unittest crow) +target_link_libraries(unittest ${Boost_LIBRARIES} ) + +set_target_properties(unittest PROPERTIES COMPILE_FLAGS "--coverage -fprofile-arcs -ftest-coverage") + +target_link_libraries(unittest gcov) + +add_subdirectory(template) +#CXXFLAGS="-g -O0 -Wall -W -Wshadow -Wunused-variable \ +#Wunused-parameter -Wunused-function -Wunused -Wno-system-headers \ +#-Wno-deprecated -Woverloaded-virtual -Wwrite-strings -fprofile-arcs -ftest-coverage" +#CFLAGS="-g -O0 -Wall -W -fprofile-arcs -ftest-coverage" +#LDFLAGS="-fprofile-arcs -ftest-coverage" diff --git a/tests/template/CMakeLists.txt b/tests/template/CMakeLists.txt new file mode 100644 index 0000000..1d4ec30 --- /dev/null +++ b/tests/template/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 2.8) +project (template_test) + + +set(PROJECT_INCLUDE_DIR +${PROJECT_SOURCE_DIR}/include +) + +set(TEST_SRCS +mustachetest.cpp +) + +add_executable(mustachetest ${TEST_SRCS}) +#target_link_libraries(unittest crow) +#target_link_libraries(unittest ${Boost_LIBRARIES} ) +set_target_properties(mustachetest PROPERTIES COMPILE_FLAGS "-Wall -std=c++1y") + +message(${PROJECT_SOURCE_DIR}) +message(${CMAKE_CURRENT_BINARY_DIR}) +file(COPY DIRECTORY . DESTINATION ${CMAKE_CURRENT_BINARY_DIR} + FILES_MATCHING + PATTERN "*.json") + +add_custom_command(OUTPUT test.py + COMMAND ${CMAKE_COMMAND} -E + copy ${PROJECT_SOURCE_DIR}/test.py ${CMAKE_CURRENT_BINARY_DIR}/test.py + DEPENDS ${PROJECT_SOURCE_DIR}/test.py + ) +add_custom_target(template_test_copy ALL DEPENDS test.py) diff --git a/tests/template/mustachetest.cc b/tests/template/mustachetest.cpp index c4ac2c9..1caf537 100644 --- a/tests/template/mustachetest.cc +++ b/tests/template/mustachetest.cpp @@ -2,8 +2,8 @@ #include <fstream> #include <string> #include <iterator> -#include "../mustache.h" -#include "../json.h" +#include "mustache.h" +#include "json.h" using namespace std; using namespace crow; using namespace crow::mustache; diff --git a/tests/template/test.py b/tests/template/test.py index 22fcca0..57bcaf8 100755 --- a/tests/template/test.py +++ b/tests/template/test.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import print_function import glob import json import os @@ -14,15 +15,15 @@ for testfile in glob.glob("*.json"): open('partials', 'w').write(json.dumps(test["partials"])) else: open('partials', 'w').write("{}") - ret = subprocess.check_output("./mustachetest") - print testfile, test["name"] + ret = subprocess.check_output("./mustachetest").decode('utf8') + print(testfile, test["name"]) if ret != test["expected"]: if 'partials' in test: - print 'partials:', json.dumps(test["partials"]) - print json.dumps(test["data"]) - print test["template"] - print 'Expected:',repr(test["expected"]) - print 'Actual:',repr(ret) + print('partials:', json.dumps(test["partials"])) + print(json.dumps(test["data"])) + print(test["template"]) + print('Expected:',repr(test["expected"])) + print('Actual:',repr(ret)) assert ret == test["expected"] os.unlink('data') os.unlink('template') |