<commit_before>// 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:test/test.dart';

import '../utils.dart';

void main() {
  group('help', help);
}

void help() {
  TestProject p;

  tearDown(() => p?.dispose());

  test('pub', () {
    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));
  });
}
<commit_msg>Add some additional tests to test the commands that are currently passing the help <verb> == <verb> --help assertion.<commit_after>// 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:test/test.dart';

import '../utils.dart';

void main() {
  group('help', help);
}

void help() {
  TestProject p;

  tearDown(() => p?.dispose());

  /// Commands not tested by the following loop.
  List<String> _commandsNotTested = <String>[
    'help', // `dart help help` is redundant
    'test' // TODO(jwren) not yet implemented, dartbug.com/41041
  ];
  DartdevRunner([]).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([]).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: '');
      }
    });
  });
}

{'fraction_non_alphanumeric': 0.15762081784386617, 'fraction_numerical': 0.0048327137546468404, 'mean_word_length': 3.455298013245033, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5382692', 'n_tokens_mistral': 826, 'n_tokens_neox': 799, 'n_words': 241}