Skip to content
This repository has been archived by the owner on Jun 3, 2018. It is now read-only.

Commit

Permalink
Only transform functions with test_ at start to test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmartinelli committed Jan 27, 2015
1 parent 72ad628 commit c210224
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions py14/transpiler.py
Expand Up @@ -29,7 +29,7 @@ def transpile(source, headers=False, testing=False):
buf += transpiler.usings

if testing or headers:
buf.append('') #Force empty line
buf.append('') # Force empty line

cpp = transpiler.visit(tree)
return "\n".join(buf) + cpp
Expand Down Expand Up @@ -83,7 +83,9 @@ def visit_FunctionDef(self, node):
body = "\n".join([self.visit(n) for n in node.body])
self._function_stack.pop()

if self.use_catch_test_cases and is_void_function(node):
if (self.use_catch_test_cases and
is_void_function(node) and
node.name.startswith("test")):
return generate_catch_test_case(node, body)
elif is_void_function(node) or is_recursive(node):
return generate_template_fun(node, body)
Expand Down
2 changes: 1 addition & 1 deletion transpile_regtests.py
Expand Up @@ -32,7 +32,7 @@ def transpile_tests(tests_dir):
main.write("#define CATCH_CONFIG_MAIN\n")
main.write('#include "catch.hpp"\n')
for hpp_file in hpp_files:
main.write('#include "{0}"'.format(hpp_file))
main.write('#include "{0}"\n'.format(hpp_file))


if __name__ == "__main__":
Expand Down

0 comments on commit c210224

Please sign in to comment.