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 /// Pub-specific scheduled_test descriptors. | 5 /// Pub-specific scheduled_test descriptors. |
6 library descriptor; | 6 library descriptor; |
7 | 7 |
8 import 'package:oauth2/oauth2.dart' as oauth2; | 8 import 'package:oauth2/oauth2.dart' as oauth2; |
9 import 'package:scheduled_test/scheduled_server.dart'; | 9 import 'package:scheduled_test/scheduled_server.dart'; |
10 import 'package:scheduled_test/scheduled_test.dart'; | 10 import 'package:scheduled_test/scheduled_test.dart'; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // Default to printing the name if no other code was given. | 76 // Default to printing the name if no other code was given. |
77 if (code == null) { | 77 if (code == null) { |
78 code = name; | 78 code = name; |
79 } | 79 } |
80 | 80 |
81 return dir("lib", [ | 81 return dir("lib", [ |
82 file("$name.dart", 'main() => "$code";') | 82 file("$name.dart", 'main() => "$code";') |
83 ]); | 83 ]); |
84 } | 84 } |
85 | 85 |
86 /// Describes a directory for a package installed from the mock package server. | |
87 /// This directory is of the form found in the global package cache. | |
88 Descriptor packageCacheDir(String name, String version) { | |
89 return dir("$name-$version", [ | |
90 libDir(name, '$name $version') | |
91 ]); | |
92 } | |
93 | |
94 /// Describes a directory for a Git package. This directory is of the form | 86 /// Describes a directory for a Git package. This directory is of the form |
95 /// found in the revision cache of the global package cache. | 87 /// found in the revision cache of the global package cache. |
96 Descriptor gitPackageRevisionCacheDir(String name, [int modifier]) { | 88 Descriptor gitPackageRevisionCacheDir(String name, [int modifier]) { |
97 var value = name; | 89 var value = name; |
98 if (modifier != null) value = "$name $modifier"; | 90 if (modifier != null) value = "$name $modifier"; |
99 return pattern(new RegExp("$name${r'-[a-f0-9]+'}"), | 91 return pattern(new RegExp("$name${r'-[a-f0-9]+'}"), |
100 (dirName) => dir(dirName, [libDir(name, value)])); | 92 (dirName) => dir(dirName, [libDir(name, value)])); |
101 } | 93 } |
102 | 94 |
103 /// Describes a directory for a Git package. This directory is of the form | 95 /// Describes a directory for a Git package. This directory is of the form |
(...skipping 26 matching lines...) Expand all Loading... |
130 }); | 122 }); |
131 return dir(packagesPath, contents); | 123 return dir(packagesPath, contents); |
132 } | 124 } |
133 | 125 |
134 /// Describes the global package cache directory containing all the given | 126 /// Describes the global package cache directory containing all the given |
135 /// [packages], which should be name/version pairs. The packages will be | 127 /// [packages], which should be name/version pairs. The packages will be |
136 /// validated against the format produced by the mock package server. | 128 /// validated against the format produced by the mock package server. |
137 /// | 129 /// |
138 /// A package's value may also be a list of versions, in which case all | 130 /// A package's value may also be a list of versions, in which case all |
139 /// versions are expected to be installed. | 131 /// versions are expected to be installed. |
140 Descriptor cacheDir(Map packages) { | 132 /// |
| 133 /// If [includePubspecs] is `true`, then pubspecs will be created for each |
| 134 /// package. Defaults to `false` so that the contents of pubspecs are not |
| 135 /// validated since they will often lack the dependencies section that the |
| 136 /// real pubspec being compared against has. You usually only need to pass |
| 137 /// `true` for this if you plan to call [create] on the resulting descriptor. |
| 138 Descriptor cacheDir(Map packages, {bool includePubspecs: false}) { |
141 var contents = <Descriptor>[]; | 139 var contents = <Descriptor>[]; |
142 packages.forEach((name, versions) { | 140 packages.forEach((name, versions) { |
143 if (versions is! List) versions = [versions]; | 141 if (versions is! List) versions = [versions]; |
144 for (var version in versions) { | 142 for (var version in versions) { |
145 contents.add(packageCacheDir(name, version)); | 143 var packageContents = [libDir(name, '$name $version')]; |
| 144 if (includePubspecs) { |
| 145 packageContents.add(libPubspec(name, version)); |
| 146 } |
| 147 contents.add(dir("$name-$version", packageContents)); |
146 } | 148 } |
147 }); | 149 }); |
| 150 |
148 return dir(cachePath, [ | 151 return dir(cachePath, [ |
149 dir('hosted', [ | 152 dir('hosted', [ |
150 async(port.then((p) => dir('localhost%58$p', contents))) | 153 async(port.then((p) => dir('localhost%58$p', contents))) |
151 ]) | 154 ]) |
152 ]); | 155 ]); |
153 } | 156 } |
154 | 157 |
155 /// Describes the file in the system cache that contains the client's OAuth2 | 158 /// Describes the file in the system cache that contains the client's OAuth2 |
156 /// credentials. The URL "/token" on [server] will be used as the token | 159 /// credentials. The URL "/token" on [server] will be used as the token |
157 /// endpoint for refreshing the access token. | 160 /// endpoint for refreshing the access token. |
(...skipping 11 matching lines...) Expand all Loading... |
169 ['https://www.googleapis.com/auth/userinfo.email'], | 172 ['https://www.googleapis.com/auth/userinfo.email'], |
170 expiration).toJson()) | 173 expiration).toJson()) |
171 ]); | 174 ]); |
172 })); | 175 })); |
173 } | 176 } |
174 | 177 |
175 /// Describes the application directory, containing only a pubspec specifying | 178 /// Describes the application directory, containing only a pubspec specifying |
176 /// the given [dependencies]. | 179 /// the given [dependencies]. |
177 DirectoryDescriptor appDir(List dependencies) => | 180 DirectoryDescriptor appDir(List dependencies) => |
178 dir(appPath, [appPubspec(dependencies)]); | 181 dir(appPath, [appPubspec(dependencies)]); |
OLD | NEW |