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