8000 Merge pull request #12 from hoxnox/buildtest · zeroshade/docopt.cpp@5ad9b98 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5ad9b98

Browse files
committed
Merge pull request docopt#12 from hoxnox/buildtest
Enhancements: run_tests preparing corrected
2 parents 2070030 + 94c8e59 commit 5ad9b98

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,16 @@ endif()
3636
# example
3737

3838
if (WITH_TESTS)
39-
add_executable(docopt_testcase run_testcase.cpp)
40-
target_link_libraries(docopt_testcase docopt)
39+
set(TESTPROG "${CMAKE_CURRENT_BINARY_DIR}/run_testcase")
40+
set(TESTCASES "${PROJECT_SOURCE_DIR}/testcases.docopt")
41+
add_executable(run_testcase run_testcase.cpp)
42+
target_link_libraries(run_testcase docopt)
43+
configure_file(
44+
"${PROJECT_SOURCE_DIR}/run_tests.py"
45+
"${CMAKE_CURRENT_BINARY_DIR}/run_tests"
46+
ESCAPE_QUOTES
47+
)
48+
add_test("Testcases docopt" ${TESTPROG})
4149
endif()
4250

4351
########################################################################

run_tests.py

100644100755
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
#!/usr/bin/env python2
2+
13
import re
24
import json
35
import subprocess
46

5-
executable = "./run_testcase"
7+
executable = "${TESTPROG}"
68

79
def parse_test(raw):
810
raw = re.compile('#.*$', re.M).sub('', raw).strip()
@@ -24,7 +26,7 @@ def parse_test(raw):
2426
failures = 0
2527
passes = 0
2628

27-
tests = open('testcases.docopt','r').read()
29+
tests = open('${TESTCASES}','r').read()
2830
for _, doc, cases in parse_test(tests):
2931
if not cases: continue
3032

0 commit comments

Comments
 (0)
0