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 'test_pub.dart'; | 10 import 'test_pub.dart'; |
10 | 11 |
11 final USAGE_STRING = """ | 12 final USAGE_STRING = """ |
12 Pub is a package manager for Dart. | 13 Pub is a package manager for Dart. |
13 | 14 |
14 Usage: pub command [arguments] | 15 Usage: pub <command> [arguments] |
15 | 16 |
16 Global options: | 17 Global options: |
17 -h, --help Print this usage information. | 18 -h, --help Print this usage information. |
18 --version Print pub version. | 19 --version Print pub version. |
19 --[no-]trace Print debugging information when an error occurs. | 20 --[no-]trace Print debugging information when an error occurs. |
20 --verbosity Control output verbosity. | 21 --verbosity Control output verbosity. |
21 | 22 |
22 [all] Show all output including internal tracing messages. | 23 [all] Show all output including internal tracing messages. |
23 [io] Also show IO operations. | 24 [io] Also show IO operations. |
24 [normal] Show errors, warnings, and user messages. | 25 [normal] Show errors, warnings, and user messages. |
25 [solver] Show steps during version resolution. | 26 [solver] Show steps during version resolution. |
26 | 27 |
27 -v, --verbose Shortcut for "--verbosity=all". | 28 -v, --verbose Shortcut for "--verbosity=all". |
28 | 29 |
29 Available commands: | 30 Available commands: |
30 build Copy and compile all Dart entrypoints in the 'web' directory. | 31 build Apply transformers to build a package. |
31 get Get the current package's dependencies. | 32 get Get the current package's dependencies. |
32 help Display help information for Pub. | 33 help Display help information for Pub. |
33 publish Publish the current package to pub.dartlang.org. | 34 publish Publish the current package to pub.dartlang.org. |
34 serve Run a local web development server. | 35 serve Run a local web development server. |
35 upgrade Upgrade the current package's dependencies to latest versions. | 36 upgrade Upgrade the current package's dependencies to latest versions. |
36 uploader Manage uploaders for a package on pub.dartlang.org. | 37 uploader Manage uploaders for a package on pub.dartlang.org. |
37 version Print pub version. | 38 version Print pub version. |
38 | 39 |
39 Use "pub help [command]" for more information about a command. | 40 Use "pub help [command]" for more information about a command. |
40 """; | 41 """; |
(...skipping 32 matching lines...) Loading... |
73 schedulePub(args: ['get', '-h'], | 74 schedulePub(args: ['get', '-h'], |
74 output: ''' | 75 output: ''' |
75 Get the current package's dependencies. | 76 Get the current package's dependencies. |
76 | 77 |
77 Usage: pub get | 78 Usage: pub get |
78 -h, --help Print usage information for this command. | 79 -h, --help Print usage information for this command. |
79 --[no-]offline Use cached packages instead of accessing the net
work. | 80 --[no-]offline Use cached packages instead of accessing the net
work. |
80 '''); | 81 '''); |
81 }); | 82 }); |
82 | 83 |
| 84 integration('running pub with --help after a command with subcommands shows ' |
| 85 'command usage', () { |
| 86 schedulePub(args: ['cache', '--help'], |
| 87 output: ''' |
| 88 Work with the system cache. |
| 89 |
| 90 Usage: pub cache <subcommand> |
| 91 -h, --help Print usage information for this command. |
| 92 |
| 93 Available subcommands: |
| 94 list List packages in the system cache. |
| 95 '''); |
| 96 }); |
| 97 |
| 98 |
83 integration('running pub with just --version displays version', () { | 99 integration('running pub with just --version displays version', () { |
84 schedulePub(args: ['--version'], output: VERSION_STRING); | 100 schedulePub(args: ['--version'], output: VERSION_STRING); |
85 }); | 101 }); |
86 | 102 |
87 integration('an unknown command displays an error message', () { | 103 integration('an unknown command displays an error message', () { |
88 schedulePub(args: ['quylthulg'], | 104 schedulePub(args: ['quylthulg'], |
89 error: ''' | 105 error: ''' |
90 Could not find a command named "quylthulg". | 106 Could not find a command named "quylthulg". |
91 Run "pub help" to see available commands. | 107 |
| 108 Available commands: |
| 109 build Apply transformers to build a package. |
| 110 get Get the current package's dependencies. |
| 111 help Display help information for Pub. |
| 112 publish Publish the current package to pub.dartlang.org. |
| 113 serve Run a local web development server. |
| 114 upgrade Upgrade the current package's dependencies to latest versio
ns. |
| 115 uploader Manage uploaders for a package on pub.dartlang.org. |
| 116 version Print pub version. |
92 ''', | 117 ''', |
93 exitCode: 64); | 118 exitCode: exit_codes.USAGE); |
| 119 }); |
| 120 |
| 121 integration('an unknown subcommand displays an error message', () { |
| 122 schedulePub(args: ['cache', 'quylthulg'], |
| 123 error: ''' |
| 124 Could not find a subcommand named "quylthulg" for "pub cache". |
| 125 |
| 126 Usage: pub cache <subcommand> |
| 127 -h, --help Print usage information for this command. |
| 128 |
| 129 Available subcommands: |
| 130 list List packages in the system cache. |
| 131 ''', |
| 132 exitCode: exit_codes.USAGE); |
94 }); | 133 }); |
95 | 134 |
96 integration('an unknown option displays an error message', () { | 135 integration('an unknown option displays an error message', () { |
97 schedulePub(args: ['--blorf'], | 136 schedulePub(args: ['--blorf'], |
98 error: ''' | 137 error: ''' |
99 Could not find an option named "blorf". | 138 Could not find an option named "blorf". |
100 Run "pub help" to see available options. | 139 Run "pub help" to see available options. |
101 ''', | 140 ''', |
102 exitCode: 64); | 141 exitCode: exit_codes.USAGE); |
103 }); | 142 }); |
104 | 143 |
105 integration('an unknown command option displays an error message', () { | 144 integration('an unknown command option displays an error message', () { |
106 // TODO(rnystrom): When pub has command-specific options, a more precise | 145 // TODO(rnystrom): When pub has command-specific options, a more precise |
107 // error message would be good here. | 146 // error message would be good here. |
108 schedulePub(args: ['version', '--blorf'], | 147 schedulePub(args: ['version', '--blorf'], |
109 error: ''' | 148 error: ''' |
110 Could not find an option named "blorf". | 149 Could not find an option named "blorf". |
111 Run "pub help" to see available options. | 150 Run "pub help" to see available options. |
112 ''', | 151 ''', |
113 exitCode: 64); | 152 exitCode: exit_codes.USAGE); |
114 }); | 153 }); |
115 | 154 |
116 integration('an unexpected argument displays an error message', () { | 155 integration('an unexpected argument displays an error message', () { |
117 schedulePub(args: ['version', 'unexpected'], | 156 schedulePub(args: ['version', 'unexpected'], |
118 output: ''' | 157 error: ''' |
119 Print pub version. | 158 Command "version" does not take any arguments. |
120 | 159 |
121 Usage: pub version | 160 Usage: pub version |
122 -h, --help Print usage information for this command. | 161 -h, --help Print usage information for this command. |
123 ''', | 162 ''', |
| 163 exitCode: exit_codes.USAGE); |
| 164 }); |
| 165 |
| 166 integration('a missing subcommand displays an error message', () { |
| 167 schedulePub(args: ['cache'], |
124 error: ''' | 168 error: ''' |
125 Command "version" does not take any arguments. | 169 Missing subcommand for "pub cache". |
| 170 |
| 171 Usage: pub cache <subcommand> |
| 172 -h, --help Print usage information for this command. |
| 173 |
| 174 Available subcommands: |
| 175 list List packages in the system cache. |
126 ''', | 176 ''', |
127 exitCode: 64); | 177 exitCode: exit_codes.USAGE); |
128 }); | 178 }); |
129 | 179 |
130 group('help', () { | 180 group('help', () { |
131 integration('shows global help if no command is given', () { | 181 integration('shows global help if no command is given', () { |
132 schedulePub(args: ['help'], output: USAGE_STRING); | 182 schedulePub(args: ['help'], output: USAGE_STRING); |
133 }); | 183 }); |
134 | 184 |
135 integration('shows help for a command', () { | 185 integration('shows help for a command', () { |
136 schedulePub(args: ['help', 'get'], | 186 schedulePub(args: ['help', 'get'], |
137 output: ''' | 187 output: ''' |
(...skipping 12 matching lines...) Loading... |
150 | 200 |
151 Usage: pub publish [options] | 201 Usage: pub publish [options] |
152 -h, --help Print usage information for this command. | 202 -h, --help Print usage information for this command. |
153 -n, --dry-run Validate but do not publish the package. | 203 -n, --dry-run Validate but do not publish the package. |
154 -f, --force Publish without confirmation if there are no errors
. | 204 -f, --force Publish without confirmation if there are no errors
. |
155 --server The package server to which to upload this package. | 205 --server The package server to which to upload this package. |
156 (defaults to "https://pub.dartlang.org") | 206 (defaults to "https://pub.dartlang.org") |
157 '''); | 207 '''); |
158 }); | 208 }); |
159 | 209 |
| 210 integration('shows help for a subcommand', () { |
| 211 schedulePub(args: ['help', 'cache', 'list'], |
| 212 output: ''' |
| 213 List packages in the system cache. |
| 214 |
| 215 Usage: pub cache list |
| 216 -h, --help Print usage information for this command. |
| 217 '''); |
| 218 }); |
| 219 |
160 integration('an unknown help command displays an error message', () { | 220 integration('an unknown help command displays an error message', () { |
161 schedulePub(args: ['help', 'quylthulg'], | 221 schedulePub(args: ['help', 'quylthulg'], |
162 error: ''' | 222 error: ''' |
163 Could not find a command named "quylthulg". | 223 Could not find a command named "quylthulg". |
164 Run "pub help" to see available commands. | 224 |
| 225 Available commands: |
| 226 build Apply transformers to build a package. |
| 227 get Get the current package's dependencies. |
| 228 help Display help information for Pub. |
| 229 publish Publish the current package to pub.dartlang.org. |
| 230 serve Run a local web development server. |
| 231 upgrade Upgrade the current package's dependencies to latest ve
rsions. |
| 232 uploader Manage uploaders for a package on pub.dartlang.org. |
| 233 version Print pub version. |
165 ''', | 234 ''', |
166 exitCode: 64); | 235 exitCode: exit_codes.USAGE); |
167 }); | 236 }); |
168 | 237 |
| 238 integration('an unknown help subcommand displays an error message', () { |
| 239 schedulePub(args: ['help', 'cache', 'quylthulg'], |
| 240 error: ''' |
| 241 Could not find a subcommand named "quylthulg" for "pub cache". |
| 242 |
| 243 Usage: pub cache <subcommand> |
| 244 -h, --help Print usage information for this command. |
| 245 |
| 246 Available subcommands: |
| 247 list List packages in the system cache. |
| 248 ''', |
| 249 exitCode: exit_codes.USAGE); |
| 250 }); |
| 251 |
| 252 integration('an unexpected help subcommand displays an error message', () { |
| 253 schedulePub(args: ['help', 'version', 'badsubcommand'], |
| 254 error: ''' |
| 255 Command "pub version" does not expect a subcommand. |
| 256 |
| 257 Usage: pub version |
| 258 -h, --help Print usage information for this command. |
| 259 ''', |
| 260 exitCode: exit_codes.USAGE); |
| 261 }); |
169 }); | 262 }); |
170 | 263 |
171 group('version', () { | 264 group('version', () { |
172 integration('displays the current version', () { | 265 integration('displays the current version', () { |
173 schedulePub(args: ['version'], output: VERSION_STRING); | 266 schedulePub(args: ['version'], output: VERSION_STRING); |
174 }); | 267 }); |
175 }); | 268 }); |
176 } | 269 } |
OLD | NEW |