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

Unified Diff: lib/src/runner/configuration/load.dart

Issue 1668573003: Add configuration support for choosing test paths. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: cr Created 4 years, 10 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/runner/configuration.dart ('k') | lib/src/runner/configuration/values.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
« no previous file with comments | « lib/src/runner/configuration.dart ('k') | lib/src/runner/configuration/values.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698