mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
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
This commit is contained in:
parent
42d6f719cb
commit
716f82763a
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user