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

Unified Diff: lib/src/backend/metadata.dart

Issue 1405633004: feature: tag tests; choose tags on command line Base URL: git@github.com:yjbanov/test.git@tags
Patch Set: Created 5 years, 2 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
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.
};
}

Powered by Google App Engine
This is Rietveld 408576698