Chromium Code Reviews| Index: lib/src/backend/metadata.dart |
| diff --git a/lib/src/backend/metadata.dart b/lib/src/backend/metadata.dart |
| index 7fb37ba8402133feab972f7ddd96d94fdd8e9462..d3991e23e884d7b66478f46bf9d974797ffe70c2 100644 |
| --- a/lib/src/backend/metadata.dart |
| +++ b/lib/src/backend/metadata.dart |
| @@ -33,6 +33,9 @@ class Metadata { |
| /// The reason the test or suite should be skipped, if given. |
| final String skipReason; |
| + /// A set of tags attached to a test |
| + final List<String> tags; |
| + |
| /// Platform-specific metadata. |
| /// |
| /// Each key identifies a platform, and its value identifies the specific |
| @@ -88,27 +91,30 @@ class Metadata { |
| /// [testOn] defaults to [PlatformSelector.all]. |
| Metadata({PlatformSelector testOn, Timeout timeout, bool skip: false, |
| this.verboseTrace: false, this.skipReason, |
| - Map<PlatformSelector, Metadata> onPlatform}) |
| + Map<PlatformSelector, Metadata> onPlatform, List<String> tags}) |
| : testOn = testOn == null ? PlatformSelector.all : testOn, |
| timeout = timeout == null ? const Timeout.factor(1) : timeout, |
| skip = skip, |
| onPlatform = onPlatform == null |
| ? const {} |
| - : new UnmodifiableMapView(onPlatform); |
| + : new UnmodifiableMapView(onPlatform), |
| + this.tags = tags ?? const <String>[]; |
|
nweiz
2015/10/13 23:28:12
Unfortunately "??" isn't usable here. Anything tha
yjbanov
2015/10/30 20:13:59
Done.
|
| /// Creates a new Metadata, but with fields parsed from caller-friendly values |
| /// where applicable. |
| /// |
| /// Throws a [FormatException] if any field is invalid. |
| Metadata.parse({String testOn, Timeout timeout, skip, |
| - this.verboseTrace: false, Map<String, dynamic> onPlatform}) |
| + this.verboseTrace: false, Map<String, dynamic> onPlatform, |
| + List<String> tags}) |
| : testOn = testOn == null |
| ? PlatformSelector.all |
| : new PlatformSelector.parse(testOn), |
| timeout = timeout == null ? const Timeout.factor(1) : timeout, |
| skip = skip != null && skip != false, |
| skipReason = skip is String ? skip : null, |
| - onPlatform = _parseOnPlatform(onPlatform) { |
| + onPlatform = _parseOnPlatform(onPlatform), |
| + this.tags = tags ?? const <String>[] { |
| if (skip != null && skip is! String && skip is! bool) { |
| throw new ArgumentError( |
| '"skip" must be a String or a bool, was "$skip".'); |
| @@ -124,6 +130,7 @@ class Metadata { |
| skip = serialized['skip'], |
| skipReason = serialized['skipReason'], |
| verboseTrace = serialized['verboseTrace'], |
| + tags = serialized['tags'] ?? const <String>[], |
| onPlatform = new Map.fromIterable(serialized['onPlatform'], |
| key: (pair) => new PlatformSelector.parse(pair.first), |
| value: (pair) => new Metadata.deserialize(pair.last)); |
| @@ -147,7 +154,8 @@ class Metadata { |
| skip: skip || other.skip, |
| verboseTrace: verboseTrace || other.verboseTrace, |
| skipReason: other.skipReason == null ? skipReason : other.skipReason, |
| - onPlatform: mergeMaps(onPlatform, other.onPlatform)); |
| + onPlatform: mergeMaps(onPlatform, other.onPlatform), |
| + tags: mergeLists(tags, other.tags)); |
| /// Returns a copy of [this] with the given fields changed. |
| Metadata change({PlatformSelector testOn, Timeout timeout, bool skip, |
| @@ -192,7 +200,8 @@ class Metadata { |
| 'skip': skip, |
| 'skipReason': skipReason, |
| 'verboseTrace': verboseTrace, |
| - 'onPlatform': serializedOnPlatform |
| + 'onPlatform': serializedOnPlatform, |
| + 'tags': tags.isEmpty ? null : tags, |
|
nweiz
2015/10/13 23:28:12
Just pass an empty list here rather than adding a
yjbanov
2015/10/30 20:13:59
Done.
|
| }; |
| } |