Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Unified 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, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/backend/invoker.dart ('k') | lib/src/frontend/timeout.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/backend/metadata.dart
diff --git a/lib/src/backend/metadata.dart b/lib/src/backend/metadata.dart
index 0dc2d2922b849d70ee0b7db52a3755f2271fdc63..e6be71e93b416395896c71eebe992f9dd6e9b2ba 100644
--- a/lib/src/backend/metadata.dart
+++ b/lib/src/backend/metadata.dart
@@ -120,10 +120,7 @@ class Metadata {
: testOn = serialized['testOn'] == null
? PlatformSelector.all
: new PlatformSelector.parse(serialized['testOn']),
- timeout = serialized['timeout']['duration'] == null
- ? new Timeout.factor(serialized['timeout']['scaleFactor'])
- : new Timeout(new Duration(
- microseconds: serialized['timeout']['duration'])),
+ timeout = _deserializeTimeout(serialized['timeout']),
skip = serialized['skip'],
skipReason = serialized['skipReason'],
verboseTrace = serialized['verboseTrace'],
@@ -131,6 +128,15 @@ class Metadata {
key: (pair) => new PlatformSelector.parse(pair.first),
value: (pair) => new Metadata.deserialize(pair.last));
+ /// Deserializes timeout from the format returned by [_serializeTimeout].
+ static _deserializeTimeout(serialized) {
+ if (serialized == 'none') return Timeout.none;
+ var scaleFactor = serialized['scaleFactor'];
+ if (scaleFactor != null) return new Timeout.factor(scaleFactor);
+ return new Timeout(
+ new Duration(microseconds: serialized['duration']));
+ }
+
/// Return a new [Metadata] that merges [this] with [other].
///
/// If the two [Metadata]s have conflicting properties, [other] wins.
@@ -182,16 +188,22 @@ class Metadata {
return {
'testOn': testOn == PlatformSelector.all ? null : testOn.toString(),
- 'timeout': {
- 'duration': timeout.duration == null
- ? null
- : timeout.duration.inMicroseconds,
- 'scaleFactor': timeout.scaleFactor
- },
+ 'timeout': _serializeTimeout(timeout),
'skip': skip,
'skipReason': skipReason,
'verboseTrace': verboseTrace,
'onPlatform': serializedOnPlatform
};
}
+
+ /// Serializes timeout into a JSON-safe object.
+ _serializeTimeout(Timeout timeout) {
+ if (timeout == Timeout.none) return 'none';
+ return {
+ 'duration': timeout.duration == null
+ ? null
+ : timeout.duration.inMicroseconds,
+ 'scaleFactor': timeout.scaleFactor
+ };
+ }
}
« 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
This is Rietveld 408576698