[go: nahoru, domu]

Skip to content

Commit

Permalink
Add workaround for bug adding unicode strings to test reports. (#145607)
Browse files Browse the repository at this point in the history
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: #145553
  • Loading branch information
godofredoc committed Mar 23, 2024
1 parent 42d6f71 commit 716f827
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dev/bots/tool_subsharding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 716f827

Please sign in to comment.