Null safety migration of packages/flutter_tools/bin (#110706)
* Migrate packages/flutter_tools/bin * Fix NPE * Fix test * Fix test * Fix l10n optionalParameters * Fix ChromeTab nullability * Fix another type cast error * Fix another cast error * Fix another cast error (copied from #110711) * Fix NPE * Fix another NPE * Assert that testDirectory is not null
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:flutter_tools/executable.dart' as executable;
|
||||
|
||||
void main(List<String> args) {
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:args/args.dart';
|
||||
import 'package:flutter_tools/src/asset.dart' hide defaultManifestPath;
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
@@ -63,10 +61,10 @@ Future<void> run(List<String> args) async {
|
||||
Cache.flutterRoot = globals.platform.environment['FLUTTER_ROOT'];
|
||||
|
||||
final String assetDir = argResults[_kOptionAsset] as String;
|
||||
final AssetBundle assets = await buildAssets(
|
||||
manifestPath: argResults[_kOptionManifest] as String ?? defaultManifestPath,
|
||||
final AssetBundle? assets = await buildAssets(
|
||||
manifestPath: argResults[_kOptionManifest] as String? ?? defaultManifestPath,
|
||||
assetDirPath: assetDir,
|
||||
packagesPath: argResults[_kOptionPackages] as String,
|
||||
packagesPath: argResults[_kOptionPackages] as String?,
|
||||
targetPlatform: TargetPlatform.fuchsia_arm64 // This is not arch specific.
|
||||
);
|
||||
|
||||
@@ -84,8 +82,9 @@ Future<void> run(List<String> args) async {
|
||||
final String outputMan = argResults[_kOptionAssetManifestOut] as String;
|
||||
await writeFuchsiaManifest(assets, argResults[_kOptionAsset] as String, outputMan, argResults[_kOptionComponentName] as String);
|
||||
|
||||
if (argResults.options.contains(_kOptionDepfile)) {
|
||||
await writeDepfile(assets, outputMan, argResults[_kOptionDepfile] as String);
|
||||
final String? depfilePath = argResults[_kOptionDepfile] as String?;
|
||||
if (depfilePath != null) {
|
||||
await writeDepfile(assets, outputMan, depfilePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:convert' show json;
|
||||
import 'dart:math' as math;
|
||||
|
||||
@@ -57,7 +55,6 @@ Future<void> run(List<String> args) async {
|
||||
..addOption(_kOptionTests, help: 'Path to json file that maps Dart test files to precompiled dill files')
|
||||
..addOption(_kOptionCoverageDirectory, help: 'The path to the directory that will have coverage collected')
|
||||
..addFlag(_kOptionCoverage,
|
||||
defaultsTo: false,
|
||||
negatable: false,
|
||||
help: 'Whether to collect coverage information.',
|
||||
)
|
||||
@@ -84,7 +81,7 @@ Future<void> run(List<String> args) async {
|
||||
if (!globals.fs.isDirectorySync(sdkRootSrc.path)) {
|
||||
throwToolExit('Cannot find SDK files at ${sdkRootSrc.path}');
|
||||
}
|
||||
Directory coverageDirectory;
|
||||
Directory? coverageDirectory;
|
||||
final String coverageDirectoryPath = argResults[_kOptionCoverageDirectory] as String;
|
||||
if (coverageDirectoryPath != null) {
|
||||
if (!globals.fs.isDirectorySync(coverageDirectoryPath)) {
|
||||
@@ -95,13 +92,14 @@ Future<void> run(List<String> args) async {
|
||||
|
||||
// Put the tester shell where runTests expects it.
|
||||
// TODO(garymm): Switch to a Fuchsia-specific Artifacts impl.
|
||||
final Artifacts artifacts = globals.artifacts!;
|
||||
final Link testerDestLink =
|
||||
globals.fs.link(globals.artifacts.getArtifactPath(Artifact.flutterTester));
|
||||
globals.fs.link(artifacts.getArtifactPath(Artifact.flutterTester));
|
||||
testerDestLink.parent.createSync(recursive: true);
|
||||
testerDestLink.createSync(globals.fs.path.absolute(shellPath));
|
||||
|
||||
final Directory sdkRootDest =
|
||||
globals.fs.directory(globals.artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath));
|
||||
globals.fs.directory(artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath));
|
||||
sdkRootDest.createSync(recursive: true);
|
||||
for (final FileSystemEntity artifact in sdkRootSrc.listSync()) {
|
||||
globals.fs.link(sdkRootDest.childFile(artifact.basename).path).createSync(artifact.path);
|
||||
@@ -109,12 +107,12 @@ Future<void> run(List<String> args) async {
|
||||
// TODO(tvolkert): Remove once flutter_tester no longer looks for this.
|
||||
globals.fs.link(sdkRootDest.childFile('platform.dill').path).createSync('platform_strong.dill');
|
||||
|
||||
Directory testDirectory;
|
||||
CoverageCollector collector;
|
||||
Directory? testDirectory;
|
||||
CoverageCollector? collector;
|
||||
if (argResults['coverage'] as bool) {
|
||||
// If we have a specified coverage directory then accept all libraries by
|
||||
// setting libraryNames to null.
|
||||
final Set<String> libraryNames = coverageDirectory != null ? null :
|
||||
final Set<String>? libraryNames = coverageDirectory != null ? null :
|
||||
<String>{FlutterProject.current().manifest.appName};
|
||||
final String packagesPath = globals.fs.path.normalize(globals.fs.path.absolute(argResults[_kOptionPackages] as String));
|
||||
collector = CoverageCollector(
|
||||
@@ -162,7 +160,7 @@ Future<void> run(List<String> args) async {
|
||||
// package (i.e. contains lib/ and test/ sub-dirs). In some cases,
|
||||
// test files may appear to be in the root directory.
|
||||
if (coverageDirectory == null) {
|
||||
globals.fs.currentDirectory = testDirectory.parent;
|
||||
globals.fs.currentDirectory = testDirectory!.parent;
|
||||
} else {
|
||||
globals.fs.currentDirectory = testDirectory;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user