PaddlePaddle/PaddleOCR · error · RuntimeError
xcresulttool metrics export failed
Error message
xcresulttool metrics export failed
What it means
RuntimeError raised when `xcrun xcresulttool get test-results metrics --path <bundle> --compact` exits non-zero in extract_xctest_metrics.py. The message is the tool's stripped stderr, or the generic 'xcresulttool metrics export failed' when stderr is empty.
Source
Thrown at deploy/ios_demo/scripts/extract_xctest_metrics.py:61
def export_metrics(result: Path) -> Dict[str, Any]:
proc = subprocess.run(
[
"xcrun",
"xcresulttool",
"get",
"test-results",
"metrics",
"--path",
str(result),
"--compact",
],
text=True,
capture_output=True,
check=False,
)
if proc.returncode != 0:
raise RuntimeError(proc.stderr.strip() or "xcresulttool metrics export failed")
raw = json.loads(proc.stdout or "[]")
tests = raw if isinstance(raw, list) else []
memory_metrics: List[Dict[str, Any]] = []
for test in tests:
if not isinstance(test, dict):
continue
for run in test.get("testRuns") or []:
if not isinstance(run, dict):
continue
device = run.get("device") if isinstance(run.get("device"), dict) else {}
config = (
run.get("testPlanConfiguration")
if isinstance(run.get("testPlanConfiguration"), dict)
else {}
)
for metric in run.get("metrics") or []:
if not isinstance(metric, dict):
continueView on GitHub (pinned to 2661c7c0ef)
Solutions
- Read the stderr text embedded in the RuntimeError to identify the xcresulttool complaint.
- Ensure the .xcresult comes from tests that use XCTest metrics (measure blocks) — plain unit tests produce no metrics.
- Regenerate the bundle with `xcodebuild test` on the currently selected Xcode.
- Check `xcrun xcresulttool help get test-results` lists `metrics` for your Xcode version.
Defensive patterns
Strategy: try-catch
Validate before calling
import subprocess
def metrics_available(bundle: str) -> bool:
r = subprocess.run(
["xcrun", "xcresulttool", "get", "test-results", "metrics", "--path", bundle, "--compact"],
capture_output=True, text=True,
)
return r.returncode == 0 Try / catch
try:
extract_metrics(result_path)
except RuntimeError as e:
if "xcresulttool" in str(e):
log.warning("no metrics in %s; skipping (only performance tests produce metrics)", result_path)
else:
raise Prevention
- Only run extract_xctest_metrics.py on bundles from XCTest performance tests (measure blocks).
- Gate the metrics step in CI on the test suite containing metrics tests.
- Verify the metrics subcommand exists for the selected Xcode before invoking.
When it happens
Trigger: Running the metrics extraction against an .xcresult that contains no metrics payloads (tests ran without performance measurement); a corrupt or non-metrics bundle; an Xcode whose xcresulttool lacks the metrics subcommand.
Common situations: CI running the script on every test result although only XCTest performance tests (measure {}) produce metrics; Xcode downgrade/upgrade changing the metrics export format.
Related errors
- Could not parse xcresulttool JSON: {e}.
- xcresulttool export attachments failed with exit {r.returnco
- Could not resolve exported file (wanted {wanted_out_name!r},
- degenerate text crop (zero width/height)
- compare_ocr_json.py requires `pip install shapely`
AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14).
Data as JSON: /api/errors/c32d9d9f8221aac8.
Report an issue: GitHub.