Chromium Code Reviews| Index: sdk/lib/_internal/pub/test/pub_test.dart |
| diff --git a/sdk/lib/_internal/pub/test/pub_test.dart b/sdk/lib/_internal/pub/test/pub_test.dart |
| index 336e125d6dc347762da5a81077cacd7c4c0e7cb8..d4c9b2b1499f020459e1413dcf0281050eb4ec8d 100644 |
| --- a/sdk/lib/_internal/pub/test/pub_test.dart |
| +++ b/sdk/lib/_internal/pub/test/pub_test.dart |
| @@ -6,12 +6,13 @@ library pub_tests; |
| import 'package:scheduled_test/scheduled_test.dart'; |
| +import '../lib/src/exit_codes.dart' as exit_codes; |
| import 'test_pub.dart'; |
| final USAGE_STRING = """ |
| Pub is a package manager for Dart. |
| - Usage: pub command [arguments] |
| + Usage: pub <command> [arguments] |
| Global options: |
| -h, --help Print this usage information. |
| @@ -27,7 +28,7 @@ final USAGE_STRING = """ |
| -v, --verbose Shortcut for "--verbosity=all". |
| Available commands: |
| - build Copy and compile all Dart entrypoints in the 'web' directory. |
| + build Apply transformers to build a package. |
| get Get the current package's dependencies. |
| help Display help information for Pub. |
| publish Publish the current package to pub.dartlang.org. |
| @@ -80,6 +81,21 @@ main() { |
| '''); |
| }); |
| + integration('running pub with --help after command with subcommands shows ' |
|
nweiz
2014/01/31 21:42:06
"after command" -> "after a command"
Bob Nystrom
2014/02/01 01:49:32
Done.
|
| + 'command usage', () { |
| + schedulePub(args: ['cache', '--help'], |
| + output: ''' |
| + Work with the system cache. |
| + |
| + Usage: pub cache <subcommand> |
| + -h, --help Print usage information for this command. |
| + |
| + Available commands: |
| + list List packages in system cache. |
| + '''); |
| + }); |
| + |
| + |
| integration('running pub with just --version displays version', () { |
| schedulePub(args: ['--version'], output: VERSION_STRING); |
| }); |
| @@ -88,9 +104,29 @@ main() { |
| schedulePub(args: ['quylthulg'], |
| error: ''' |
| Could not find a command named "quylthulg". |
| - Run "pub help" to see available commands. |
| + |
| + Available commands: |
| + build Apply transformers to build a package. |
| + get Get the current package's dependencies. |
| + help Display help information for Pub. |
| + publish Publish the current package to pub.dartlang.org. |
| + serve Run a local web development server. |
| + upgrade Upgrade the current package's dependencies to latest versions. |
| + uploader Manage uploaders for a package on pub.dartlang.org. |
| + version Print pub version. |
| ''', |
| - exitCode: 64); |
| + exitCode: exit_codes.USAGE); |
| + }); |
| + |
| + integration('an unknown subcommand displays an error message', () { |
| + schedulePub(args: ['cache', 'quylthulg'], |
| + error: ''' |
| + Could not find a subcommand named "quylthulg" for "pub cache". |
| + |
| + Available subcommands: |
| + list List packages in system cache. |
| + ''', |
| + exitCode: exit_codes.USAGE); |
| }); |
| integration('an unknown option displays an error message', () { |
| @@ -99,7 +135,7 @@ main() { |
| Could not find an option named "blorf". |
| Run "pub help" to see available options. |
| ''', |
| - exitCode: 64); |
| + exitCode: exit_codes.USAGE); |
| }); |
| integration('an unknown command option displays an error message', () { |
| @@ -110,7 +146,7 @@ main() { |
| Could not find an option named "blorf". |
| Run "pub help" to see available options. |
| ''', |
| - exitCode: 64); |
| + exitCode: exit_codes.USAGE); |
| }); |
| integration('an unexpected argument displays an error message', () { |
| @@ -124,7 +160,18 @@ main() { |
| error: ''' |
| Command "version" does not take any arguments. |
| ''', |
| - exitCode: 64); |
| + exitCode: exit_codes.USAGE); |
| + }); |
| + |
| + integration('a missing subcommand displays an error message', () { |
| + schedulePub(args: ['cache'], |
| + error: ''' |
| + Missing subcommand for "pub cache". |
|
nweiz
2014/01/31 21:42:06
This should also mention "Usage: pub cache <comman
Bob Nystrom
2014/02/01 01:49:32
Done.
|
| + |
| + Available subcommands: |
| + list List packages in system cache. |
| + ''', |
| + exitCode: exit_codes.USAGE); |
| }); |
| group('help', () { |
| @@ -157,15 +204,52 @@ main() { |
| '''); |
| }); |
| + integration('shows help for a subcommand', () { |
| + schedulePub(args: ['help', 'cache', 'list'], |
| + output: ''' |
| + List packages in system cache. |
| + |
| + Usage: pub cache list |
| + -h, --help Print usage information for this command. |
| + '''); |
| + }); |
| + |
| integration('an unknown help command displays an error message', () { |
| schedulePub(args: ['help', 'quylthulg'], |
| error: ''' |
| Could not find a command named "quylthulg". |
| - Run "pub help" to see available commands. |
| + |
| + Available commands: |
| + build Apply transformers to build a package. |
| + get Get the current package's dependencies. |
| + help Display help information for Pub. |
| + publish Publish the current package to pub.dartlang.org. |
| + serve Run a local web development server. |
| + upgrade Upgrade the current package's dependencies to latest versions. |
| + uploader Manage uploaders for a package on pub.dartlang.org. |
| + version Print pub version. |
| + ''', |
| + exitCode: exit_codes.USAGE); |
| + }); |
| + |
| + integration('an unknown help subcommand displays an error message', () { |
| + schedulePub(args: ['help', 'cache', 'quylthulg'], |
| + error: ''' |
| + Could not find a subcommand named "quylthulg" for "pub cache". |
| + |
| + Available subcommands: |
| + list List packages in system cache. |
| ''', |
| - exitCode: 64); |
| + exitCode: exit_codes.USAGE); |
| }); |
| + integration('an unexpected help subcommand displays an error message', () { |
| + schedulePub(args: ['help', 'version', 'badsubcommand'], |
| + error: ''' |
| + Command "pub version" does not expect a subcommand. |
|
nweiz
2014/01/31 21:42:06
This should print the documentation for "pub versi
Bob Nystrom
2014/02/01 01:49:32
Done.
|
| + ''', |
| + exitCode: exit_codes.USAGE); |
| + }); |
| }); |
| group('version', () { |