Migrate the migration runner script in server
Change-Id: Ie4fc8e19a360ff0d201b0f91f2de9cb093566ab1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195960
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analysis_server/tool/migration_runner.dart b/pkg/analysis_server/tool/migration_runner.dart
index 355040f..ec9b6a2 100644
--- a/pkg/analysis_server/tool/migration_runner.dart
+++ b/pkg/analysis_server/tool/migration_runner.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
/// This executable provides the ability to run the migration tool in process
/// on a single package. It should be invoked with two command-line arguments:
/// a path to a configuration file and the name of a package to migrate.
@@ -54,18 +52,14 @@
migrationTest.setUp();
print('Migrating');
await migrationTest.run(packageRoot, port);
- if (port == null) {
- print('Done');
- io.exit(0);
- } else {
- print('Done. Please point your browser to localhost:$port/\$filePath');
- }
+ migrationTest.tearDown();
+ print('Done. Please point your browser to localhost:$port/\$filePath');
}
class MigrationBase {
ResourceProvider resourceProvider = PhysicalResourceProvider.INSTANCE;
- MockServerChannel serverChannel;
- AnalysisServer server;
+ late MockServerChannel serverChannel;
+ late AnalysisServer server;
AnalysisServer createAnalysisServer() {
//
@@ -114,8 +108,6 @@
void tearDown() {
server.done();
- server = null;
- serverChannel = null;
}
/// Returns a [Future] that completes when the server's analysis is complete.
@@ -157,11 +149,11 @@
Map<String, String> get externalPackages =>
((testInfoJson['external_packages'] ?? {}) as Map).cast<String, String>();
- String get outputRoot => testInfoJson['output_root'];
+ String get outputRoot => testInfoJson['output_root'] as String;
- int get port => testInfoJson['port'];
+ int get port => testInfoJson['port'] as int;
- String get sdkRoot => testInfoJson['sdk_root'];
+ String get sdkRoot => testInfoJson['sdk_root'] as String;
String packageRoot(String packageName) {
if (thirdPartyPackages.contains(packageName)) {
@@ -169,7 +161,7 @@
} else if (builtInPackages.contains(packageName)) {
return path.join(sdkRoot, 'pkg', packageName);
} else if (externalPackages.containsKey(packageName)) {
- return externalPackages[packageName];
+ return externalPackages[packageName] as String;
} else {
throw StateError('Unrecognized package $packageName');
}