Fix crash when failing to parse test discovery output
Test discovery code should never fail a build as it's for info purposes
only.
Test: atest build_test_suites_test
Bug: 382217072
Change-Id: Ib546ee6209e1c3bb9d249cb1ee1d37454449008d
diff --git a/ci/build_test_suites.py b/ci/build_test_suites.py
index 4d3b546..623d256 100644
--- a/ci/build_test_suites.py
+++ b/ci/build_test_suites.py
@@ -87,11 +87,14 @@
if optimization_rationale:
get_metrics_agent().report_unoptimized_target(target, optimization_rationale)
else:
- regex = r'\b(%s)\b' % re.escape(target)
- if any(re.search(regex, opt) for opt in test_discovery_zip_regexes):
- get_metrics_agent().report_unoptimized_target(target, 'Test artifact used.')
- else:
- get_metrics_agent().report_optimized_target(target)
+ try:
+ regex = r'\b(%s)\b' % re.escape(target)
+ if any(re.search(regex, opt) for opt in test_discovery_zip_regexes):
+ get_metrics_agent().report_unoptimized_target(target, 'Test artifact used.')
+ else:
+ get_metrics_agent().report_optimized_target(target)
+ except Exception as e:
+ logging.error(f'unable to parse test discovery output: {repr(e)}')
if self._unused_target_exclusion_enabled(
target