Index: lib/src/runner/configuration/load.dart |
diff --git a/lib/src/runner/configuration/load.dart b/lib/src/runner/configuration/load.dart |
index d2def18469e06f6540022fee732263844aec1fd4..c3d2ff1f2e23a39c5508195076b8f4dc213d17ca 100644 |
--- a/lib/src/runner/configuration/load.dart |
+++ b/lib/src/runner/configuration/load.dart |
@@ -4,6 +4,7 @@ |
import 'dart:io'; |
+import 'package:glob/glob.dart'; |
import 'package:path/path.dart' as p; |
import 'package:source_span/source_span.dart'; |
import 'package:yaml/yaml.dart'; |
@@ -70,7 +71,14 @@ class _ConfigurationLoader { |
return TestPlatform.find(platformNode.value); |
}); |
- // TODO(nweiz): Add support for using globs to define defaults paths to run. |
+ var paths = _getList("paths", (pathNode) { |
+ _validate(pathNode, "Paths must be strings.", (value) => value is String); |
+ _validate(pathNode, "Paths must be relative.", p.url.isRelative); |
+ |
+ return _parseNode(pathNode, "path", p.fromUri); |
+ }); |
+ |
+ var filename = _parseValue("filename", (value) => new Glob(value)); |
return new Configuration( |
verboseTrace: verboseTrace, |
@@ -79,7 +87,9 @@ class _ConfigurationLoader { |
pubServePort: pubServePort, |
concurrency: concurrency, |
timeout: timeout, |
- platforms: platforms); |
+ platforms: platforms, |
+ paths: paths, |
+ filename: filename); |
} |
/// Throws an exception with [message] if [test] returns `false` when passed |
@@ -132,22 +142,33 @@ class _ConfigurationLoader { |
return node.nodes.map(forElement).toList(); |
} |
- /// Asserts that [field] is a string, passes it to [parse], and returns the |
- /// result. |
+ /// Asserts that [node] is a string, passes its value to [parse], and returns |
+ /// the result. |
/// |
- /// If [parse] throws a [FormatException], it's wrapped to include [field]'s |
+ /// If [parse] throws a [FormatException], it's wrapped to include [node]'s |
/// span. |
- _parseValue(String field, parse(value)) { |
- var value = _getString(field); |
- if (value == null) return null; |
+ _parseNode(YamlNode node, String name, parse(String value)) { |
+ _validate(node, "$name must be a string.", (value) => value is String); |
try { |
- return parse(value); |
+ return parse(node.value); |
} on FormatException catch (error) { |
- _error('Invalid $field: ${error.message}', field); |
+ throw new SourceSpanFormatException( |
+ 'Invalid $name: ${error.message}', node.span, _source); |
} |
} |
+ /// Asserts that [field] is a string, passes it to [parse], and returns the |
+ /// result. |
+ /// |
+ /// If [parse] throws a [FormatException], it's wrapped to include [field]'s |
+ /// span. |
+ _parseValue(String field, parse(String value)) { |
+ var node = _document.nodes[field]; |
+ if (node == null) return null; |
+ return _parseNode(node, field, parse); |
+ } |
+ |
/// Throws a [SourceSpanFormatException] with [message] about [field]. |
void _error(String message, String field) { |
throw new SourceSpanFormatException( |