Commit cffd5517 authored by Yegor's avatar Yegor Committed by GitHub

log full timeline when transition test fails; print stack chain in task errors (#6772)

parent d6343077
......@@ -9,6 +9,7 @@ import 'dart:io';
import 'dart:isolate';
import 'package:logging/logging.dart';
import 'package:stack_trace/stack_trace.dart';
import 'utils.dart';
......@@ -115,16 +116,24 @@ class _TaskRunner {
_keepAlivePort?.close();
}
Future<TaskResult> _performTask() async {
try {
return await task();
} catch (taskError, taskErrorStack) {
Future<TaskResult> _performTask() {
Completer<TaskResult> completer = new Completer<TaskResult>();
Chain.capture(() async {
completer.complete(await task());
}, onError: (dynamic taskError, Chain taskErrorStack) {
String message = 'Task failed: $taskError';
if (taskErrorStack != null) {
message += '\n\n$taskErrorStack';
}
return new TaskResult.failure(message);
}
stderr
..writeln(message)
..writeln('\nStack trace:')
..writeln(taskErrorStack.terse);
// IMPORTANT: We're completing the future _successfully_ but with a value
// that indicates a task failure. This is intentional. At this point we
// are catching errors coming from arbitrary (and untrustworthy) task
// code. Our goal is to convert the failure into a readable message.
// Propagating it further is not useful.
completer.complete(new TaskResult.failure(message));
});
return completer.future;
}
}
......
......@@ -59,6 +59,8 @@ final List<String> demoTitles = <String>[
'Typography'
];
final FileSystem _fs = new LocalFileSystem();
Future<Null> saveDurationsHistogram(List<Map<String, dynamic>> events) async {
final Map<String, List<int>> durations = new Map<String, List<int>>();
Map<String, dynamic> startEvent;
......@@ -87,9 +89,8 @@ Future<Null> saveDurationsHistogram(List<Map<String, dynamic>> events) async {
// Save the durations Map to a file.
final String destinationDirectory = 'build';
final FileSystem fs = new LocalFileSystem();
await fs.directory(destinationDirectory).create(recursive: true);
final File file = fs.file(path.join(destinationDirectory, 'transition_durations.timeline.json'));
await _fs.directory(destinationDirectory).create(recursive: true);
final File file = _fs.file(path.join(destinationDirectory, 'transition_durations.timeline.json'));
await file.writeAsString(new JsonEncoder.withIndent(' ').convert(durations));
}
......@@ -136,10 +137,16 @@ void main() {
// Save the duration (in microseconds) of the first timeline Frame event
// that follows a 'Start Transition' event. The Gallery app adds a
// 'Start Transition' event when a demo is launched (see GalleryItem).
saveDurationsHistogram(timeline.json['traceEvents']);
TimelineSummary summary = new TimelineSummary.summarize(timeline);
summary.writeSummaryToFile('transitions');
summary.writeSummaryToFile('transitions', pretty: true);
try {
saveDurationsHistogram(timeline.json['traceEvents']);
} catch(_) {
summary.writeTimelineToFile('transitions', pretty: true);
print('ERROR: failed to extract transition events. Here is the full timeline:\n');
print(await _fs.file('build/transitions.timeline.json').readAsString());
rethrow;
}
}, timeout: new Timeout(new Duration(minutes: 5)));
});
......
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