diff --git a/package.json b/package.json index aa6117adb8d..988f7a44335 100644 --- a/package.json +++ b/package.json @@ -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}\"", diff --git a/scripts/cxx-api/README.md b/scripts/cxx-api/README.md index 459c0e8a4c7..b894a008fc0 100644 --- a/scripts/cxx-api/README.md +++ b/scripts/cxx-api/README.md @@ -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 diff --git a/scripts/cxx-api/parser/__main__.py b/scripts/cxx-api/parser/__main__.py index d1aeef6a93c..df051850786 100644 --- a/scripts/cxx-api/parser/__main__.py +++ b/scripts/cxx-api/parser/__main__.py @@ -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__": diff --git a/scripts/cxx-api/parser/snapshot_diff.py b/scripts/cxx-api/parser/snapshot_diff.py index c97f750ea5d..c503a8d43a3 100644 --- a/scripts/cxx-api/parser/snapshot_diff.py +++ b/scripts/cxx-api/parser/snapshot_diff.py @@ -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):