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

Unified Diff: lib/src/runner/parse_metadata.dart

Issue 1405633004: feature: tag tests; choose tags on command line Base URL: git@github.com:yjbanov/test.git@tags
Patch Set: address comments Created 5 years, 1 month 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/runner/configuration.dart ('k') | lib/src/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/runner/parse_metadata.dart
diff --git a/lib/src/runner/parse_metadata.dart b/lib/src/runner/parse_metadata.dart
index fb84f4aab9ffe9ccc7302681cc62f4125c055a5a..f5c4d301340a9bb4591f89782193bc1d71ab8811 100644
--- a/lib/src/runner/parse_metadata.dart
+++ b/lib/src/runner/parse_metadata.dart
@@ -55,6 +55,7 @@ class _Parser {
var testOn;
var skip;
var onPlatform;
+ var tags;
for (var annotation in _annotations) {
var pair = _resolveConstructor(
@@ -74,6 +75,9 @@ class _Parser {
} else if (name == 'OnPlatform') {
_assertSingle(onPlatform, 'OnPlatform', annotation);
onPlatform = _parseOnPlatform(annotation, constructorName);
+ } else if (name == 'Tags') {
+ _assertSingle(tags, 'Tags', annotation);
+ tags = _parseTags(annotation, constructorName);
}
}
@@ -82,7 +86,8 @@ class _Parser {
timeout: timeout,
skip: skip != null,
skipReason: skip is String ? skip : null,
- onPlatform: onPlatform);
+ onPlatform: onPlatform,
+ tags: tags);
}
/// Parses a `@TestOn` annotation.
@@ -163,6 +168,27 @@ class _Parser {
return args.isEmpty ? true : _parseString(args.first).stringValue;
}
+ /// Parses a `@Tags` annotation.
+ ///
+ /// [annotation] is the annotation. [constructorName] is the name of the named
+ /// constructor for the annotation, if any.
+ Set<String> _parseTags(Annotation annotation, String constructorName) {
+ _assertConstructorName(constructorName, 'Tags', annotation);
+ _assertArguments(annotation.arguments, 'Tags', annotation, positional: 1);
+ var arg = annotation.arguments.arguments.first;
+ if (arg is ListLiteral) {
+ var tagExpressions = _parseList(arg);
+ return new Set<String>.from(
+ tagExpressions.map((tagExpr) => _parseString(tagExpr).stringValue));
+ } else if (arg is StringLiteral) {
+ return new Set<String>.from([_parseString(arg).stringValue]);
+ } else {
+ throw new SourceSpanFormatException(
+ 'Only String or List literal allowed as @Tags argument',
+ _spanFor(arg));
+ }
+ }
+
/// Parses an `@OnPlatform` annotation.
///
/// [annotation] is the annotation. [constructorName] is the name of the named
« no previous file with comments | « lib/src/runner/configuration.dart ('k') | lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698