Add --xml flag to persist xml artifacts for testing purposes (#56238)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56238

Currently, all xml artifacts generated by doxygen are stored in the tmp dir and deleted at the end of the snapshot generation. For debugging reasons, this diff adds `--xml` flag to persist generated artifacts, so that they can be analyzed.

Changelog:
[Internal]

Reviewed By: cipolleschi

Differential Revision: D98289956

fbshipit-source-id: 73eb0185f7112389e589d3e8f8a2004efe325e8d
This commit is contained in:
Dawid Małecki
2026-03-31 08:32:57 -07:00
committed by meta-codesync[bot]
parent 7f879769db
commit 1d6e68bfdf
+19
View File
@@ -14,6 +14,7 @@ Usage:
import argparse
import concurrent.futures
import os
import shutil
import subprocess
import sys
import tempfile
@@ -140,6 +141,7 @@ def build_snapshots(
verbose: bool,
view_filter: str | None = None,
is_test: bool = False,
keep_xml: bool = False,
) -> None:
if not is_test:
configs_to_build = [
@@ -203,6 +205,7 @@ def build_snapshots(
failed_views = ", ".join(name for name, _ in errors)
raise RuntimeError(f"Failed to generate snapshots: {failed_views}")
else:
work_dir = os.path.join(react_native_dir, "api")
snapshot = build_snapshot_for_view(
api_view="Test",
react_native_dir=react_native_dir,
@@ -213,8 +216,18 @@ def build_snapshots(
codegen_dir=None,
verbose=verbose,
input_filter=input_filter,
work_dir=work_dir,
)
if keep_xml:
xml_src = os.path.join(work_dir, "xml")
xml_dst = os.path.join(output_dir, "xml")
if os.path.exists(xml_dst):
shutil.rmtree(xml_dst)
shutil.copytree(xml_src, xml_dst)
if verbose:
print(f"XML files saved to {xml_dst}")
if verbose:
print(snapshot)
@@ -252,6 +265,11 @@ def main():
action="store_true",
help="Run on the local test directory instead of the react-native directory",
)
parser.add_argument(
"--xml",
action="store_true",
help="Keep the generated Doxygen XML files next to the .api output in a xml/ directory",
)
args = parser.parse_args()
verbose = not args.check
@@ -309,6 +327,7 @@ def main():
input_filter=input_filter,
view_filter=args.view,
is_test=args.test,
keep_xml=args.xml,
)
if args.check: