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

Unified Diff: pkg/scheduled_test/lib/src/descriptor/nothing.dart

Issue 12853005: Change the way Patterns work in scheduled_test/descriptor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add Nothing.validateNow. Created 7 years, 9 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
Index: pkg/scheduled_test/lib/src/descriptor/nothing.dart
diff --git a/pkg/scheduled_test/lib/src/descriptor/nothing.dart b/pkg/scheduled_test/lib/src/descriptor/nothing.dart
index 9a1f1b4c6fe48c1a69b8a5889989f088ddcd164b..9b9254350d2048573171c9905d487043ce5d20a2 100644
--- a/pkg/scheduled_test/lib/src/descriptor/nothing.dart
+++ b/pkg/scheduled_test/lib/src/descriptor/nothing.dart
@@ -12,43 +12,30 @@ import '../../../../../pkg/pathos/lib/path.dart' as path;
import '../../descriptor.dart' as descriptor;
import '../../scheduled_test.dart';
import '../utils.dart';
-import 'utils.dart';
/// A descriptor that validates that no file exists with the given name.
/// Creating this descriptor is a no-op and loading from it is invalid.
class Nothing extends descriptor.Entry {
- Nothing(Pattern name)
+ Nothing(String name)
: super(name);
Future create([String parent]) => new Future.immediate(null);
- Future validate([String parent]) => schedule(() {
+ Future validate([String parent]) => schedule(() => validateNow(parent),
+ "validating '$name' doesn't exist");
+
+ Future validateNow([String parent]) => new Future.of(() {
if (parent == null) parent = descriptor.defaultRoot;
- if (name is String) {
- var fullPath = path.join(parent, name);
- if (new File(fullPath).existsSync()) {
- throw "Expected nothing to exist at '$fullPath', but found a file.";
- } else if (new Directory(fullPath).existsSync()) {
- throw "Expected nothing to exist at '$fullPath', but found a "
- "directory.";
- } else {
- return;
- }
+ var fullPath = path.join(parent, name);
+ if (new File(fullPath).existsSync()) {
+ throw "Expected nothing to exist at '$fullPath', but found a file.";
+ } else if (new Directory(fullPath).existsSync()) {
+ throw "Expected nothing to exist at '$fullPath', but found a "
+ "directory.";
+ } else {
+ return;
}
-
- return new Directory(parent).list().toList().then((entries) {
- var matchingEntries = entries
- .map((entry) => entry is File ? entry.fullPathSync() : entry.path)
- .where((entry) => path.basename(entry).contains(name))
- .toList();
- matchingEntries.sort();
-
- if (matchingEntries.length == 0) return;
- throw "Expected nothing to exist in '$parent' matching $nameDescription, "
- "but found:\n"
- "${matchingEntries.map((entry) => '* $entry').join('\n')}";
- });
- }, "validating $nameDescription doesn't exist");
+ });
Stream<List<int>> load(String pathToLoad) => errorStream("Nothing "
"descriptors don't support load().");
@@ -56,5 +43,5 @@ class Nothing extends descriptor.Entry {
Stream<List<int>> read() => errorStream("Nothing descriptors don't support "
"read().");
- String describe() => "nothing at $nameDescription";
+ String describe() => "nothing at '$name'";
}

Powered by Google App Engine
This is Rietveld 408576698