Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1089)

Side by Side Diff: pkg/args/test/command_runner_test.dart

Issue 812743002: Fix the built-in help command in args. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/args/pubspec.yaml ('k') | pkg/args/test/utils.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 command_runner_test; 5 library command_runner_test;
6 6
7 import 'package:args/args.dart'; 7 import 'package:args/args.dart';
8 import 'package:args/command_runner.dart'; 8 import 'package:args/command_runner.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 10
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 expect(() => runner.run(["foo", "--help"]), prints(""" 171 expect(() => runner.run(["foo", "--help"]), prints("""
172 Set a value. 172 Set a value.
173 173
174 Usage: test foo [arguments] 174 Usage: test foo [arguments]
175 -h, --help Print this usage information. 175 -h, --help Print this usage information.
176 176
177 Run "test help" to see global options. 177 Run "test help" to see global options.
178 """)); 178 """));
179 }); 179 });
180 }); 180 });
181
182 group("with help command", () {
183 test("with no command prints the usage", () {
184 expect(() => runner.run(["help"]), prints("""
185 A test command runner.
186
187 $_DEFAULT_USAGE
188 """));
189 });
190
191 test("with a command prints the usage for that command", () {
192 var command = new FooCommand();
193 runner.addCommand(command);
194
195 expect(() => runner.run(["help", "foo"]), prints("""
196 Set a value.
197
198 Usage: test foo [arguments]
199 -h, --help Print this usage information.
200
201 Run "test help" to see global options.
202 """));
203 });
204
205 test("prints its own usage", () {
206 expect(() => runner.run(["help", "help"]), prints("""
207 Display help information for test.
208
209 Usage: test help [command]
210 -h, --help Print this usage information.
211
212 Run "test help" to see global options.
213 """));
214 });
215 });
181 }); 216 });
182 217
183 group("with a footer", () { 218 group("with a footer", () {
184 setUp(() { 219 setUp(() {
185 runner = new CommandRunnerWithFooter("test", "A test command runner."); 220 runner = new CommandRunnerWithFooter("test", "A test command runner.");
186 }); 221 });
187 222
188 test("includes the footer in the usage string", () { 223 test("includes the footer in the usage string", () {
189 expect(runner.usage, equals(""" 224 expect(runner.usage, equals("""
190 A test command runner. 225 A test command runner.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 286
252 expect(runner.run(["foo", "bar"]), 287 expect(runner.run(["foo", "bar"]),
253 throwsUsageError('Command "foo" does not take any arguments.', """ 288 throwsUsageError('Command "foo" does not take any arguments.', """
254 Usage: test foo [arguments] 289 Usage: test foo [arguments]
255 -h, --help Print this usage information. 290 -h, --help Print this usage information.
256 291
257 Run "test help" to see global options.""")); 292 Run "test help" to see global options."""));
258 }); 293 });
259 }); 294 });
260 } 295 }
OLDNEW
« no previous file with comments | « pkg/args/pubspec.yaml ('k') | pkg/args/test/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698