| Index: pkg/scheduled_test/lib/src/descriptor/directory_descriptor.dart
|
| diff --git a/pkg/scheduled_test/lib/src/descriptor/directory_descriptor.dart b/pkg/scheduled_test/lib/src/descriptor/directory_descriptor.dart
|
| index 1dbb7a4b322dfa4c6ce6487b5ea5cb4c41dea513..c8565e721d9bc7555c50226d7c0c65c67560ee92 100644
|
| --- a/pkg/scheduled_test/lib/src/descriptor/directory_descriptor.dart
|
| +++ b/pkg/scheduled_test/lib/src/descriptor/directory_descriptor.dart
|
| @@ -43,8 +43,15 @@ class DirectoryDescriptor extends Descriptor {
|
| throw "Directory not found: '$fullPath'.";
|
| }
|
|
|
| - return Future.wait(
|
| - contents.map((entry) => entry.validateNow(fullPath)).toList());
|
| + return Future.wait(contents.map((entry) {
|
| + return new Future.of(() => entry.validateNow(fullPath))
|
| + .then((_) => null)
|
| + .catchError((e) => e.error);
|
| + })).then((results) {
|
| + var errors = results.where((e) => e != null);
|
| + if (errors.isEmpty) return;
|
| + throw _DirectoryValidationError.merge(errors);
|
| + });
|
| }
|
|
|
| Stream<List<int>> load(String pathToLoad) {
|
| @@ -96,3 +103,26 @@ class DirectoryDescriptor extends Descriptor {
|
| return buffer.toString();
|
| }
|
| }
|
| +
|
| +/// A class for formatting errors thrown by [DirectoryDescriptor].
|
| +class _DirectoryValidationError {
|
| + final Collection<String> errors;
|
| +
|
| + /// Flatten nested [_DirectoryValidationError]s in [errors] to create a single
|
| + /// list of errors.
|
| + static _DirectoryValidationError merge(Iterable errors) {
|
| + return new _DirectoryValidationError(errors.expand((error) {
|
| + if (error is _DirectoryValidationError) return error.errors;
|
| + return [error];
|
| + }));
|
| + }
|
| +
|
| + _DirectoryValidationError(Iterable errors)
|
| + : errors = errors.map((e) => e.toString()).toList();
|
| +
|
| + String toString() {
|
| + if (errors.length == 1) return errors.single;
|
| + return errors.map((e) => prefixLines(e, prefix: ' ', firstPrefix: '* '))
|
| + .join('\n');
|
| + }
|
| +}
|
|
|