cd970af91a
This includes the following pub commits: git log --format="%C(auto) %h %s" 5b4df5a6f931c63622ac349602d6ef0367e8070f..fb72c1f774ca27556225b207185c0b6b6ab1c274 fb72c1f7 Make `run` available (but deprecated) in the embedding (#2698) 63b56ea4 Return the exit-code from commands (#2689) 7fc4e273 Deprecate top level (#2694) Change-Id: I5842b1ecb15fc7844d628e2ad5fb00e3f627dbff Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168347 Commit-Queue: Sigurd Meldgaard <sigurdm@google.com> Reviewed-by: Sigurd Meldgaard <sigurdm@google.com> Reviewed-by: Ben Konyi <bkonyi@google.com> Reviewed-by: Jonas Jensen <jonasfj@google.com>
63 lines
2.0 KiB
Dart
63 lines
2.0 KiB
Dart
// Copyright (c) 2020, 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.
|
|
|
|
import 'package:args/command_runner.dart';
|
|
import 'package:dartdev/dartdev.dart';
|
|
import 'package:dartdev/src/analytics.dart' show disabledAnalytics;
|
|
import 'package:test/test.dart';
|
|
|
|
import '../utils.dart';
|
|
|
|
void main() {
|
|
group('help', help, timeout: longTimeout);
|
|
}
|
|
|
|
void help() {
|
|
TestProject p;
|
|
|
|
tearDown(() => p?.dispose());
|
|
|
|
/// Commands not tested by the following loop.
|
|
List<String> _commandsNotTested = <String>[
|
|
'help', // `dart help help` is redundant
|
|
];
|
|
DartdevRunner(['--disable-dartdev-analytics'], disabledAnalytics)
|
|
.commands
|
|
.forEach((String commandKey, Command command) {
|
|
if (!_commandsNotTested.contains(commandKey)) {
|
|
test('(help $commandKey == $commandKey --help)', () {
|
|
p = project();
|
|
var result = p.runSync('help', [commandKey]);
|
|
var verbHelpResult = p.runSync(commandKey, ['--help']);
|
|
|
|
expect(result.stdout, contains(verbHelpResult.stdout));
|
|
expect(result.stderr, contains(verbHelpResult.stderr));
|
|
});
|
|
}
|
|
});
|
|
|
|
test('(help pub == pub --help)', () {
|
|
p = project();
|
|
var result = p.runSync('help', ['pub']);
|
|
var pubHelpResult = p.runSync('pub', ['--help']);
|
|
|
|
expect(result.stdout, contains(pubHelpResult.stdout));
|
|
expect(result.stderr, contains(pubHelpResult.stderr));
|
|
});
|
|
|
|
test('(--help flags also have -h abbr)', () {
|
|
DartdevRunner(['--disable-dartdev-analytics'], disabledAnalytics)
|
|
.commands
|
|
.forEach((String commandKey, Command command) {
|
|
var helpOption = command.argParser.options['help'];
|
|
// Some commands (like pub which use
|
|
// "argParser = ArgParser.allowAnything()") may not have the help Option
|
|
// accessible with the API used above:
|
|
if (helpOption != null) {
|
|
expect(helpOption.abbr, 'h', reason: '');
|
|
}
|
|
});
|
|
});
|
|
}
|