Skip to content

Commit 59d93d6

Browse files
[tool] Add command aliases (flutter#4207)
Adds aliases for all commands that put the verb first, since currently they are inconsistent which can make it hard to remember (in particular, I often write `check-foo` instead of `foo-check` when running locally, and it fails). Also does the long-overdue renaming of `test` to `dart-test`, since we now have `native-test`, `custom-test`, etc. `test` continues to work as an alias for individual muscle memory.
1 parent 754405d commit 59d93d6

17 files changed

+81
-27
lines changed

.ci/scripts/dart_unit_tests_win32.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
# found in the LICENSE file.
55
set -e
66

7-
dart ./script/tool/bin/flutter_plugin_tools.dart test \
7+
dart ./script/tool/bin/flutter_plugin_tools.dart dart-test \
88
--exclude=script/configs/windows_unit_tests_exceptions.yaml \
99
--packages-for-branch --log-timing

.cirrus.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,13 @@ task:
231231
CHANNEL: "master"
232232
CHANNEL: "stable"
233233
unit_test_script:
234-
- ./script/tool_runner.sh test --exclude=script/configs/dart_unit_tests_exceptions.yaml
234+
- ./script/tool_runner.sh dart-test --exclude=script/configs/dart_unit_tests_exceptions.yaml
235235
pathified_unit_test_script:
236236
# Run tests with path-based dependencies to ensure that publishing
237237
# the changes won't break tests of other packages in the repository
238238
# that depend on it.
239239
- ./script/tool_runner.sh make-deps-path-based --target-dependencies-with-non-breaking-updates
240-
- $PLUGIN_TOOL_COMMAND test --run-on-dirty-packages --exclude=script/configs/dart_unit_tests_exceptions.yaml
240+
- $PLUGIN_TOOL_COMMAND dart-test --run-on-dirty-packages --exclude=script/configs/dart_unit_tests_exceptions.yaml
241241
- name: linux-custom_package_tests
242242
env:
243243
PATH: $PATH:/usr/local/bin

script/tool/lib/src/custom_test_command.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class CustomTestCommand extends PackageLoopingCommand {
2828
@override
2929
final String name = 'custom-test';
3030

31+
@override
32+
List<String> get aliases => <String>['test-custom'];
33+
3134
@override
3235
final String description = 'Runs package-specific custom tests defined in '
3336
"a package's tool/$_scriptName file.\n\n"

script/tool/lib/src/test_command.dart renamed to script/tool/lib/src/dart_test_command.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import 'common/process_runner.dart';
1212
import 'common/repository_package.dart';
1313

1414
/// A command to run Dart unit tests for packages.
15-
class TestCommand extends PackageLoopingCommand {
15+
class DartTestCommand extends PackageLoopingCommand {
1616
/// Creates an instance of the test command.
17-
TestCommand(
17+
DartTestCommand(
1818
Directory packagesDir, {
1919
ProcessRunner processRunner = const ProcessRunner(),
2020
Platform platform = const LocalPlatform(),
@@ -30,7 +30,13 @@ class TestCommand extends PackageLoopingCommand {
3030
}
3131

3232
@override
33-
final String name = 'test';
33+
final String name = 'dart-test';
34+
35+
// TODO(stuartmorgan): Eventually remove 'test', which is a legacy name from
36+
// before there were other test commands that made it ambiguous. For now it's
37+
// an alias to avoid breaking people's workflows.
38+
@override
39+
List<String> get aliases => <String>['test', 'test-dart'];
3440

3541
@override
3642
final String description = 'Runs the Dart tests for all packages.\n\n'

script/tool/lib/src/dependabot_check_command.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ class DependabotCheckCommand extends PackageLoopingCommand {
3232
@override
3333
final String name = 'dependabot-check';
3434

35+
@override
36+
List<String> get aliases => <String>['check-dependabot'];
37+
3538
@override
3639
final String description =
3740
'Checks that all packages have Dependabot coverage.';

script/tool/lib/src/federation_safety_check_command.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ class FederationSafetyCheckCommand extends PackageLoopingCommand {
5252
@override
5353
final String name = 'federation-safety-check';
5454

55+
@override
56+
List<String> get aliases => <String>['check-federation-safety'];
57+
5558
@override
5659
final String description =
5760
'Checks that the change does not violate repository rules around changes '

script/tool/lib/src/gradle_check_command.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class GradleCheckCommand extends PackageLoopingCommand {
2323
@override
2424
final String name = 'gradle-check';
2525

26+
@override
27+
List<String> get aliases => <String>['check-gradle'];
28+
2629
@override
2730
final String description =
2831
'Checks that gradle files follow repository conventions.';

script/tool/lib/src/license_check_command.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ class LicenseCheckCommand extends PackageCommand {
114114
@override
115115
final String name = 'license-check';
116116

117+
@override
118+
List<String> get aliases => <String>['check-license'];
119+
117120
@override
118121
final String description =
119122
'Ensures that all code files have copyright/license blocks.';

script/tool/lib/src/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import 'build_examples_command.dart';
1313
import 'common/core.dart';
1414
import 'create_all_packages_app_command.dart';
1515
import 'custom_test_command.dart';
16+
import 'dart_test_command.dart';
1617
import 'dependabot_check_command.dart';
1718
import 'drive_examples_command.dart';
1819
import 'federation_safety_check_command.dart';
@@ -31,7 +32,6 @@ import 'publish_command.dart';
3132
import 'pubspec_check_command.dart';
3233
import 'readme_check_command.dart';
3334
import 'remove_dev_dependencies_command.dart';
34-
import 'test_command.dart';
3535
import 'update_dependency_command.dart';
3636
import 'update_excerpts_command.dart';
3737
import 'update_min_sdk_command.dart';
@@ -80,7 +80,7 @@ void main(List<String> args) {
8080
..addCommand(PubspecCheckCommand(packagesDir))
8181
..addCommand(ReadmeCheckCommand(packagesDir))
8282
..addCommand(RemoveDevDependenciesCommand(packagesDir))
83-
..addCommand(TestCommand(packagesDir))
83+
..addCommand(DartTestCommand(packagesDir))
8484
..addCommand(UpdateDependencyCommand(packagesDir))
8585
..addCommand(UpdateExcerptsCommand(packagesDir))
8686
..addCommand(UpdateMinSdkCommand(packagesDir))

script/tool/lib/src/native_test_command.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ class NativeTestCommand extends PackageLoopingCommand {
7373
@override
7474
final String name = 'native-test';
7575

76+
@override
77+
List<String> get aliases => <String>['test-native'];
78+
7679
@override
7780
final String description = '''
7881
Runs native unit tests and native integration tests.

0 commit comments

Comments
 (0)