Chromium Code Reviews| 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 97f8c92341c5f78a573887bccc5c911d625692b3..d3c3cdd4b14a1a4b99a45d96198d6d5ed13c02ee 100644 |
| --- a/pkg/scheduled_test/lib/src/descriptor/directory_descriptor.dart |
| +++ b/pkg/scheduled_test/lib/src/descriptor/directory_descriptor.dart |
| @@ -17,7 +17,7 @@ import '../utils.dart'; |
| final path.Builder _path = new path.Builder(style: path.Style.posix); |
| /// A descriptor describing a directory containing multiple files. |
| -class DirectoryDescriptor extends Descriptor { |
| +class DirectoryDescriptor extends Descriptor implements LoadableDescriptor { |
| /// The entries contained within this directory. This is intentionally |
| /// mutable. |
| final List<Descriptor> contents; |
| @@ -67,13 +67,20 @@ class DirectoryDescriptor extends Descriptor { |
| throw "Can't load '$pathToLoad' from within '$name'."; |
|
Bob Nystrom
2013/06/04 15:45:53
And this.
|
| } |
| - var matchingEntries = contents.where((entry) => |
| - entry.name == split.first).toList(); |
| + var requiresReadable = split.length == 1; |
| + var matchingEntries = contents.where((entry) { |
| + return entry.name == split.first && (requiresReadable ? |
| + entry is ReadableDescriptor : |
| + entry is LoadableDescriptor); |
|
Bob Nystrom
2013/06/04 15:45:53
Is DirectoryDescriptor the only thing that impleme
nweiz
2013/06/04 18:26:45
I want to support directory-like descriptors that
|
| + }).toList(); |
| + var adjective = requiresReadable ? 'readable' : 'loadable'; |
| if (matchingEntries.length == 0) { |
| - throw "Couldn't find an entry named '${split.first}' within '$name'."; |
| + throw "Couldn't find a $adjective entry named '${split.first}' within " |
| + "'$name'."; |
| } else if (matchingEntries.length > 1) { |
| - throw "Found multiple entries named '${split.first}' within '$name'."; |
| + throw "Found multiple $adjective entries named '${split.first}' within " |
| + "'$name'."; |
| } else { |
| var remainingPath = split.sublist(1); |
| if (remainingPath.isEmpty) { |
| @@ -85,9 +92,6 @@ class DirectoryDescriptor extends Descriptor { |
| })); |
| } |
| - Stream<List<int>> read() => errorStream("Can't read the contents of '$name': " |
| - "is a directory."); |
| - |
| String describe() { |
| if (contents.isEmpty) return name; |