Unverified Commit 716f8276 authored by godofredoc's avatar godofredoc Committed by GitHub

Add workaround for bug adding unicode strings to test reports. (#145607)

When print is used inside tests its content is added to the test report as a string of unicode \u0000 making the test reporting parser fail. This PR cleans removes non json content every line of the report.

Bug: https://github.com/flutter/flutter/issues/145553
parent 42d6f719
......@@ -49,7 +49,14 @@ class TestFileReporterResults {
final List<String> errors = <String>[];
for (final String metric in metrics.readAsLinesSync()) {
final Map<String, Object?> entry = json.decode(metric) as Map<String, Object?>;
/// 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<String, Object?> entry = json.decode(sanitizedMetric) as Map<String, Object?>;
if (entry.containsKey('suite')) {
final Map<String, Object?> suite = entry['suite']! as Map<String, Object?>;
addTestSpec(suite, entry['time']! as int, testSpecs);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment