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

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

Issue 1090513002: Support configuring timeouts per-test and -group. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 8 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 unified diff | Download patch
« 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 '../frontend/timeout.dart';
7 import 'platform_selector.dart'; 8 import 'platform_selector.dart';
8 9
9 /// Metadata for a test or test suite. 10 /// Metadata for a test or test suite.
10 /// 11 ///
11 /// This metadata comes from declarations on the test itself; it doesn't include 12 /// This metadata comes from declarations on the test itself; it doesn't include
12 /// configuration from the user. 13 /// configuration from the user.
13 class Metadata { 14 class Metadata {
14 /// The selector indicating which platforms the suite supports. 15 /// The selector indicating which platforms the suite supports.
15 final PlatformSelector testOn; 16 final PlatformSelector testOn;
16 17
18 /// The modification to the timeout for the test or suite.
19 final Timeout timeout;
20
17 /// Creates new Metadata. 21 /// Creates new Metadata.
18 /// 22 ///
19 /// [testOn] defaults to [PlatformSelector.all]. 23 /// [testOn] defaults to [PlatformSelector.all].
20 Metadata({PlatformSelector testOn}) 24 Metadata({PlatformSelector testOn, Timeout timeout})
21 : testOn = testOn == null ? PlatformSelector.all : testOn; 25 : testOn = testOn == null ? PlatformSelector.all : testOn,
26 timeout = timeout == null ? new Timeout.factor(1) : timeout;
22 27
23 /// Parses metadata fields from strings. 28 /// Creates a new Metadata, but with fields parsed from strings where
29 /// applicable.
24 /// 30 ///
25 /// Throws a [FormatException] if any field is invalid. 31 /// Throws a [FormatException] if any field is invalid.
26 Metadata.parse({String testOn}) 32 Metadata.parse({String testOn, Timeout timeout})
27 : this( 33 : this(
28 testOn: testOn == null ? null : new PlatformSelector.parse(testOn)); 34 testOn: testOn == null ? null : new PlatformSelector.parse(testOn),
35 timeout: timeout);
29 36
30 /// Dezerializes the result of [Metadata.serialize] into a new [Metadata]. 37 /// Dezerializes the result of [Metadata.serialize] into a new [Metadata].
31 Metadata.deserialize(serialized) 38 Metadata.deserialize(serialized)
32 : this.parse(testOn: serialized['testOn']); 39 : this.parse(
40 testOn: serialized['testOn'],
41 timeout: serialized['timeout']['duration'] == null
42 ? new Timeout.factor(serialized['timeout']['scaleFactor'])
43 : new Timeout(new Duration(
44 microseconds: serialized['timeout']['duration'])));
33 45
34 /// Return a new [Metadata] that merges [this] with [other]. 46 /// Return a new [Metadata] that merges [this] with [other].
35 /// 47 ///
36 /// If the two [Metadata]s have conflicting properties, [other] wins. 48 /// If the two [Metadata]s have conflicting properties, [other] wins.
37 Metadata merge(Metadata other) => 49 Metadata merge(Metadata other) =>
38 new Metadata(testOn: testOn.intersect(other.testOn)); 50 new Metadata(
51 testOn: testOn.intersect(other.testOn),
52 timeout: timeout.merge(other.timeout));
39 53
40 /// Serializes [this] into a JSON-safe object that can be deserialized using 54 /// Serializes [this] into a JSON-safe object that can be deserialized using
41 /// [new Metadata.deserialize]. 55 /// [new Metadata.deserialize].
42 serialize() => { 56 serialize() => {
43 'testOn': testOn == PlatformSelector.all ? null : testOn.toString() 57 'testOn': testOn == PlatformSelector.all ? null : testOn.toString(),
58 'timeout': {
59 'duration': timeout.duration == null
60 ? null
61 : timeout.duration.inMicroseconds,
62 'scaleFactor': timeout.scaleFactor
63 }
44 }; 64 };
45 } 65 }
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
This is Rietveld 408576698