Rename --check flag to --validate in C++ public API parser (#56253)

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

Renames flag for verifying that the C++ public API snapshot is with sync with the actual public API surface to match the JS API command.

Changelog:
[Internal]

Reviewed By: huntie

Differential Revision: D98484129

fbshipit-source-id: ec806353f263b00e5060d9e7f0333bcf4cced148
This commit is contained in:
Dawid Małecki authored and meta-codesync[bot] committed 2026-03-31 08:32:57 -07:00
1 parent ef6777ddf3
commit c54d353df9
4 files changed
+15 -15

No files matched your search

+1 -1
View File
@@ -12,7 +12,7 @@
"clang-format": "clang-format -i --glob=*/**/*.{h,cpp,m,mm}",
"clean": "node ./scripts/build/clean.js",
"cxx-api-build": "python -m scripts.cxx-api.parser",
"cxx-api-validate": "python -m scripts.cxx-api.parser --check",
"cxx-api-validate": "python -m scripts.cxx-api.parser --validate",
"flow-check": "flow check",
"flow": "flow",
"format-check": "prettier --list-different \"./**/*.{js,md,yml,ts,tsx}\"",
+3 -3
View File
@@ -31,15 +31,15 @@ Maintainers should run this command whenever making intentional C++ API changes:
python -m scripts.cxx-api.parser
```
#### Check snapshots against committed baseline
#### Validate snapshots against committed baseline
This mode generates snapshots to a temporary directory and compares them against the committed `.api` files. It is designed for CI:
```sh
python -m scripts.cxx-api.parser --check
python -m scripts.cxx-api.parser --validate
```
If any snapshot differs, a unified diff is printed and the process exits with a non-zero status. To fix a failing check, regenerate the snapshots with `python -m scripts.cxx-api.parser` and commit the updated `.api` files.
If any snapshot differs, a unified diff is printed and the process exits with a non-zero status. To fix a failing validation, regenerate the snapshots with `python -m scripts.cxx-api.parser` and commit the updated `.api` files.
## How it works
+9 -9
View File
@@ -24,7 +24,7 @@ from .config import ApiViewSnapshotConfig, parse_config_file
from .doxygen import get_doxygen_bin, run_doxygen
from .main import build_snapshot
from .path_utils import get_react_native_dir
from .snapshot_diff import check_snapshots
from .snapshot_diff import validate_snapshots
def run_command(
@@ -250,14 +250,14 @@ def main():
help="Output directory for the snapshot",
)
parser.add_argument(
"--check",
"--validate",
action="store_true",
help="Generate snapshots to a temp directory and compare against committed ones",
)
parser.add_argument(
"--snapshot-dir",
type=str,
help="Directory containing committed snapshots for comparison (used with --check)",
help="Directory containing committed snapshots for comparison (used with --validate)",
)
parser.add_argument(
"--view",
@@ -276,7 +276,7 @@ def main():
)
args = parser.parse_args()
verbose = not args.check
verbose = not args.validate
doxygen_bin = get_doxygen_bin()
version_result = subprocess.run(
@@ -319,13 +319,13 @@ def main():
with tempfile.TemporaryDirectory() as tmpdir:
snapshot_output_dir = (
args.output_dir or tmpdir
if args.check
if args.validate
else args.output_dir or get_default_snapshot_dir()
)
build_snapshots(
output_dir=snapshot_output_dir,
verbose=not args.check,
verbose=not args.validate,
snapshot_configs=snapshot_configs,
react_native_dir=react_native_package_dir,
input_filter=input_filter,
@@ -334,13 +334,13 @@ def main():
keep_xml=args.xml,
)
if args.check:
if args.validate:
snapshot_dir = args.snapshot_dir or get_default_snapshot_dir()
if not check_snapshots(snapshot_output_dir, snapshot_dir):
if not validate_snapshots(snapshot_output_dir, snapshot_dir):
sys.exit(1)
print("All snapshot checks passed")
print("All snapshot validations passed")
if __name__ == "__main__":
+2 -2
View File
@@ -11,10 +11,10 @@ import difflib
import os
def check_snapshots(generated_dir: str, committed_dir: str) -> bool:
def validate_snapshots(generated_dir: str, committed_dir: str) -> bool:
"""Compare generated snapshots against committed ones.
Returns True if check passes (snapshots match or no committed snapshots).
Returns True if validation passes (snapshots match or no committed snapshots).
Returns False if snapshots differ.
"""
if not os.path.isdir(committed_dir):