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