| Index: pkg/args/test/utils.dart
|
| diff --git a/pkg/args/test/utils.dart b/pkg/args/test/utils.dart
|
| index 4586f573b0d12809f4f035eb4e65ea6daef9e933..1267a53cd391c507c919061f4fa867f567e81fcd 100644
|
| --- a/pkg/args/test/utils.dart
|
| +++ b/pkg/args/test/utils.dart
|
| @@ -4,8 +4,66 @@
|
|
|
| library utils;
|
|
|
| -import 'package:unittest/unittest.dart';
|
| +import 'dart:async';
|
| +
|
| import 'package:args/args.dart';
|
| +import 'package:args/command_runner.dart';
|
| +import 'package:unittest/unittest.dart';
|
| +
|
| +class CommandRunnerWithFooter extends CommandRunner {
|
| + final usageFooter = "Also, footer!";
|
| +
|
| + CommandRunnerWithFooter(String executableName, String description)
|
| + : super(executableName, description);
|
| +}
|
| +
|
| +class FooCommand extends Command {
|
| + var hasRun = false;
|
| +
|
| + final name = "foo";
|
| + final description = "Set a value.";
|
| + final takesArguments = false;
|
| +
|
| + void run() {
|
| + hasRun = true;
|
| + }
|
| +}
|
| +
|
| +class HiddenCommand extends Command {
|
| + var hasRun = false;
|
| +
|
| + final name = "hidden";
|
| + final description = "Set a value.";
|
| + final hidden = true;
|
| + final takesArguments = false;
|
| +
|
| + void run() {
|
| + hasRun = true;
|
| + }
|
| +}
|
| +
|
| +class AliasedCommand extends Command {
|
| + var hasRun = false;
|
| +
|
| + final name = "aliased";
|
| + final description = "Set a value.";
|
| + final takesArguments = false;
|
| + final aliases = const ["alias", "als"];
|
| +
|
| + void run() {
|
| + hasRun = true;
|
| + }
|
| +}
|
| +
|
| +class AsyncCommand extends Command {
|
| + var hasRun = false;
|
| +
|
| + final name = "async";
|
| + final description = "Set a value asynchronously.";
|
| + final takesArguments = false;
|
| +
|
| + Future run() => new Future.value().then((_) => hasRun = true);
|
| +}
|
|
|
| void throwsIllegalArg(function, {String reason: null}) {
|
| expect(function, throwsArgumentError, reason: reason);
|
| @@ -14,3 +72,12 @@ void throwsIllegalArg(function, {String reason: null}) {
|
| void throwsFormat(ArgParser parser, List<String> args) {
|
| expect(() => parser.parse(args), throwsFormatException);
|
| }
|
| +
|
| +Matcher throwsUsageError(message, usage) {
|
| + return throwsA(predicate((error) {
|
| + expect(error, new isInstanceOf<UsageError>());
|
| + expect(error.message, message);
|
| + expect(error.usage, usage);
|
| + return true;
|
| + }));
|
| +}
|
|
|