| 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 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 import 'test_pub.dart'; | 9 import 'test_pub.dart'; |
| 10 import '../../../pkg/unittest/lib/unittest.dart'; | 10 import '../../../pkg/unittest/lib/unittest.dart'; |
| 11 | 11 |
| 12 final USAGE_STRING = """ | 12 final USAGE_STRING = """ |
| 13 Pub is a package manager for Dart. | 13 Pub is a package manager for Dart. |
| 14 | 14 |
| 15 Usage: pub command [arguments] | 15 Usage: pub command [arguments] |
| 16 | 16 |
| 17 Global options: | 17 Global options: |
| 18 -h, --help print this usage information | 18 -h, --help Print this usage information. |
| 19 --version print the version of pub | 19 --version Print pub version. |
| 20 --[no-]trace print debugging information when an error occurs | 20 --[no-]trace Print debugging information when an error occurs. |
| 21 --verbosity control output verbosity | 21 --verbosity Control output verbosity. |
| 22 | 22 |
| 23 [all] all output including internal tracing messages are sho
wn | 23 [all] All output including internal tracing messages are sho
wn. |
| 24 [io] IO operations are also shown | 24 [io] IO operations are also shown. |
| 25 [normal] errors, warnings, and user messages are shown | 25 [normal] Errors, warnings, and user messages are shown. |
| 26 | 26 |
| 27 -v, --verbose shortcut for "--verbosity=all" | 27 -v, --verbose Shortcut for "--verbosity=all" |
| 28 | 28 |
| 29 Available commands: | 29 Available commands: |
| 30 help display help information for Pub | 30 help Display help information for Pub. |
| 31 install install the current package's dependencies | 31 install Install the current package's dependencies. |
| 32 publish publish the current package to pub.dartlang.org | 32 publish Publish the current package to pub.dartlang.org. |
| 33 update update the current package's dependencies to the latest versions | 33 update Update the current package's dependencies to the latest versions
. |
| 34 version print Pub version | 34 version Print pub version. |
| 35 | 35 |
| 36 Use "pub help [command]" for more information about a command. | 36 Use "pub help [command]" for more information about a command. |
| 37 """; | 37 """; |
| 38 | 38 |
| 39 final VERSION_STRING = ''' | 39 final VERSION_STRING = ''' |
| 40 Pub 0.0.0 | 40 Pub 0.0.0 |
| 41 '''; | 41 '''; |
| 42 | 42 |
| 43 main() { | 43 main() { |
| 44 test('running pub with no command displays usage', () => | 44 test('running pub with no command displays usage', () => |
| (...skipping 30 matching lines...) Expand all Loading... |
| 75 // TODO(rnystrom): When pub has command-specific options, a more precise | 75 // TODO(rnystrom): When pub has command-specific options, a more precise |
| 76 // error message would be good here. | 76 // error message would be good here. |
| 77 runPub(args: ['version', '--blorf'], | 77 runPub(args: ['version', '--blorf'], |
| 78 error: ''' | 78 error: ''' |
| 79 Could not find an option named "blorf". | 79 Could not find an option named "blorf". |
| 80 Use "pub help" for more information. | 80 Use "pub help" for more information. |
| 81 ''', | 81 ''', |
| 82 exitCode: 64); | 82 exitCode: 64); |
| 83 }); | 83 }); |
| 84 | 84 |
| 85 test('an unknown help command displays an error message', () { | 85 group('help', () { |
| 86 runPub(args: ['help', 'quylthulg'], | 86 test('shows help for a command', () { |
| 87 error: ''' | 87 runPub(args: ['help', 'install'], |
| 88 Could not find a command named "quylthulg". | 88 output: ''' |
| 89 Run "pub help" to see available commands. | 89 Install the current package's dependencies. |
| 90 ''', | 90 |
| 91 exitCode: 64); | 91 Usage: pub install |
| 92 '''); |
| 93 }); |
| 94 |
| 95 test('shows help for a command', () { |
| 96 runPub(args: ['help', 'publish'], |
| 97 output: ''' |
| 98 Publish the current package to pub.dartlang.org. |
| 99 |
| 100 Usage: pub publish [options] |
| 101 --server The package server to which to upload this package |
| 102 (defaults to "https://pub.dartlang.org") |
| 103 '''); |
| 104 }); |
| 105 |
| 106 test('an unknown help command displays an error message', () { |
| 107 runPub(args: ['help', 'quylthulg'], |
| 108 error: ''' |
| 109 Could not find a command named "quylthulg". |
| 110 Run "pub help" to see available commands. |
| 111 ''', |
| 112 exitCode: 64); |
| 113 }); |
| 114 |
| 92 }); | 115 }); |
| 93 | 116 |
| 94 test('displays the current version', () => | 117 test('displays the current version', () => |
| 95 runPub(args: ['version'], output: VERSION_STRING)); | 118 runPub(args: ['version'], output: VERSION_STRING)); |
| 96 } | 119 } |
| OLD | NEW |