OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library pub_tests; | 5 library pub_tests; |
6 | 6 |
7 import 'package:scheduled_test/scheduled_test.dart'; | 7 import 'package:scheduled_test/scheduled_test.dart'; |
8 | 8 |
9 import '../lib/src/exit_codes.dart' as exit_codes; | 9 import '../lib/src/exit_codes.dart' as exit_codes; |
10 import 'test_pub.dart'; | 10 import 'test_pub.dart'; |
(...skipping 23 matching lines...) Expand all Loading... |
34 get Get the current package's dependencies. | 34 get Get the current package's dependencies. |
35 help Display help information for Pub. | 35 help Display help information for Pub. |
36 publish Publish the current package to pub.dartlang.org. | 36 publish Publish the current package to pub.dartlang.org. |
37 run Run an executable from a package. | 37 run Run an executable from a package. |
38 serve Run a local web development server. | 38 serve Run a local web development server. |
39 upgrade Upgrade the current package's dependencies to latest versions. | 39 upgrade Upgrade the current package's dependencies to latest versions. |
40 uploader Manage uploaders for a package on pub.dartlang.org. | 40 uploader Manage uploaders for a package on pub.dartlang.org. |
41 version Print pub version. | 41 version Print pub version. |
42 | 42 |
43 Use "pub help [command]" for more information about a command. | 43 Use "pub help [command]" for more information about a command. |
| 44 See http://dartlang.org/tools/pub for detailed documentation. |
44 """; | 45 """; |
45 | 46 |
46 final VERSION_STRING = ''' | 47 final VERSION_STRING = ''' |
47 Pub 0.1.2+3 | 48 Pub 0.1.2+3 |
48 '''; | 49 '''; |
49 | 50 |
50 main() { | 51 main() { |
51 initConfig(); | 52 initConfig(); |
52 | 53 |
53 integration('running pub with no command displays usage', () { | 54 integration('running pub with no command displays usage', () { |
(...skipping 10 matching lines...) Expand all Loading... |
64 | 65 |
65 integration('running pub with --help after command shows command usage', () { | 66 integration('running pub with --help after command shows command usage', () { |
66 schedulePub(args: ['get', '--help'], | 67 schedulePub(args: ['get', '--help'], |
67 output: ''' | 68 output: ''' |
68 Get the current package's dependencies. | 69 Get the current package's dependencies. |
69 | 70 |
70 Usage: pub get | 71 Usage: pub get |
71 -h, --help Print usage information for this command. | 72 -h, --help Print usage information for this command. |
72 --[no-]offline Use cached packages instead of accessing the net
work. | 73 --[no-]offline Use cached packages instead of accessing the net
work. |
73 -n, --dry-run Report what dependencies would change but don't
change any. | 74 -n, --dry-run Report what dependencies would change but don't
change any. |
| 75 |
| 76 See http://dartlang.org/tools/pub/cmd/pub-get.html for detailed docume
ntation. |
74 '''); | 77 '''); |
75 }); | 78 }); |
76 | 79 |
77 integration('running pub with -h after command shows command usage', () { | 80 integration('running pub with -h after command shows command usage', () { |
78 schedulePub(args: ['get', '-h'], | 81 schedulePub(args: ['get', '-h'], |
79 output: ''' | 82 output: ''' |
80 Get the current package's dependencies. | 83 Get the current package's dependencies. |
81 | 84 |
82 Usage: pub get | 85 Usage: pub get |
83 -h, --help Print usage information for this command. | 86 -h, --help Print usage information for this command. |
84 --[no-]offline Use cached packages instead of accessing the net
work. | 87 --[no-]offline Use cached packages instead of accessing the net
work. |
85 -n, --dry-run Report what dependencies would change but don't
change any. | 88 -n, --dry-run Report what dependencies would change but don't
change any. |
| 89 |
| 90 See http://dartlang.org/tools/pub/cmd/pub-get.html for detailed docume
ntation. |
86 '''); | 91 '''); |
87 }); | 92 }); |
88 | 93 |
89 integration('running pub with --help after a command with subcommands shows ' | 94 integration('running pub with --help after a command with subcommands shows ' |
90 'command usage', () { | 95 'command usage', () { |
91 schedulePub(args: ['cache', '--help'], | 96 schedulePub(args: ['cache', '--help'], |
92 output: ''' | 97 output: ''' |
93 Work with the system cache. | 98 Work with the system cache. |
94 | 99 |
95 Usage: pub cache <subcommand> | 100 Usage: pub cache <subcommand> |
96 -h, --help Print usage information for this command. | 101 -h, --help Print usage information for this command. |
97 | 102 |
98 Available subcommands: | 103 Available subcommands: |
99 add Install a package. | 104 add Install a package. |
100 repair Reinstall cached packages. | 105 repair Reinstall cached packages. |
| 106 |
| 107 See http://dartlang.org/tools/pub/cmd/pub-cache.html for detailed docu
mentation. |
101 '''); | 108 '''); |
102 }); | 109 }); |
103 | 110 |
104 | 111 |
105 integration('running pub with just --version displays version', () { | 112 integration('running pub with just --version displays version', () { |
106 schedulePub(args: ['--version'], output: VERSION_STRING); | 113 schedulePub(args: ['--version'], output: VERSION_STRING); |
107 }); | 114 }); |
108 | 115 |
109 integration('an unknown command displays an error message', () { | 116 integration('an unknown command displays an error message', () { |
110 schedulePub(args: ['quylthulg'], | 117 schedulePub(args: ['quylthulg'], |
(...skipping 20 matching lines...) Expand all Loading... |
131 schedulePub(args: ['cache', 'quylthulg'], | 138 schedulePub(args: ['cache', 'quylthulg'], |
132 error: ''' | 139 error: ''' |
133 Could not find a subcommand named "quylthulg" for "pub cache". | 140 Could not find a subcommand named "quylthulg" for "pub cache". |
134 | 141 |
135 Usage: pub cache <subcommand> | 142 Usage: pub cache <subcommand> |
136 -h, --help Print usage information for this command. | 143 -h, --help Print usage information for this command. |
137 | 144 |
138 Available subcommands: | 145 Available subcommands: |
139 add Install a package. | 146 add Install a package. |
140 repair Reinstall cached packages. | 147 repair Reinstall cached packages. |
| 148 |
| 149 See http://dartlang.org/tools/pub/cmd/pub-cache.html for detailed docume
ntation. |
141 ''', | 150 ''', |
142 exitCode: exit_codes.USAGE); | 151 exitCode: exit_codes.USAGE); |
143 }); | 152 }); |
144 | 153 |
145 integration('an unknown option displays an error message', () { | 154 integration('an unknown option displays an error message', () { |
146 schedulePub(args: ['--blorf'], | 155 schedulePub(args: ['--blorf'], |
147 error: ''' | 156 error: ''' |
148 Could not find an option named "blorf". | 157 Could not find an option named "blorf". |
149 Run "pub help" to see available options. | 158 Run "pub help" to see available options. |
150 ''', | 159 ''', |
(...skipping 26 matching lines...) Expand all Loading... |
177 schedulePub(args: ['cache'], | 186 schedulePub(args: ['cache'], |
178 error: ''' | 187 error: ''' |
179 Missing subcommand for "pub cache". | 188 Missing subcommand for "pub cache". |
180 | 189 |
181 Usage: pub cache <subcommand> | 190 Usage: pub cache <subcommand> |
182 -h, --help Print usage information for this command. | 191 -h, --help Print usage information for this command. |
183 | 192 |
184 Available subcommands: | 193 Available subcommands: |
185 add Install a package. | 194 add Install a package. |
186 repair Reinstall cached packages. | 195 repair Reinstall cached packages. |
| 196 |
| 197 See http://dartlang.org/tools/pub/cmd/pub-cache.html for detailed docume
ntation. |
187 ''', | 198 ''', |
188 exitCode: exit_codes.USAGE); | 199 exitCode: exit_codes.USAGE); |
189 }); | 200 }); |
190 | 201 |
191 group('help', () { | 202 group('help', () { |
192 integration('shows global help if no command is given', () { | 203 integration('shows global help if no command is given', () { |
193 schedulePub(args: ['help'], output: USAGE_STRING); | 204 schedulePub(args: ['help'], output: USAGE_STRING); |
194 }); | 205 }); |
195 | 206 |
196 integration('shows help for a command', () { | 207 integration('shows help for a command', () { |
197 schedulePub(args: ['help', 'get'], | 208 schedulePub(args: ['help', 'get'], |
198 output: ''' | 209 output: ''' |
199 Get the current package's dependencies. | 210 Get the current package's dependencies. |
200 | 211 |
201 Usage: pub get | 212 Usage: pub get |
202 -h, --help Print usage information for this command. | 213 -h, --help Print usage information for this command. |
203 --[no-]offline Use cached packages instead of accessing the n
etwork. | 214 --[no-]offline Use cached packages instead of accessing the n
etwork. |
204 -n, --dry-run Report what dependencies would change but don'
t change any. | 215 -n, --dry-run Report what dependencies would change but don'
t change any. |
| 216 |
| 217 See http://dartlang.org/tools/pub/cmd/pub-get.html for detailed docu
mentation. |
205 '''); | 218 '''); |
206 }); | 219 }); |
207 | 220 |
208 integration('shows help for a command', () { | 221 integration('shows help for a command', () { |
209 schedulePub(args: ['help', 'publish'], | 222 schedulePub(args: ['help', 'publish'], |
210 output: ''' | 223 output: ''' |
211 Publish the current package to pub.dartlang.org. | 224 Publish the current package to pub.dartlang.org. |
212 | 225 |
213 Usage: pub publish [options] | 226 Usage: pub publish [options] |
214 -h, --help Print usage information for this command. | 227 -h, --help Print usage information for this command. |
215 -n, --dry-run Validate but do not publish the package. | 228 -n, --dry-run Validate but do not publish the package. |
216 -f, --force Publish without confirmation if there are no errors
. | 229 -f, --force Publish without confirmation if there are no errors
. |
217 --server The package server to which to upload this package. | 230 --server The package server to which to upload this package. |
218 (defaults to "https://pub.dartlang.org") | 231 (defaults to "https://pub.dartlang.org") |
| 232 |
| 233 See http://dartlang.org/tools/pub/cmd/pub-lish.html for detailed doc
umentation. |
219 '''); | 234 '''); |
220 }); | 235 }); |
221 | 236 |
222 integration('shows non-truncated help', () { | 237 integration('shows non-truncated help', () { |
223 schedulePub(args: ['help', 'serve'], | 238 schedulePub(args: ['help', 'serve'], |
224 output: ''' | 239 output: ''' |
225 Run a local web development server. | 240 Run a local web development server. |
226 | 241 |
227 By default, this serves "web/" and "test/", but an explicit list of | 242 By default, this serves "web/" and "test/", but an explicit list of |
228 directories to serve can be provided as well. | 243 directories to serve can be provided as well. |
229 | 244 |
230 Usage: pub serve [directories...] | 245 Usage: pub serve [directories...] |
231 -h, --help Print usage information for this command. | 246 -h, --help Print usage information for this command. |
232 --mode Mode to run transformers in. | 247 --mode Mode to run transformers in. |
233 (defaults to "debug") | 248 (defaults to "debug") |
234 | 249 |
235 --all Use all default source directories. | 250 --all Use all default source directories. |
236 --hostname The hostname to listen on. | 251 --hostname The hostname to listen on. |
237 (defaults to "localhost") | 252 (defaults to "localhost") |
238 | 253 |
239 --port The base port to listen on. | 254 --port The base port to listen on. |
240 (defaults to "8080") | 255 (defaults to "8080") |
241 | 256 |
242 --[no-]dart2js Compile Dart to JavaScript. | 257 --[no-]dart2js Compile Dart to JavaScript. |
243 (defaults to on) | 258 (defaults to on) |
244 | 259 |
245 --[no-]force-poll Force the use of a polling filesystem watch
er. | 260 --[no-]force-poll Force the use of a polling filesystem watch
er. |
| 261 |
| 262 See http://dartlang.org/tools/pub/cmd/pub-serve.html for detailed do
cumentation. |
246 '''); | 263 '''); |
247 }); | 264 }); |
248 | 265 |
249 integration('shows help for a subcommand', () { | 266 integration('shows help for a subcommand', () { |
250 schedulePub(args: ['help', 'cache', 'list'], | 267 schedulePub(args: ['help', 'cache', 'list'], |
251 output: ''' | 268 output: ''' |
252 List packages in the system cache. | 269 List packages in the system cache. |
253 | 270 |
254 Usage: pub cache list | 271 Usage: pub cache list |
255 -h, --help Print usage information for this command. | 272 -h, --help Print usage information for this command. |
(...skipping 25 matching lines...) Expand all Loading... |
281 schedulePub(args: ['help', 'cache', 'quylthulg'], | 298 schedulePub(args: ['help', 'cache', 'quylthulg'], |
282 error: ''' | 299 error: ''' |
283 Could not find a subcommand named "quylthulg" for "pub cache". | 300 Could not find a subcommand named "quylthulg" for "pub cache". |
284 | 301 |
285 Usage: pub cache <subcommand> | 302 Usage: pub cache <subcommand> |
286 -h, --help Print usage information for this command. | 303 -h, --help Print usage information for this command. |
287 | 304 |
288 Available subcommands: | 305 Available subcommands: |
289 add Install a package. | 306 add Install a package. |
290 repair Reinstall cached packages. | 307 repair Reinstall cached packages. |
| 308 |
| 309 See http://dartlang.org/tools/pub/cmd/pub-cache.html for detailed do
cumentation. |
291 ''', | 310 ''', |
292 exitCode: exit_codes.USAGE); | 311 exitCode: exit_codes.USAGE); |
293 }); | 312 }); |
294 | 313 |
295 integration('an unexpected help subcommand displays an error message', () { | 314 integration('an unexpected help subcommand displays an error message', () { |
296 schedulePub(args: ['help', 'version', 'badsubcommand'], | 315 schedulePub(args: ['help', 'version', 'badsubcommand'], |
297 error: ''' | 316 error: ''' |
298 Command "pub version" does not expect a subcommand. | 317 Command "pub version" does not expect a subcommand. |
299 | 318 |
300 Usage: pub version | 319 Usage: pub version |
301 -h, --help Print usage information for this command. | 320 -h, --help Print usage information for this command. |
302 ''', | 321 ''', |
303 exitCode: exit_codes.USAGE); | 322 exitCode: exit_codes.USAGE); |
304 }); | 323 }); |
305 }); | 324 }); |
306 | 325 |
307 group('version', () { | 326 group('version', () { |
308 integration('displays the current version', () { | 327 integration('displays the current version', () { |
309 schedulePub(args: ['version'], output: VERSION_STRING); | 328 schedulePub(args: ['version'], output: VERSION_STRING); |
310 }); | 329 }); |
311 }); | 330 }); |
312 } | 331 } |
OLD | NEW |