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...) Expand 10 before | Expand all | Expand 10 after 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 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.
| |
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 commands: | |
94 list List packages in 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 Available subcommands: | |
127 list List packages in system cache. | |
128 ''', | |
129 exitCode: exit_codes.USAGE); | |
94 }); | 130 }); |
95 | 131 |
96 integration('an unknown option displays an error message', () { | 132 integration('an unknown option displays an error message', () { |
97 schedulePub(args: ['--blorf'], | 133 schedulePub(args: ['--blorf'], |
98 error: ''' | 134 error: ''' |
99 Could not find an option named "blorf". | 135 Could not find an option named "blorf". |
100 Run "pub help" to see available options. | 136 Run "pub help" to see available options. |
101 ''', | 137 ''', |
102 exitCode: 64); | 138 exitCode: exit_codes.USAGE); |
103 }); | 139 }); |
104 | 140 |
105 integration('an unknown command option displays an error message', () { | 141 integration('an unknown command option displays an error message', () { |
106 // TODO(rnystrom): When pub has command-specific options, a more precise | 142 // TODO(rnystrom): When pub has command-specific options, a more precise |
107 // error message would be good here. | 143 // error message would be good here. |
108 schedulePub(args: ['version', '--blorf'], | 144 schedulePub(args: ['version', '--blorf'], |
109 error: ''' | 145 error: ''' |
110 Could not find an option named "blorf". | 146 Could not find an option named "blorf". |
111 Run "pub help" to see available options. | 147 Run "pub help" to see available options. |
112 ''', | 148 ''', |
113 exitCode: 64); | 149 exitCode: exit_codes.USAGE); |
114 }); | 150 }); |
115 | 151 |
116 integration('an unexpected argument displays an error message', () { | 152 integration('an unexpected argument displays an error message', () { |
117 schedulePub(args: ['version', 'unexpected'], | 153 schedulePub(args: ['version', 'unexpected'], |
118 output: ''' | 154 output: ''' |
119 Print pub version. | 155 Print pub version. |
120 | 156 |
121 Usage: pub version | 157 Usage: pub version |
122 -h, --help Print usage information for this command. | 158 -h, --help Print usage information for this command. |
123 ''', | 159 ''', |
124 error: ''' | 160 error: ''' |
125 Command "version" does not take any arguments. | 161 Command "version" does not take any arguments. |
126 ''', | 162 ''', |
127 exitCode: 64); | 163 exitCode: exit_codes.USAGE); |
164 }); | |
165 | |
166 integration('a missing subcommand displays an error message', () { | |
167 schedulePub(args: ['cache'], | |
168 error: ''' | |
169 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.
| |
170 | |
171 Available subcommands: | |
172 list List packages in system cache. | |
173 ''', | |
174 exitCode: exit_codes.USAGE); | |
128 }); | 175 }); |
129 | 176 |
130 group('help', () { | 177 group('help', () { |
131 integration('shows global help if no command is given', () { | 178 integration('shows global help if no command is given', () { |
132 schedulePub(args: ['help'], output: USAGE_STRING); | 179 schedulePub(args: ['help'], output: USAGE_STRING); |
133 }); | 180 }); |
134 | 181 |
135 integration('shows help for a command', () { | 182 integration('shows help for a command', () { |
136 schedulePub(args: ['help', 'get'], | 183 schedulePub(args: ['help', 'get'], |
137 output: ''' | 184 output: ''' |
(...skipping 12 matching lines...) Expand all Loading... | |
150 | 197 |
151 Usage: pub publish [options] | 198 Usage: pub publish [options] |
152 -h, --help Print usage information for this command. | 199 -h, --help Print usage information for this command. |
153 -n, --dry-run Validate but do not publish the package. | 200 -n, --dry-run Validate but do not publish the package. |
154 -f, --force Publish without confirmation if there are no errors . | 201 -f, --force Publish without confirmation if there are no errors . |
155 --server The package server to which to upload this package. | 202 --server The package server to which to upload this package. |
156 (defaults to "https://pub.dartlang.org") | 203 (defaults to "https://pub.dartlang.org") |
157 '''); | 204 '''); |
158 }); | 205 }); |
159 | 206 |
207 integration('shows help for a subcommand', () { | |
208 schedulePub(args: ['help', 'cache', 'list'], | |
209 output: ''' | |
210 List packages in system cache. | |
211 | |
212 Usage: pub cache list | |
213 -h, --help Print usage information for this command. | |
214 '''); | |
215 }); | |
216 | |
160 integration('an unknown help command displays an error message', () { | 217 integration('an unknown help command displays an error message', () { |
161 schedulePub(args: ['help', 'quylthulg'], | 218 schedulePub(args: ['help', 'quylthulg'], |
162 error: ''' | 219 error: ''' |
163 Could not find a command named "quylthulg". | 220 Could not find a command named "quylthulg". |
164 Run "pub help" to see available commands. | 221 |
222 Available commands: | |
223 build Apply transformers to build a package. | |
224 get Get the current package's dependencies. | |
225 help Display help information for Pub. | |
226 publish Publish the current package to pub.dartlang.org. | |
227 serve Run a local web development server. | |
228 upgrade Upgrade the current package's dependencies to latest ve rsions. | |
229 uploader Manage uploaders for a package on pub.dartlang.org. | |
230 version Print pub version. | |
165 ''', | 231 ''', |
166 exitCode: 64); | 232 exitCode: exit_codes.USAGE); |
167 }); | 233 }); |
168 | 234 |
235 integration('an unknown help subcommand displays an error message', () { | |
236 schedulePub(args: ['help', 'cache', 'quylthulg'], | |
237 error: ''' | |
238 Could not find a subcommand named "quylthulg" for "pub cache". | |
239 | |
240 Available subcommands: | |
241 list List packages in system cache. | |
242 ''', | |
243 exitCode: exit_codes.USAGE); | |
244 }); | |
245 | |
246 integration('an unexpected help subcommand displays an error message', () { | |
247 schedulePub(args: ['help', 'version', 'badsubcommand'], | |
248 error: ''' | |
249 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.
| |
250 ''', | |
251 exitCode: exit_codes.USAGE); | |
252 }); | |
169 }); | 253 }); |
170 | 254 |
171 group('version', () { | 255 group('version', () { |
172 integration('displays the current version', () { | 256 integration('displays the current version', () { |
173 schedulePub(args: ['version'], output: VERSION_STRING); | 257 schedulePub(args: ['version'], output: VERSION_STRING); |
174 }); | 258 }); |
175 }); | 259 }); |
176 } | 260 } |
OLD | NEW |