Unverified Commit 61460d25 authored by Jim Graham's avatar Jim Graham Committed by GitHub

preserve detailFiles entry in TaskResult JSON (#70668)

* preserve detailFiles entry in TaskResult JSON
parent 4cbafda8
......@@ -10,7 +10,7 @@ class TaskResult {
/// Constructs a successful result.
TaskResult.success(this.data, {
this.benchmarkScoreKeys = const <String>[],
this.detailFiles,
this.detailFiles = const <String>[],
})
: succeeded = true,
message = 'success' {
......@@ -29,11 +29,14 @@ class TaskResult {
}
/// Constructs a successful result using JSON data stored in a file.
factory TaskResult.successFromFile(File file,
{List<String> benchmarkScoreKeys}) {
factory TaskResult.successFromFile(File file, {
List<String> benchmarkScoreKeys = const <String>[],
List<String> detailFiles = const <String>[],
}) {
return TaskResult.success(
json.decode(file.readAsStringSync()) as Map<String, dynamic>,
benchmarkScoreKeys: benchmarkScoreKeys,
detailFiles: detailFiles,
);
}
......@@ -42,8 +45,11 @@ class TaskResult {
final bool success = json['success'] as bool;
if (success) {
final List<String> benchmarkScoreKeys = (json['benchmarkScoreKeys'] as List<dynamic> ?? <String>[]).cast<String>();
final List<String> detailFiles = (json['detailFiles'] as List<dynamic> ?? <String>[]).cast<String>();
return TaskResult.success(json['data'] as Map<String, dynamic>,
benchmarkScoreKeys: benchmarkScoreKeys);
benchmarkScoreKeys: benchmarkScoreKeys,
detailFiles: detailFiles,
);
}
return TaskResult.failure(json['reason'] as String);
......@@ -54,7 +60,7 @@ class TaskResult {
: succeeded = false,
data = null,
detailFiles = null,
benchmarkScoreKeys = const <String>[];
benchmarkScoreKeys = null;
/// Whether the task succeeded.
final bool succeeded;
......@@ -98,8 +104,7 @@ class TaskResult {
if (succeeded) {
json['data'] = data;
if (detailFiles != null)
json['detailFiles'] = detailFiles;
json['detailFiles'] = detailFiles;
json['benchmarkScoreKeys'] = benchmarkScoreKeys;
} else {
json['reason'] = message;
......
......@@ -119,15 +119,14 @@ class GalleryTransitionTest {
summary['transitions'] = transitions;
summary['missed_transition_count'] = _countMissedTransitions(transitions);
}
final List<String> detailFiles = <String>[
if (transitionDurationFile != null)
'${galleryDirectory.path}/build/$transitionDurationFile.json',
if (timelineTraceFile != null)
'${galleryDirectory.path}/build/$timelineTraceFile.json'
];
return TaskResult.success(summary,
detailFiles: detailFiles.isNotEmpty ? detailFiles : null,
detailFiles: <String>[
if (transitionDurationFile != null)
'${galleryDirectory.path}/build/$transitionDurationFile.json',
if (timelineTraceFile != null)
'${galleryDirectory.path}/build/$timelineTraceFile.json'
],
benchmarkScoreKeys: <String>[
if (transitionDurationFile != null)
'missed_transition_count',
......
......@@ -640,10 +640,6 @@ class PerfTest {
final Map<String, dynamic> data = json.decode(
file('$testDirectory/build/$resultFilename.json').readAsStringSync(),
) as Map<String, dynamic>;
final List<String> detailFiles = <String>[
if (saveTraceFile)
'$testDirectory/build/$traceFilename.json',
];
if (data['frame_count'] as int < 5) {
return TaskResult.failure(
......@@ -657,7 +653,10 @@ class PerfTest {
final bool isAndroid = deviceOperatingSystem == DeviceOperatingSystem.android;
return TaskResult.success(
data,
detailFiles: detailFiles.isNotEmpty ? detailFiles : null,
detailFiles: <String>[
if (saveTraceFile)
'$testDirectory/build/$traceFilename.json',
],
benchmarkScoreKeys: benchmarkScoreKeys ?? <String>[
..._kCommonScoreKeys,
'average_vsync_transitions_missed',
......
......@@ -17,6 +17,7 @@ void main() {
'not_a_metric': 'something',
},
'benchmarkScoreKeys': <String>['i', 'j'],
'detailFiles': <String>[],
};
final TaskResult result = TaskResult.fromJson(expectedJson);
expect(result.toJson(), expectedJson);
......@@ -30,6 +31,7 @@ void main() {
'success': true,
'data': null,
'benchmarkScoreKeys': <String>[],
'detailFiles': <String>[],
};
expect(result.toJson(), expectedJson);
});
......
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