aboutsummaryrefslogtreecommitdiffstats
path: root/tests/template
diff options
context:
space:
mode:
authoripknHama <ipknhama@gmail.com>2014-08-07 04:46:28 +0900
committeripknHama <ipknhama@gmail.com>2014-08-07 04:46:28 +0900
commite70380e003ae28822a6b903193c9a699cc02c405 (patch)
tree529a655ab16dc121024723d820edcfd192d381b5 /tests/template
parent031615ac866cc3c8f1900dd4b4aae2106ad31230 (diff)
downloadcrow-e70380e003ae28822a6b903193c9a699cc02c405.tar.gz
crow-e70380e003ae28822a6b903193c9a699cc02c405.zip
cmake update, added template test
Diffstat (limited to 'tests/template')
-rw-r--r--tests/template/CMakeLists.txt29
-rw-r--r--tests/template/mustachetest.cpp (renamed from tests/template/mustachetest.cc)4
-rwxr-xr-xtests/template/test.py15
3 files changed, 39 insertions, 9 deletions
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')