MCPcopy Create free account
hub / github.com/apache/fory / generate_bazel_build

Function generate_bazel_build

ci/extract_cpp_doc_code.py:220–263  ·  view source on GitHub ↗
(test_files: List[Path], output_dir: Path)

Source from the content-addressed store, hash-verified

218
219
220def generate_bazel_build(test_files: List[Path], output_dir: Path) -> None:
221 build_path = output_dir / "BUILD"
222
223 build_content = """package(default_visibility = ["//visibility:public"])
224
225"""
226
227 test_names = []
228 for test_file in sorted(test_files):
229 test_name = test_file.stem
230 test_names.append(test_name)
231
232 # Determine additional deps based on test name
233 deps = ['"//cpp/fory/serialization:fory_serialization"']
234 if "row-format" in test_name:
235 deps.append('"//cpp/fory/row:fory_row_format"')
236 deps.append('"//cpp/fory/encoder:fory_encoder"')
237
238 deps_str = ",\n ".join(deps)
239
240 build_content += f'''
241cc_test(
242 name = "{test_name}",
243 srcs = ["{test_file.name}"],
244 deps = [
245 {deps_str},
246 ],
247)
248'''
249
250 if test_names:
251 build_content += f"""
252test_suite(
253 name = "doc_example_tests",
254 tests = [
255{chr(10).join(f' ":{name}",' for name in test_names)}
256 ],
257)
258"""
259
260 with open(build_path, "w", encoding="utf-8") as f:
261 f.write(build_content)
262
263 logging.info(f"Generated BUILD file with {len(test_names)} tests")
264
265
266def main():

Callers 1

mainFunction · 0.85

Calls 3

writeMethod · 0.65
infoMethod · 0.65
appendMethod · 0.45

Tested by

no test coverage detected