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

Unified Diff: packages/args/test/command_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « packages/args/test/command_runner_test.dart ('k') | packages/args/test/parse_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/args/test/command_test.dart
diff --git a/packages/args/test/command_test.dart b/packages/args/test/command_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..888016a4053fd0d74cfaf53fa8d60acb4ee77b76
--- /dev/null
+++ b/packages/args/test/command_test.dart
@@ -0,0 +1,106 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library command_test;
+
+import 'package:args/command_runner.dart';
+import 'package:test/test.dart';
+import 'utils.dart';
+
+void main() {
+ var foo;
+ setUp(() {
+ foo = new FooCommand();
+
+ // Make sure [Command.runner] is set up.
+ new CommandRunner("test", "A test command runner.").addCommand(foo);
+ });
+
+ group(".invocation has a sane default", () {
+ test("without subcommands", () {
+ expect(foo.invocation, equals("test foo [arguments]"));
+ });
+
+ test("with subcommands", () {
+ foo.addSubcommand(new AsyncCommand());
+ expect(foo.invocation, equals("test foo <subcommand> [arguments]"));
+ });
+
+ test("for a subcommand", () {
+ var async = new AsyncCommand();
+ foo.addSubcommand(async);
+
+ expect(async.invocation, equals("test foo async [arguments]"));
+ });
+ });
+
+ group(".usage", () {
+ test("returns the usage string", () {
+ expect(foo.usage, equals("""
+Set a value.
+
+Usage: test foo [arguments]
+-h, --help Print this usage information.
+
+Run "test help" to see global options."""));
+ });
+
+ test("contains custom options", () {
+ foo.argParser.addFlag("flag", help: "Do something.");
+
+ expect(foo.usage, equals("""
+Set a value.
+
+Usage: test foo [arguments]
+-h, --help Print this usage information.
+ --[no-]flag Do something.
+
+Run "test help" to see global options."""));
+ });
+
+ test("doesn't print hidden subcommands", () {
+ foo.addSubcommand(new AsyncCommand());
+ foo.addSubcommand(new HiddenCommand());
+
+ expect(foo.usage, equals("""
+Set a value.
+
+Usage: test foo <subcommand> [arguments]
+-h, --help Print this usage information.
+
+Available subcommands:
+ async Set a value asynchronously.
+
+Run "test help" to see global options."""));
+ });
+
+ test("doesn't print subcommand aliases", () {
+ foo.addSubcommand(new AliasedCommand());
+
+ expect(foo.usage, equals("""
+Set a value.
+
+Usage: test foo <subcommand> [arguments]
+-h, --help Print this usage information.
+
+Available subcommands:
+ aliased Set a value.
+
+Run "test help" to see global options."""));
+ });
+ });
+
+ test("usageException splits up the message and usage", () {
+ expect(() => foo.usageException("message"), throwsUsageError("message", """
+Usage: test foo [arguments]
+-h, --help Print this usage information.
+
+Run "test help" to see global options."""));
+ });
+
+ test("considers a command hidden if all its subcommands are hidden", () {
+ foo.addSubcommand(new HiddenCommand());
+ expect(foo.hidden, isTrue);
+ });
+}
« no previous file with comments | « packages/args/test/command_runner_test.dart ('k') | packages/args/test/parse_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698