| 218 | |
| 219 | |
| 220 | def 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''' |
| 241 | cc_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""" |
| 252 | test_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 | |
| 266 | def main(): |