| 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'; |
| 11 | 11 |
| 12 final USAGE_STRING = """ | |
| 13 Pub is a package manager for Dart. | |
| 14 | |
| 15 Usage: pub <command> [arguments] | |
| 16 | |
| 17 Global options: | |
| 18 -h, --help Print this usage information. | |
| 19 --version Print pub version. | |
| 20 --[no-]trace Print debugging information when an error occurs. | |
| 21 --verbosity Control output verbosity. | |
| 22 | |
| 23 [all] Show all output including internal tracing messages. | |
| 24 [io] Also show IO operations. | |
| 25 [normal] Show errors, warnings, and user messages. | |
| 26 [solver] Show steps during version resolution. | |
| 27 | |
| 28 -v, --verbose Shortcut for "--verbosity=all". | |
| 29 | |
| 30 Available commands: | |
| 31 build Apply transformers to build a package. | |
| 32 cache Work with the system cache. | |
| 33 deps Print package dependencies. | |
| 34 downgrade Downgrade the current package's dependencies to oldest version
s. | |
| 35 get Get the current package's dependencies. | |
| 36 global Work with global packages. | |
| 37 help Display help information for Pub. | |
| 38 publish Publish the current package to pub.dartlang.org. | |
| 39 run Run an executable from a package. | |
| 40 serve Run a local web development server. | |
| 41 upgrade Upgrade the current package's dependencies to latest versions. | |
| 42 uploader Manage uploaders for a package on pub.dartlang.org. | |
| 43 version Print pub version. | |
| 44 | |
| 45 Run "pub help [command]" for more information about a command. | |
| 46 See http://dartlang.org/tools/pub for detailed documentation. | |
| 47 """; | |
| 48 | |
| 49 final VERSION_STRING = ''' | |
| 50 Pub 0.1.2+3 | |
| 51 '''; | |
| 52 | |
| 53 main() { | 12 main() { |
| 54 initConfig(); | 13 initConfig(); |
| 55 | 14 |
| 56 integration('running pub with no command displays usage', () { | 15 integration('running pub with no command displays usage', () { |
| 57 schedulePub(args: [], output: USAGE_STRING); | 16 schedulePub(args: [], output: """ |
| 58 }); | 17 Pub is a package manager for Dart. |
| 59 | 18 |
| 60 integration('running pub with just --help displays usage', () { | 19 Usage: pub <command> [arguments] |
| 61 schedulePub(args: ['--help'], output: USAGE_STRING); | |
| 62 }); | |
| 63 | 20 |
| 64 integration('running pub with just -h displays usage', () { | 21 Global options: |
| 65 schedulePub(args: ['-h'], output: USAGE_STRING); | 22 -h, --help Print this usage information. |
| 66 }); | 23 --version Print pub version. |
| 24 --[no-]trace Print debugging information when an error occurs. |
| 25 --verbosity Control output verbosity. |
| 67 | 26 |
| 68 integration('running pub with --with-prejudice upcases everything', () { | 27 [all] Show all output including internal tracing message
s. |
| 69 schedulePub(args: ['--with-prejudice'], output: USAGE_STRING.toUpperCase()); | 28 [io] Also show IO operations. |
| 70 }); | 29 [normal] Show errors, warnings, and user messages. |
| 30 [solver] Show steps during version resolution. |
| 71 | 31 |
| 72 integration('running pub with --help after command shows command usage', () { | 32 -v, --verbose Shortcut for "--verbosity=all". |
| 73 schedulePub(args: ['get', '--help'], output: ''' | |
| 74 Get the current package's dependencies. | |
| 75 | |
| 76 Usage: pub get | |
| 77 -h, --help Print usage information for this command. | |
| 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. | |
| 80 | |
| 81 Run "pub help" to see global options. | |
| 82 See http://dartlang.org/tools/pub/cmd/pub-get.html for detailed docume
ntation. | |
| 83 '''); | |
| 84 }); | |
| 85 | |
| 86 integration('running pub with -h after command shows command usage', () { | |
| 87 schedulePub(args: ['get', '-h'], output: ''' | |
| 88 Get the current package's dependencies. | |
| 89 | |
| 90 Usage: pub get | |
| 91 -h, --help Print usage information for this command. | |
| 92 --[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 | |
| 95 Run "pub help" to see global options. | |
| 96 See http://dartlang.org/tools/pub/cmd/pub-get.html for detailed docume
ntation. | |
| 97 '''); | |
| 98 }); | |
| 99 | |
| 100 integration( | |
| 101 'running pub with --help after a command with subcommands shows ' | |
| 102 'command usage', | |
| 103 () { | |
| 104 schedulePub(args: ['cache', '--help'], output: ''' | |
| 105 Work with the system cache. | |
| 106 | |
| 107 Usage: pub cache <subcommand> | |
| 108 -h, --help Print usage information for this command. | |
| 109 | |
| 110 Available subcommands: | |
| 111 add Install a package. | |
| 112 repair Reinstall cached packages. | |
| 113 | |
| 114 Run "pub help" to see global options. | |
| 115 See http://dartlang.org/tools/pub/cmd/pub-cache.html for detailed docu
mentation. | |
| 116 '''); | |
| 117 }); | |
| 118 | |
| 119 | |
| 120 integration('running pub with just --version displays version', () { | |
| 121 schedulePub(args: ['--version'], output: VERSION_STRING); | |
| 122 }); | |
| 123 | |
| 124 integration('an unknown command displays an error message', () { | |
| 125 schedulePub(args: ['quylthulg'], error: ''' | |
| 126 Could not find a command named "quylthulg". | |
| 127 | 33 |
| 128 Available commands: | 34 Available commands: |
| 129 build Apply transformers to build a package. | 35 build Apply transformers to build a package. |
| 130 cache Work with the system cache. | 36 cache Work with the system cache. |
| 131 deps Print package dependencies. | 37 deps Print package dependencies. |
| 132 downgrade Downgrade the current package's dependencies to oldest ver
sions. | 38 downgrade Downgrade the current package's dependencies to oldest ver
sions. |
| 133 get Get the current package's dependencies. | 39 get Get the current package's dependencies. |
| 134 global Work with global packages. | 40 global Work with global packages. |
| 135 help Display help information for Pub. | 41 help Display help information for pub. |
| 136 publish Publish the current package to pub.dartlang.org. | 42 publish Publish the current package to pub.dartlang.org. |
| 137 run Run an executable from a package. | 43 run Run an executable from a package. |
| 138 serve Run a local web development server. | 44 serve Run a local web development server. |
| 139 upgrade Upgrade the current package's dependencies to latest versi
ons. | 45 upgrade Upgrade the current package's dependencies to latest versi
ons. |
| 140 uploader Manage uploaders for a package on pub.dartlang.org. | 46 uploader Manage uploaders for a package on pub.dartlang.org. |
| 141 version Print pub version. | 47 version Print pub version. |
| 142 ''', exitCode: exit_codes.USAGE); | 48 |
| 49 Run "pub help <command>" for more information about a command. |
| 50 See http://dartlang.org/tools/pub for detailed documentation. |
| 51 """); |
| 143 }); | 52 }); |
| 144 | 53 |
| 145 integration('an unknown subcommand displays an error message', () { | 54 integration('running pub with just --version displays version', () { |
| 146 schedulePub(args: ['cache', 'quylthulg'], error: ''' | 55 schedulePub(args: ['--version'], output: 'Pub 0.1.2+3'); |
| 147 Could not find a subcommand named "quylthulg" for "pub cache". | |
| 148 | |
| 149 Usage: pub cache <subcommand> | |
| 150 -h, --help Print usage information for this command. | |
| 151 | |
| 152 Available subcommands: | |
| 153 add Install a package. | |
| 154 repair Reinstall cached packages. | |
| 155 | |
| 156 Run "pub help" to see global options. | |
| 157 See http://dartlang.org/tools/pub/cmd/pub-cache.html for detailed docume
ntation. | |
| 158 ''', exitCode: exit_codes.USAGE); | |
| 159 }); | |
| 160 | |
| 161 integration('an unknown option displays an error message', () { | |
| 162 schedulePub(args: ['--blorf'], error: ''' | |
| 163 Could not find an option named "blorf". | |
| 164 Run "pub help" to see available options. | |
| 165 ''', exitCode: exit_codes.USAGE); | |
| 166 }); | |
| 167 | |
| 168 integration('an unknown command option displays an error message', () { | |
| 169 // TODO(rnystrom): When pub has command-specific options, a more precise | |
| 170 // error message would be good here. | |
| 171 schedulePub(args: ['version', '--blorf'], error: ''' | |
| 172 Could not find an option named "blorf". | |
| 173 Run "pub help" to see available options. | |
| 174 ''', exitCode: exit_codes.USAGE); | |
| 175 }); | |
| 176 | |
| 177 integration('an unexpected argument displays an error message', () { | |
| 178 schedulePub(args: ['version', 'unexpected'], error: ''' | |
| 179 Command "version" does not take any arguments. | |
| 180 | |
| 181 Usage: pub version | |
| 182 -h, --help Print usage information for this command. | |
| 183 | |
| 184 Run "pub help" to see global options. | |
| 185 ''', exitCode: exit_codes.USAGE); | |
| 186 }); | |
| 187 | |
| 188 integration('a missing subcommand displays an error message', () { | |
| 189 schedulePub(args: ['cache'], error: ''' | |
| 190 Missing subcommand for "pub cache". | |
| 191 | |
| 192 Usage: pub cache <subcommand> | |
| 193 -h, --help Print usage information for this command. | |
| 194 | |
| 195 Available subcommands: | |
| 196 add Install a package. | |
| 197 repair Reinstall cached packages. | |
| 198 | |
| 199 Run "pub help" to see global options. | |
| 200 See http://dartlang.org/tools/pub/cmd/pub-cache.html for detailed docume
ntation. | |
| 201 ''', exitCode: exit_codes.USAGE); | |
| 202 }); | |
| 203 | |
| 204 group('help', () { | |
| 205 integration('shows global help if no command is given', () { | |
| 206 schedulePub(args: ['help'], output: USAGE_STRING); | |
| 207 }); | |
| 208 | |
| 209 integration('shows help for a command', () { | |
| 210 schedulePub(args: ['help', 'get'], output: ''' | |
| 211 Get the current package's dependencies. | |
| 212 | |
| 213 Usage: pub get | |
| 214 -h, --help Print usage information for this command. | |
| 215 --[no-]offline Use cached packages instead of accessing the n
etwork. | |
| 216 -n, --dry-run Report what dependencies would change but don'
t change any. | |
| 217 | |
| 218 Run "pub help" to see global options. | |
| 219 See http://dartlang.org/tools/pub/cmd/pub-get.html for detailed docu
mentation. | |
| 220 '''); | |
| 221 }); | |
| 222 | |
| 223 integration('shows help for a command', () { | |
| 224 schedulePub(args: ['help', 'publish'], output: ''' | |
| 225 Publish the current package to pub.dartlang.org. | |
| 226 | |
| 227 Usage: pub publish [options] | |
| 228 -h, --help Print usage information for this command. | |
| 229 -n, --dry-run Validate but do not publish the package. | |
| 230 -f, --force Publish without confirmation if there are no errors
. | |
| 231 --server The package server to which to upload this package. | |
| 232 (defaults to "https://pub.dartlang.org") | |
| 233 | |
| 234 Run "pub help" to see global options. | |
| 235 See http://dartlang.org/tools/pub/cmd/pub-lish.html for detailed doc
umentation. | |
| 236 '''); | |
| 237 }); | |
| 238 | |
| 239 integration('shows non-truncated help', () { | |
| 240 schedulePub(args: ['help', 'serve'], output: ''' | |
| 241 Run a local web development server. | |
| 242 | |
| 243 By default, this serves "web/" and "test/", but an explicit list of | |
| 244 directories to serve can be provided as well. | |
| 245 | |
| 246 Usage: pub serve [directories...] | |
| 247 -h, --help Print usage information for this command. | |
| 248 --mode Mode to run transformers in. | |
| 249 (defaults to "debug") | |
| 250 | |
| 251 --all Use all default source directories. | |
| 252 --hostname The hostname to listen on. | |
| 253 (defaults to "localhost") | |
| 254 | |
| 255 --port The base port to listen on. | |
| 256 (defaults to "8080") | |
| 257 | |
| 258 --[no-]dart2js Compile Dart to JavaScript. | |
| 259 (defaults to on) | |
| 260 | |
| 261 --[no-]force-poll Force the use of a polling filesystem watch
er. | |
| 262 | |
| 263 Run "pub help" to see global options. | |
| 264 See http://dartlang.org/tools/pub/cmd/pub-serve.html for detailed do
cumentation. | |
| 265 '''); | |
| 266 }); | |
| 267 | |
| 268 integration('shows help for a subcommand', () { | |
| 269 schedulePub(args: ['help', 'cache', 'list'], output: ''' | |
| 270 List packages in the system cache. | |
| 271 | |
| 272 Usage: pub cache list | |
| 273 -h, --help Print usage information for this command. | |
| 274 | |
| 275 Run "pub help" to see global options. | |
| 276 '''); | |
| 277 }); | |
| 278 | |
| 279 integration('an unknown help command displays an error message', () { | |
| 280 schedulePub(args: ['help', 'quylthulg'], error: ''' | |
| 281 Could not find a command named "quylthulg". | |
| 282 | |
| 283 Available commands: | |
| 284 build Apply transformers to build a package. | |
| 285 cache Work with the system cache. | |
| 286 deps Print package dependencies. | |
| 287 downgrade Downgrade the current package's dependencies to oldest
versions. | |
| 288 get Get the current package's dependencies. | |
| 289 global Work with global packages. | |
| 290 help Display help information for Pub. | |
| 291 publish Publish the current package to pub.dartlang.org. | |
| 292 run Run an executable from a package. | |
| 293 serve Run a local web development server. | |
| 294 upgrade Upgrade the current package's dependencies to latest v
ersions. | |
| 295 uploader Manage uploaders for a package on pub.dartlang.org. | |
| 296 version Print pub version. | |
| 297 ''', exitCode: exit_codes.USAGE); | |
| 298 }); | |
| 299 | |
| 300 integration('an unknown help subcommand displays an error message', () { | |
| 301 schedulePub(args: ['help', 'cache', 'quylthulg'], error: ''' | |
| 302 Could not find a subcommand named "quylthulg" for "pub cache". | |
| 303 | |
| 304 Usage: pub cache <subcommand> | |
| 305 -h, --help Print usage information for this command. | |
| 306 | |
| 307 Available subcommands: | |
| 308 add Install a package. | |
| 309 repair Reinstall cached packages. | |
| 310 | |
| 311 Run "pub help" to see global options. | |
| 312 See http://dartlang.org/tools/pub/cmd/pub-cache.html for detailed do
cumentation. | |
| 313 ''', exitCode: exit_codes.USAGE); | |
| 314 }); | |
| 315 | |
| 316 integration('an unexpected help subcommand displays an error message', () { | |
| 317 schedulePub(args: ['help', 'version', 'badsubcommand'], error: ''' | |
| 318 Command "pub version" does not expect a subcommand. | |
| 319 | |
| 320 Usage: pub version | |
| 321 -h, --help Print usage information for this command. | |
| 322 | |
| 323 Run "pub help" to see global options. | |
| 324 ''', exitCode: exit_codes.USAGE); | |
| 325 }); | |
| 326 }); | |
| 327 | |
| 328 group('version', () { | |
| 329 integration('displays the current version', () { | |
| 330 schedulePub(args: ['version'], output: VERSION_STRING); | |
| 331 }); | |
| 332 }); | 56 }); |
| 333 } | 57 } |
| OLD | NEW |