diff --git a/dev/bots/tool_subsharding.dart b/dev/bots/tool_subsharding.dart index 769517f80a..9fe70bd581 100644 --- a/dev/bots/tool_subsharding.dart +++ b/dev/bots/tool_subsharding.dart @@ -49,7 +49,14 @@ class TestFileReporterResults { final List errors = []; for (final String metric in metrics.readAsLinesSync()) { - final Map entry = json.decode(metric) as Map; + /// Using print within a test adds the printed content to the json file report + /// as \u0000 making the file parsing step fail. The content of the json file + /// is expected to be a json dictionary per line and the following line removes + /// all the additional content at the beginning of the line until it finds the + /// first opening curly bracket. + // TODO(godofredoc): remove when https://github.com/flutter/flutter/issues/145553 is fixed. + final String sanitizedMetric = metric.replaceAll(RegExp(r'$.*{'), '{'); + final Map entry = json.decode(sanitizedMetric) as Map; if (entry.containsKey('suite')) { final Map suite = entry['suite']! as Map; addTestSpec(suite, entry['time']! as int, testSpecs);