MCPcopy
hub / github.com/SFTtech/openage / generate_testlist

Function generate_testlist

openage/codegen/cpp_testlist.py:64–93  ·  view source on GitHub ↗

Generates the test/demo method symbol lookup file from tests_cpp. projectdir is a util.fslike.path.Path.

(projectdir)

Source from the content-addressed store, hash-verified

62
63
64def 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)

Callers 1

generate_allFunction · 0.85

Calls 9

add_functionnameMethod · 0.95
gen_prototypesMethod · 0.95
get_functionnamesMethod · 0.95
NamespaceClass · 0.85
list_targets_cppFunction · 0.85
joinpathMethod · 0.80
openMethod · 0.45
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected