log full timeline when transition test fails; print stack chain in task errors (#6772)
This commit is contained in:
parent
d63430773c
commit
cffd551793
@ -9,6 +9,7 @@ import 'dart:io';
|
|||||||
import 'dart:isolate';
|
import 'dart:isolate';
|
||||||
|
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
|
import 'package:stack_trace/stack_trace.dart';
|
||||||
|
|
||||||
import 'utils.dart';
|
import 'utils.dart';
|
||||||
|
|
||||||
@ -115,16 +116,24 @@ class _TaskRunner {
|
|||||||
_keepAlivePort?.close();
|
_keepAlivePort?.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<TaskResult> _performTask() async {
|
Future<TaskResult> _performTask() {
|
||||||
try {
|
Completer<TaskResult> completer = new Completer<TaskResult>();
|
||||||
return await task();
|
Chain.capture(() async {
|
||||||
} catch (taskError, taskErrorStack) {
|
completer.complete(await task());
|
||||||
|
}, onError: (dynamic taskError, Chain taskErrorStack) {
|
||||||
String message = 'Task failed: $taskError';
|
String message = 'Task failed: $taskError';
|
||||||
if (taskErrorStack != null) {
|
stderr
|
||||||
message += '\n\n$taskErrorStack';
|
..writeln(message)
|
||||||
}
|
..writeln('\nStack trace:')
|
||||||
return new TaskResult.failure(message);
|
..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'
|
'Typography'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
final FileSystem _fs = new LocalFileSystem();
|
||||||
|
|
||||||
Future<Null> saveDurationsHistogram(List<Map<String, dynamic>> events) async {
|
Future<Null> saveDurationsHistogram(List<Map<String, dynamic>> events) async {
|
||||||
final Map<String, List<int>> durations = new Map<String, List<int>>();
|
final Map<String, List<int>> durations = new Map<String, List<int>>();
|
||||||
Map<String, dynamic> startEvent;
|
Map<String, dynamic> startEvent;
|
||||||
@ -87,9 +89,8 @@ Future<Null> saveDurationsHistogram(List<Map<String, dynamic>> events) async {
|
|||||||
|
|
||||||
// Save the durations Map to a file.
|
// Save the durations Map to a file.
|
||||||
final String destinationDirectory = 'build';
|
final String destinationDirectory = 'build';
|
||||||
final FileSystem fs = new LocalFileSystem();
|
await _fs.directory(destinationDirectory).create(recursive: true);
|
||||||
await fs.directory(destinationDirectory).create(recursive: true);
|
final File file = _fs.file(path.join(destinationDirectory, 'transition_durations.timeline.json'));
|
||||||
final File file = fs.file(path.join(destinationDirectory, 'transition_durations.timeline.json'));
|
|
||||||
await file.writeAsString(new JsonEncoder.withIndent(' ').convert(durations));
|
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
|
// Save the duration (in microseconds) of the first timeline Frame event
|
||||||
// that follows a 'Start Transition' event. The Gallery app adds a
|
// that follows a 'Start Transition' event. The Gallery app adds a
|
||||||
// 'Start Transition' event when a demo is launched (see GalleryItem).
|
// 'Start Transition' event when a demo is launched (see GalleryItem).
|
||||||
saveDurationsHistogram(timeline.json['traceEvents']);
|
|
||||||
|
|
||||||
TimelineSummary summary = new TimelineSummary.summarize(timeline);
|
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)));
|
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user