Conditions | 7 |
Total Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | #!/usr/bin/env python |
||
12 | def transpile_tests(tests_dir): |
||
13 | """ |
||
14 | Transpile all python regression tests in tests_dir into C++ header |
||
15 | files and include them in a single cpp file |
||
16 | """ |
||
17 | hpp_files = [] |
||
18 | py_files = [p for p in os.listdir(tests_dir) if is_test(p)] |
||
19 | |||
20 | for py_file in py_files: |
||
21 | hpp_file = splitext(py_file)[0] + ".hpp" |
||
22 | hpp_path = join(tests_dir, hpp_file) |
||
23 | |||
24 | with open(hpp_path, "w") as cpp_file: |
||
25 | source = open(join(tests_dir, py_file)).read() |
||
26 | cpp = transpile(source, headers=True, testing=True) |
||
27 | cpp_file.write(cpp) |
||
28 | |||
29 | hpp_files.append(hpp_file) |
||
30 | |||
31 | with open(join(tests_dir, "main.cpp"), "w") as main: |
||
32 | main.write("#define CATCH_CONFIG_MAIN\n") |
||
33 | main.write('#include "catch.hpp"\n') |
||
34 | for hpp_file in hpp_files: |
||
35 | main.write('#include "{0}"\n'.format(hpp_file)) |
||
36 | |||
41 |