Unverified Commit 234952cf authored by Jia Hao's avatar Jia Hao Committed by GitHub

[flutter_tools] Simplify `flutter test` internals (#74176)

parent 7c22f0d2
......@@ -61,13 +61,18 @@ Future<Map<String, dynamic>> _runTest(String scriptPath) async {
final String testResults = (await process.stdout
.transform(utf8.decoder)
.expand((String text) => text.split('\n'))
.map((String line) {
.map<dynamic>((String line) {
try {
return jsonDecode(line) as Map<String, dynamic>;
return jsonDecode(line);
} on FormatException {
// Only interested in test events which are JSON.
}
})
.expand<Map<String, dynamic>>((dynamic json) {
return json is List<dynamic>
? json.cast()
: <Map<String, dynamic>>[json as Map<String, dynamic>];
})
.where((Map<String, dynamic> testEvent) =>
testEvent != null && testEvent['type'] == 'print')
.map((Map<String, dynamic> printEvent) => printEvent['message'] as String)
......
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