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

Unified Diff: pkg/scheduled_test/lib/src/descriptor/nothing_descriptor.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: Code review changes. 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_descriptor.dart
diff --git a/pkg/scheduled_test/lib/src/descriptor/nothing_descriptor.dart b/pkg/scheduled_test/lib/src/descriptor/nothing_descriptor.dart
new file mode 100644
index 0000000000000000000000000000000000000000..00fa7061ce40b7cb4ec0a62386f9ccaccf623f61
--- /dev/null
+++ b/pkg/scheduled_test/lib/src/descriptor/nothing_descriptor.dart
@@ -0,0 +1,47 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library descriptor.async;
+
+import 'dart:async';
+import 'dart:io';
+
+import '../../../../../pkg/pathos/lib/path.dart' as path;
+
+import '../../descriptor.dart';
+import '../../scheduled_test.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 NothingDescriptor extends Descriptor {
+ NothingDescriptor(String name)
+ : super(name);
+
+ Future create([String parent]) => new Future.immediate(null);
+
+ Future validate([String parent]) => schedule(() => validateNow(parent),
+ "validating '$name' doesn't exist");
+
+ Future validateNow([String parent]) => new Future.of(() {
+ if (parent == null) parent = defaultRoot;
+ 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;
+ }
+ });
+
+ Stream<List<int>> load(String pathToLoad) => errorStream("Nothing "
+ "descriptors don't support load().");
+
+ Stream<List<int>> read() => errorStream("Nothing descriptors don't support "
+ "read().");
+
+ String describe() => "nothing at '$name'";
+}
« no previous file with comments | « pkg/scheduled_test/lib/src/descriptor/nothing.dart ('k') | pkg/scheduled_test/lib/src/descriptor/pattern_descriptor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698