{"record":{"id":"37c01863d471431f","repo":"PaddlePaddle/PaddleOCR","slug":"xcresulttool-get-test-results-failed-with-exit-r","errorCode":null,"errorMessage":"xcresulttool get test-results failed with exit {r.returncode}.","messagePattern":"xcresulttool get test-results failed with exit (.+?)\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"deploy/ios_demo/scripts/extract_xcresult_attachments.py","lineNumber":102,"sourceCode":"        )\n\n\ndef _load_tests_json(result_path: Path) -> dict:\n    r = _run(\n        [\n            \"xcrun\",\n            \"xcresulttool\",\n            \"get\",\n            \"test-results\",\n            \"tests\",\n            \"--path\",\n            str(result_path),\n            \"--format\",\n            \"json\",\n        ]\n    )\n    if r.returncode != 0:\n        raise SystemExit(\n            _die(\n                f\"xcresulttool get test-results failed with exit {r.returncode}.\",\n                str(result_path),\n                \"Confirm the .xcresult was produced by a completed `xcodebuild test`.\",\n            )\n        )\n    try:\n        return json.loads(r.stdout or b\"{}\")\n    except json.JSONDecodeError as e:\n        raise SystemExit(\n            _die(\n                f\"Could not parse xcresulttool JSON: {e}.\",\n                str(result_path),\n                \"Re-run xcodebuild test to regenerate the .xcresult.\",\n            )\n        )\n\n","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/deploy/ios_demo/scripts/extract_xcresult_attachments.py#L84-L120","documentation":"Raised by extract_xcresult_attachments.py when the probe in _load_tests_json fails: `xcrun xcresulttool get test-results tests --path <xcresult> --format json` exits non-zero. The script surfaces the exit code, the result-bundle path, and a hint that the bundle must come from a completed `xcodebuild test` run.","triggerScenarios":"Pointing the script at a nonexistent or truncated .xcresult, a bundle from an interrupted/crashed test run, or a bundle created by a different (older) Xcode whose format the current xcresulttool cannot read.","commonSituations":"Test runner was killed mid-suite leaving a partial bundle; passing the build directory instead of the .xcresult path; archiving tests with one Xcode version and extracting with another.","solutions":["Re-run the tests to completion (`xcodebuild test ... -resultBundlePath result.xcresult`) and pass that fresh bundle.","Verify the path exists and is a directory ending in .xcresult.","Ensure the Xcode that produced the bundle matches (or is older than) the one selected for extraction."],"exampleFix":"# before\npython deploy/ios_demo/scripts/extract_xcresult_attachments.py build/  # wrong path\n# -> SystemExit: xcresulttool get test-results failed with exit 70\n\n# after\nxcodebuild test -scheme Demo -resultBundlePath result.xcresult\npython deploy/ios_demo/scripts/extract_xcresult_attachments.py result.xcresult","handlingStrategy":"try-catch","validationCode":"from pathlib import Path\n\ndef xcresult_ok(path: str) -> bool:\n    p = Path(path)\n    return p.is_dir() and p.suffix == \".xcresult\" and (p / \"Info.plist\").exists()\n\nassert xcresult_ok(bundle), f\"{bundle} is not a complete .xcresult bundle\"","typeGuard":null,"tryCatchPattern":"try:\n    extract(result_path)\nexcept SystemExit as e:\n    msg = str(e)\n    if \"xcresulttool get test-results failed\" in msg:\n        rerun_tests_and_retry()  # regenerate the bundle from a completed xcodebuild test\n    else:\n        raise","preventionTips":["Always generate bundles with -resultBundlePath on a completed xcodebuild test run.","Verify the .xcresult directory (and Info.plist) exists before extraction.","Produce and extract bundles with the same Xcode version to avoid format mismatches."],"tags":["paddleocr","ios","xcode","xcresulttool","test-artifacts"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}