| OLD | NEW |
| 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 [Descriptor.create] to schedule a task that will create that structure | 9 /// call [Descriptor.create] to schedule a task that will create that structure |
| 10 /// on the physical filesystem, or [Descriptor.validate] to schedule an | 10 /// on the physical filesystem, or [Descriptor.validate] to schedule an |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 String _defaultRoot; | 93 String _defaultRoot; |
| 94 | 94 |
| 95 /// Creates a new text [FileDescriptor] with [name] and [contents]. | 95 /// Creates a new text [FileDescriptor] with [name] and [contents]. |
| 96 FileDescriptor file(String name, [String contents='']) => | 96 FileDescriptor file(String name, [String contents='']) => |
| 97 new FileDescriptor(name, contents); | 97 new FileDescriptor(name, contents); |
| 98 | 98 |
| 99 /// Creates a new binary [FileDescriptor] descriptor with [name] and [contents]. | 99 /// Creates a new binary [FileDescriptor] descriptor with [name] and [contents]. |
| 100 FileDescriptor binaryFile(String name, List<int> contents) => | 100 FileDescriptor binaryFile(String name, List<int> contents) => |
| 101 new FileDescriptor.binary(name, contents); | 101 new FileDescriptor.binary(name, contents); |
| 102 | 102 |
| 103 /// Creates a new text [FileDescriptor] with [name] that matches its String |
| 104 /// contents against [matcher]. If the file is created, it's considered to be |
| 105 /// empty. |
| 106 FileDescriptor matcherFile(String name, matcher) => |
| 107 new FileDescriptor.matcher(name, wrapMatcher(matcher)); |
| 108 |
| 109 /// Creates a new binary [FileDescriptor] with [name] that matches its binary |
| 110 /// contents against [matcher]. If the file is created, it's considered to be |
| 111 /// empty. |
| 112 FileDescriptor binaryMatcherFile(String name, matcher) => |
| 113 new FileDescriptor.binaryMatcher(name, wrapMatcher(matcher)); |
| 114 |
| 103 /// Creates a new [DirectoryDescriptor] descriptor with [name] and [contents]. | 115 /// Creates a new [DirectoryDescriptor] descriptor with [name] and [contents]. |
| 104 DirectoryDescriptor dir(String name, [Iterable<Descriptor> contents]) => | 116 DirectoryDescriptor dir(String name, [Iterable<Descriptor> contents]) => |
| 105 new DirectoryDescriptor(name, contents == null? <Descriptor>[] : contents); | 117 new DirectoryDescriptor(name, contents == null? <Descriptor>[] : contents); |
| 106 | 118 |
| 107 /// Creates a new descriptor wrapping a [Future]. This descriptor forwards all | 119 /// Creates a new descriptor wrapping a [Future]. This descriptor forwards all |
| 108 /// asynchronous operations to the result of [future]. | 120 /// asynchronous operations to the result of [future]. |
| 109 AsyncDescriptor async(Future<Descriptor> future) => | 121 AsyncDescriptor async(Future<Descriptor> future) => |
| 110 new AsyncDescriptor(future); | 122 new AsyncDescriptor(future); |
| 111 | 123 |
| 112 /// Creates a new [NothingDescriptor] descriptor that asserts that no entry | 124 /// Creates a new [NothingDescriptor] descriptor that asserts that no entry |
| 113 /// named [name] exists. | 125 /// named [name] exists. |
| 114 NothingDescriptor nothing(String name) => new NothingDescriptor(name); | 126 NothingDescriptor nothing(String name) => new NothingDescriptor(name); |
| 115 | 127 |
| 116 /// Creates a new [PatternDescriptor] descriptor that asserts than an entry with | 128 /// Creates a new [PatternDescriptor] descriptor that asserts than an entry with |
| 117 /// a name matching [pattern] exists, and matches the [Descriptor] returned | 129 /// a name matching [pattern] exists, and matches the [Descriptor] returned |
| 118 /// by [fn]. | 130 /// by [fn]. |
| 119 PatternDescriptor pattern(Pattern name, EntryCreator fn) => | 131 PatternDescriptor pattern(Pattern name, EntryCreator fn) => |
| 120 new PatternDescriptor(name, fn); | 132 new PatternDescriptor(name, fn); |
| 121 | 133 |
| 122 /// A convenience method for creating a [PatternDescriptor] descriptor that | 134 /// A convenience method for creating a [PatternDescriptor] descriptor that |
| 123 /// constructs a [FileDescriptor] descriptor. | 135 /// constructs a [FileDescriptor] descriptor. |
| 124 PatternDescriptor filePattern(Pattern name, [String contents='']) => | 136 PatternDescriptor filePattern(Pattern name, [String contents='']) => |
| 125 pattern(name, (realName) => file(realName, contents)); | 137 pattern(name, (realName) => file(realName, contents)); |
| 126 | 138 |
| 127 /// A convenience method for creating a [PatternDescriptor] descriptor that | 139 /// A convenience method for creating a [PatternDescriptor] descriptor that |
| 128 /// constructs a [DirectoryDescriptor] descriptor. | 140 /// constructs a [DirectoryDescriptor] descriptor. |
| 129 PatternDescriptor dirPattern(Pattern name, [Iterable<Descriptor> contents]) => | 141 PatternDescriptor dirPattern(Pattern name, [Iterable<Descriptor> contents]) => |
| 130 pattern(name, (realName) => dir(realName, contents)); | 142 pattern(name, (realName) => dir(realName, contents)); |
| OLD | NEW |