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

Side by Side Diff: pkg/scheduled_test/lib/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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// A library for declaratively describing a filesystem structure, usually for 5 /// A library for declaratively describing a filesystem structure, usually for
6 /// the purpose of creating or validating it as part of a scheduled test. 6 /// the purpose of creating or validating it as part of a scheduled test.
7 /// 7 ///
8 /// You can use [dir] and [file] to define a filesystem structure. Then, you can 8 /// You can use [dir] and [file] to define a filesystem structure. Then, you can
9 /// call [Entry.create] to schedule a task that will create that structure on 9 /// call [Entry.create] to schedule a task that will create that structure on
10 /// the physical filesystem, or [Entry.validate] to schedule an assertion that 10 /// the physical filesystem, or [Entry.validate] to schedule an assertion that
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 /// currentSchedule.onComplete.schedule(() { 55 /// currentSchedule.onComplete.schedule(() {
56 /// d.defaultRoot = null; 56 /// d.defaultRoot = null;
57 /// return tempDir.delete(recursive: true); 57 /// return tempDir.delete(recursive: true);
58 /// }); 58 /// });
59 /// }); 59 /// });
60 /// 60 ///
61 /// // ... 61 /// // ...
62 /// } 62 /// }
63 library descriptor; 63 library descriptor;
64 64
65 import 'dart:core' as core show Pattern;
66 import 'dart:core' hide Pattern;
65 import 'dart:async'; 67 import 'dart:async';
66 68
67 import '../../../pkg/pathos/lib/path.dart' as path; 69 import '../../../pkg/pathos/lib/path.dart' as path;
68 70
69 import 'scheduled_test.dart'; 71 import 'scheduled_test.dart';
70 import 'src/descriptor/async.dart'; 72 import 'src/descriptor/async.dart';
71 import 'src/descriptor/directory.dart'; 73 import 'src/descriptor/directory.dart';
72 import 'src/descriptor/entry.dart'; 74 import 'src/descriptor/entry.dart';
73 import 'src/descriptor/file.dart'; 75 import 'src/descriptor/file.dart';
74 import 'src/descriptor/nothing.dart'; 76 import 'src/descriptor/nothing.dart';
77 import 'src/descriptor/pattern.dart';
75 78
76 export 'src/descriptor/async.dart'; 79 export 'src/descriptor/async.dart';
77 export 'src/descriptor/directory.dart'; 80 export 'src/descriptor/directory.dart';
78 export 'src/descriptor/entry.dart'; 81 export 'src/descriptor/entry.dart';
79 export 'src/descriptor/file.dart'; 82 export 'src/descriptor/file.dart';
80 export 'src/descriptor/nothing.dart'; 83 export 'src/descriptor/nothing.dart';
84 export 'src/descriptor/pattern.dart';
81 85
82 /// The root path for descriptors. Top-level descriptors will be created and 86 /// The root path for descriptors. Top-level descriptors will be created and
83 /// validated at this path. Defaults to the current working directory. 87 /// validated at this path. Defaults to the current working directory.
84 /// 88 ///
85 /// If this is set to `null`, it will reset itself to the current working 89 /// If this is set to `null`, it will reset itself to the current working
86 /// directory. 90 /// directory.
87 String get defaultRoot => _defaultRoot == null ? path.current : _defaultRoot; 91 String get defaultRoot => _defaultRoot == null ? path.current : _defaultRoot;
88 set defaultRoot(String value) { 92 set defaultRoot(String value) {
89 _defaultRoot = value; 93 _defaultRoot = value;
90 } 94 }
91 String _defaultRoot; 95 String _defaultRoot;
92 96
93 /// Creates a new text [File] descriptor with [name] and [contents]. 97 /// Creates a new text [File] descriptor with [name] and [contents].
94 File file(Pattern name, [String contents='']) => new File(name, contents); 98 File file(String name, [String contents='']) => new File(name, contents);
95 99
96 /// Creates a new binary [File] descriptor with [name] and [contents]. 100 /// Creates a new binary [File] descriptor with [name] and [contents].
97 File binaryFile(Pattern name, List<int> contents) => 101 File binaryFile(String name, List<int> contents) =>
98 new File.binary(name, contents); 102 new File.binary(name, contents);
99 103
100 /// Creates a new [Directory] descriptor with [name] and [contents]. 104 /// Creates a new [Directory] descriptor with [name] and [contents].
101 Directory dir(Pattern name, [Iterable<Entry> contents]) => 105 Directory dir(String name, [Iterable<Entry> contents]) =>
102 new Directory(name, contents == null ? <Entry>[] : contents); 106 new Directory(name, contents == null ? <Entry>[] : contents);
103 107
104 /// Creates a new descriptor wrapping a [Future]. This descriptor forwards all 108 /// Creates a new descriptor wrapping a [Future]. This descriptor forwards all
105 /// asynchronous operations to the result of [future]. 109 /// asynchronous operations to the result of [future].
106 Async async(Future<Entry> future) => new Async(future); 110 Async async(Future<Entry> future) => new Async(future);
107 111
108 /// Creates a new [Nothing] descriptor that asserts that no entry named [name] 112 /// Creates a new [Nothing] descriptor that asserts that no entry named [name]
109 /// exists. 113 /// exists.
110 Nothing nothing(Pattern name) => new Nothing(name); 114 Nothing nothing(String name) => new Nothing(name);
115
116 /// Creates a new [Pattern] descriptor that asserts than an entry with a name
117 /// matching [pattern] exists, and matches the [Entry] returned by [fn].
118 Pattern pattern(core.Pattern name, EntryCreator fn) => new Pattern(name, fn);
Bob Nystrom 2013/03/15 21:58:46 It's pretty verbose at callsites to always have to
nweiz 2013/03/15 23:17:21 I don't like disallowing other Patterns. I think t
Bob Nystrom 2013/03/18 21:06:34 I like that Pattern (er, I mean descriptor.Pattern
nweiz 2013/03/18 21:41:05 "new d.PatternDescriptor(..., (name) => d.dir(name
Bob Nystrom 2013/03/18 22:05:34 Ah, forgot about filePattern() and dirPattern(). S
OLDNEW
« no previous file with comments | « no previous file | pkg/scheduled_test/lib/src/descriptor/async.dart » ('j') | pkg/scheduled_test/lib/src/descriptor/async.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698