Generates the test/demo method symbol lookup file from tests_cpp. projectdir is a util.fslike.path.Path.
(projectdir)
| 62 | |
| 63 | |
| 64 | def generate_testlist(projectdir): |
| 65 | """ |
| 66 | Generates the test/demo method symbol lookup file from tests_cpp. |
| 67 | |
| 68 | projectdir is a util.fslike.path.Path. |
| 69 | """ |
| 70 | root_namespace = Namespace() |
| 71 | |
| 72 | from ..testing.list_processor import list_targets_cpp |
| 73 | |
| 74 | for testname, _, _, _ in list_targets_cpp(): |
| 75 | root_namespace.add_functionname(testname.split('::')) |
| 76 | |
| 77 | func_prototypes = list(root_namespace.gen_prototypes()) |
| 78 | |
| 79 | method_mappings = [ |
| 80 | f"{{\"{functionname}\", ::{functionname}}}" |
| 81 | for functionname in root_namespace.get_functionnames() |
| 82 | ] |
| 83 | |
| 84 | tmpl_path = projectdir.joinpath("libopenage/testing/testlist.cpp.template") |
| 85 | with tmpl_path.open() as tmpl: |
| 86 | content = tmpl.read() |
| 87 | |
| 88 | content = content.replace('FUNCTION_PROTOTYPES', "".join(func_prototypes)) |
| 89 | content = content.replace('METHOD_MAPPINGS', ",\n\t".join(method_mappings)) |
| 90 | |
| 91 | gen_path = projectdir.joinpath("libopenage/testing/testlist.gen.cpp") |
| 92 | with gen_path.open("w") as gen: |
| 93 | gen.write(content) |
no test coverage detected