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

Unified Diff: lib/src/runner/parse_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/frontend/timeout.dart ('k') | test/backend/invoker_test.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 7f735deb037a3706e08678e85f6f1b7f68354d3d..fb84f4aab9ffe9ccc7302681cc62f4125c055a5a 100644
--- a/lib/src/runner/parse_metadata.dart
+++ b/lib/src/runner/parse_metadata.dart
@@ -103,11 +103,16 @@ class _Parser {
/// constructor for the annotation, if any.
Timeout _parseTimeout(Annotation annotation, String constructorName) {
_assertConstructorName(constructorName, 'Timeout', annotation,
- validNames: [null, 'factor']);
+ validNames: [null, 'factor', 'none']);
var description = 'Timeout';
if (constructorName != null) description += '.$constructorName';
+ if (constructorName == 'none') {
+ _assertNoArguments(annotation, description);
+ return Timeout.none;
+ }
+
_assertArguments(annotation.arguments, description, annotation,
positional: 1);
@@ -176,7 +181,8 @@ class _Parser {
var expressions = [];
if (value is ListLiteral) {
expressions = _parseList(value);
- } else if (value is InstanceCreationExpression) {
+ } else if (value is InstanceCreationExpression ||
+ value is PrefixedIdentifier) {
expressions = [value];
} else {
throw new SourceSpanFormatException(
@@ -187,23 +193,35 @@ class _Parser {
var timeout;
var skip;
for (var expression in expressions) {
- var className = expression is InstanceCreationExpression
- ? _resolveConstructor(
- expression.constructorName.type.name,
- expression.constructorName.name).first
- : null;
+ if (expression is InstanceCreationExpression) {
+ var className = _resolveConstructor(
+ expression.constructorName.type.name,
+ expression.constructorName.name).first;
+
+ if (className == 'Timeout') {
+ _assertSingle(timeout, 'Timeout', expression);
+ timeout = _parseTimeoutConstructor(expression);
+ continue;
+ } else if (className == 'Skip') {
+ _assertSingle(skip, 'Skip', expression);
+ skip = _parseSkipConstructor(expression);
+ continue;
+ }
+ } else if (expression is PrefixedIdentifier &&
+ expression.prefix.name == 'Timeout') {
+ if (expression.identifier.name != 'none') {
+ throw new SourceSpanFormatException(
+ 'Undefined value.', _spanFor(expression));
+ }
- if (className == 'Timeout') {
_assertSingle(timeout, 'Timeout', expression);
- timeout = _parseTimeoutConstructor(expression);
- } else if (className == 'Skip') {
- _assertSingle(skip, 'Skip', expression);
- skip = _parseSkipConstructor(expression);
- } else {
- throw new SourceSpanFormatException(
- 'Expected a Timeout or Skip.',
- _spanFor(expression));
+ timeout = Timeout.none;
+ continue;
}
+
+ throw new SourceSpanFormatException(
+ 'Expected a Timeout or Skip.',
+ _spanFor(expression));
}
return new Metadata.parse(timeout: timeout, skip: skip);
@@ -407,6 +425,13 @@ class _Parser {
return namedValues;
}
+ /// Assert that [annotation] (described by [name]) has no argument list.
+ void _assertNoArguments(Annotation annotation, String name) {
+ if (annotation.arguments == null) return;
+ throw new SourceSpanFormatException(
+ "$name doesn't take arguments.", _spanFor(annotation));
+ }
+
/// Parses a Map literal.
///
/// By default, returns [Expression] keys and values. These can be overridden
« no previous file with comments | « lib/src/frontend/timeout.dart ('k') | test/backend/invoker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698