Chromium Code Reviews

Side by Side Diff: lib/src/backend/metadata.dart

Issue 1256833003: Add Timeout.none. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Fix invoker_test. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « lib/src/backend/invoker.dart ('k') | lib/src/frontend/timeout.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.backend.metadata; 5 library test.backend.metadata;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import '../backend/operating_system.dart'; 9 import '../backend/operating_system.dart';
10 import '../backend/test_platform.dart'; 10 import '../backend/test_platform.dart';
(...skipping 102 matching lines...)
113 throw new ArgumentError( 113 throw new ArgumentError(
114 '"skip" must be a String or a bool, was "$skip".'); 114 '"skip" must be a String or a bool, was "$skip".');
115 } 115 }
116 } 116 }
117 117
118 /// Dezerializes the result of [Metadata.serialize] into a new [Metadata]. 118 /// Dezerializes the result of [Metadata.serialize] into a new [Metadata].
119 Metadata.deserialize(serialized) 119 Metadata.deserialize(serialized)
120 : testOn = serialized['testOn'] == null 120 : testOn = serialized['testOn'] == null
121 ? PlatformSelector.all 121 ? PlatformSelector.all
122 : new PlatformSelector.parse(serialized['testOn']), 122 : new PlatformSelector.parse(serialized['testOn']),
123 timeout = serialized['timeout']['duration'] == null 123 timeout = _deserializeTimeout(serialized['timeout']),
124 ? new Timeout.factor(serialized['timeout']['scaleFactor'])
125 : new Timeout(new Duration(
126 microseconds: serialized['timeout']['duration'])),
127 skip = serialized['skip'], 124 skip = serialized['skip'],
128 skipReason = serialized['skipReason'], 125 skipReason = serialized['skipReason'],
129 verboseTrace = serialized['verboseTrace'], 126 verboseTrace = serialized['verboseTrace'],
130 onPlatform = new Map.fromIterable(serialized['onPlatform'], 127 onPlatform = new Map.fromIterable(serialized['onPlatform'],
131 key: (pair) => new PlatformSelector.parse(pair.first), 128 key: (pair) => new PlatformSelector.parse(pair.first),
132 value: (pair) => new Metadata.deserialize(pair.last)); 129 value: (pair) => new Metadata.deserialize(pair.last));
133 130
131 /// Deserializes timeout from the format returned by [_serializeTimeout].
132 static _deserializeTimeout(serialized) {
133 if (serialized == 'none') return Timeout.none;
134 var scaleFactor = serialized['scaleFactor'];
135 if (scaleFactor != null) return new Timeout.factor(scaleFactor);
136 return new Timeout(
137 new Duration(microseconds: serialized['duration']));
138 }
139
134 /// Return a new [Metadata] that merges [this] with [other]. 140 /// Return a new [Metadata] that merges [this] with [other].
135 /// 141 ///
136 /// If the two [Metadata]s have conflicting properties, [other] wins. 142 /// If the two [Metadata]s have conflicting properties, [other] wins.
137 Metadata merge(Metadata other) => 143 Metadata merge(Metadata other) =>
138 new Metadata( 144 new Metadata(
139 testOn: testOn.intersect(other.testOn), 145 testOn: testOn.intersect(other.testOn),
140 timeout: timeout.merge(other.timeout), 146 timeout: timeout.merge(other.timeout),
141 skip: skip || other.skip, 147 skip: skip || other.skip,
142 verboseTrace: verboseTrace || other.verboseTrace, 148 verboseTrace: verboseTrace || other.verboseTrace,
143 skipReason: other.skipReason == null ? skipReason : other.skipReason, 149 skipReason: other.skipReason == null ? skipReason : other.skipReason,
(...skipping 31 matching lines...)
175 /// [new Metadata.deserialize]. 181 /// [new Metadata.deserialize].
176 serialize() { 182 serialize() {
177 // Make this a list to guarantee that the order is preserved. 183 // Make this a list to guarantee that the order is preserved.
178 var serializedOnPlatform = []; 184 var serializedOnPlatform = [];
179 onPlatform.forEach((key, value) { 185 onPlatform.forEach((key, value) {
180 serializedOnPlatform.add([key.toString(), value.serialize()]); 186 serializedOnPlatform.add([key.toString(), value.serialize()]);
181 }); 187 });
182 188
183 return { 189 return {
184 'testOn': testOn == PlatformSelector.all ? null : testOn.toString(), 190 'testOn': testOn == PlatformSelector.all ? null : testOn.toString(),
185 'timeout': { 191 'timeout': _serializeTimeout(timeout),
186 'duration': timeout.duration == null
187 ? null
188 : timeout.duration.inMicroseconds,
189 'scaleFactor': timeout.scaleFactor
190 },
191 'skip': skip, 192 'skip': skip,
192 'skipReason': skipReason, 193 'skipReason': skipReason,
193 'verboseTrace': verboseTrace, 194 'verboseTrace': verboseTrace,
194 'onPlatform': serializedOnPlatform 195 'onPlatform': serializedOnPlatform
195 }; 196 };
196 } 197 }
198
199 /// Serializes timeout into a JSON-safe object.
200 _serializeTimeout(Timeout timeout) {
201 if (timeout == Timeout.none) return 'none';
202 return {
203 'duration': timeout.duration == null
204 ? null
205 : timeout.duration.inMicroseconds,
206 'scaleFactor': timeout.scaleFactor
207 };
208 }
197 } 209 }
OLDNEW
« no previous file with comments | « lib/src/backend/invoker.dart ('k') | lib/src/frontend/timeout.dart » ('j') | no next file with comments »

Powered by Google App Engine