Null safety migration of packages/flutter_tools/test/commands.shard/permeable (#110710)
* Migrate packages/flutter_tools/test/commands.shard/permeable * Fix upgrade_test * Chris's comments
This commit is contained in:
parent
96b72232bd
commit
089d955156
@ -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/command_runner.dart';
|
||||
import 'package:flutter_tools/src/android/android_builder.dart';
|
||||
import 'package:flutter_tools/src/android/android_sdk.dart';
|
||||
@ -16,7 +14,6 @@ import 'package:flutter_tools/src/features.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:test/fake.dart';
|
||||
|
||||
import '../../src/android_common.dart';
|
||||
@ -29,7 +26,7 @@ import '../../src/test_flutter_command_runner.dart';
|
||||
void main() {
|
||||
Cache.disableLocking();
|
||||
|
||||
Future<BuildAarCommand> runCommandIn(String target, { List<String> arguments }) async {
|
||||
Future<BuildAarCommand> runCommandIn(String target, { List<String>? arguments }) async {
|
||||
final BuildAarCommand command = BuildAarCommand(verboseHelp: false);
|
||||
final CommandRunner<void> runner = createTestCommandRunner(command);
|
||||
await runner.run(<String>[
|
||||
@ -42,8 +39,8 @@ void main() {
|
||||
}
|
||||
|
||||
group('Usage', () {
|
||||
Directory tempDir;
|
||||
TestUsage testUsage;
|
||||
late Directory tempDir;
|
||||
late TestUsage testUsage;
|
||||
|
||||
setUp(() {
|
||||
testUsage = TestUsage();
|
||||
@ -110,8 +107,8 @@ void main() {
|
||||
});
|
||||
|
||||
group('flag parsing', () {
|
||||
Directory tempDir;
|
||||
FakeAndroidBuilder fakeAndroidBuilder;
|
||||
late Directory tempDir;
|
||||
late FakeAndroidBuilder fakeAndroidBuilder;
|
||||
|
||||
setUp(() {
|
||||
fakeAndroidBuilder = FakeAndroidBuilder();
|
||||
@ -193,11 +190,11 @@ void main() {
|
||||
});
|
||||
|
||||
group('Gradle', () {
|
||||
Directory tempDir;
|
||||
AndroidSdk mockAndroidSdk;
|
||||
String gradlew;
|
||||
FakeProcessManager processManager;
|
||||
String flutterRoot;
|
||||
late Directory tempDir;
|
||||
late AndroidSdk mockAndroidSdk;
|
||||
late String gradlew;
|
||||
late FakeProcessManager processManager;
|
||||
late String flutterRoot;
|
||||
|
||||
setUp(() {
|
||||
tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
|
||||
@ -277,7 +274,7 @@ void main() {
|
||||
|
||||
Future<BuildAarCommand> runBuildAarCommand(
|
||||
String target, {
|
||||
List<String> arguments,
|
||||
List<String>? arguments,
|
||||
}) async {
|
||||
final BuildAarCommand command = BuildAarCommand(verboseHelp: false);
|
||||
final CommandRunner<void> runner = createTestCommandRunner(command);
|
||||
@ -291,19 +288,19 @@ Future<BuildAarCommand> runBuildAarCommand(
|
||||
}
|
||||
|
||||
class FakeAndroidBuilder extends Fake implements AndroidBuilder {
|
||||
FlutterProject project;
|
||||
Set<AndroidBuildInfo> androidBuildInfo;
|
||||
String target;
|
||||
String outputDirectoryPath;
|
||||
String buildNumber;
|
||||
late FlutterProject project;
|
||||
late Set<AndroidBuildInfo> androidBuildInfo;
|
||||
late String target;
|
||||
String? outputDirectoryPath;
|
||||
late String buildNumber;
|
||||
|
||||
@override
|
||||
Future<void> buildAar({
|
||||
@required FlutterProject project,
|
||||
@required Set<AndroidBuildInfo> androidBuildInfo,
|
||||
@required String target,
|
||||
@required String outputDirectoryPath,
|
||||
@required String buildNumber,
|
||||
required FlutterProject project,
|
||||
required Set<AndroidBuildInfo> androidBuildInfo,
|
||||
required String target,
|
||||
String? outputDirectoryPath,
|
||||
required String buildNumber,
|
||||
}) async {
|
||||
this.project = project;
|
||||
this.androidBuildInfo = androidBuildInfo;
|
||||
|
@ -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/command_runner.dart';
|
||||
import 'package:flutter_tools/src/android/android_builder.dart';
|
||||
import 'package:flutter_tools/src/android/android_sdk.dart';
|
||||
@ -26,8 +24,8 @@ void main() {
|
||||
Cache.disableLocking();
|
||||
|
||||
group('Usage', () {
|
||||
Directory tempDir;
|
||||
TestUsage testUsage;
|
||||
late Directory tempDir;
|
||||
late TestUsage testUsage;
|
||||
|
||||
setUp(() {
|
||||
testUsage = TestUsage();
|
||||
@ -108,11 +106,11 @@ void main() {
|
||||
});
|
||||
|
||||
group('Gradle', () {
|
||||
Directory tempDir;
|
||||
FakeProcessManager processManager;
|
||||
String gradlew;
|
||||
AndroidSdk mockAndroidSdk;
|
||||
TestUsage testUsage;
|
||||
late Directory tempDir;
|
||||
late FakeProcessManager processManager;
|
||||
late String gradlew;
|
||||
late AndroidSdk mockAndroidSdk;
|
||||
late TestUsage testUsage;
|
||||
|
||||
setUp(() {
|
||||
testUsage = TestUsage();
|
||||
@ -429,7 +427,7 @@ void main() {
|
||||
|
||||
Future<BuildApkCommand> runBuildApkCommand(
|
||||
String target, {
|
||||
List<String> arguments,
|
||||
List<String>? arguments,
|
||||
}) async {
|
||||
final BuildApkCommand command = BuildApkCommand();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(command);
|
||||
|
@ -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/command_runner.dart';
|
||||
import 'package:flutter_tools/src/android/android_builder.dart';
|
||||
import 'package:flutter_tools/src/android/android_sdk.dart';
|
||||
@ -24,8 +22,8 @@ void main() {
|
||||
Cache.disableLocking();
|
||||
|
||||
group('Usage', () {
|
||||
Directory tempDir;
|
||||
TestUsage testUsage;
|
||||
late Directory tempDir;
|
||||
late TestUsage testUsage;
|
||||
|
||||
setUp(() {
|
||||
tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
|
||||
@ -87,10 +85,10 @@ void main() {
|
||||
});
|
||||
|
||||
group('Gradle', () {
|
||||
Directory tempDir;
|
||||
FakeProcessManager processManager;
|
||||
FakeAndroidSdk fakeAndroidSdk;
|
||||
TestUsage testUsage;
|
||||
late Directory tempDir;
|
||||
late FakeProcessManager processManager;
|
||||
late FakeAndroidSdk fakeAndroidSdk;
|
||||
late TestUsage testUsage;
|
||||
|
||||
setUp(() {
|
||||
testUsage = TestUsage();
|
||||
@ -213,7 +211,7 @@ void main() {
|
||||
|
||||
Future<BuildAppBundleCommand> runBuildAppBundleCommand(
|
||||
String target, {
|
||||
List<String> arguments,
|
||||
List<String>? arguments,
|
||||
}) async {
|
||||
final BuildAppBundleCommand command = BuildAppBundleCommand();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(command);
|
||||
|
@ -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/command_runner.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
@ -27,8 +25,8 @@ import '../../src/test_flutter_command_runner.dart';
|
||||
|
||||
void main() {
|
||||
Cache.disableLocking();
|
||||
Directory tempDir;
|
||||
FakeBundleBuilder fakeBundleBuilder;
|
||||
late Directory tempDir;
|
||||
late FakeBundleBuilder fakeBundleBuilder;
|
||||
final FileSystemStyle fileSystemStyle = globals.fs.path.separator == '/' ?
|
||||
FileSystemStyle.posix : FileSystemStyle.windows;
|
||||
|
||||
@ -46,7 +44,7 @@ void main() {
|
||||
return MemoryFileSystem.test(style: fileSystemStyle);
|
||||
}
|
||||
|
||||
Future<BuildBundleCommand> runCommandIn(String projectPath, { List<String> arguments }) async {
|
||||
Future<BuildBundleCommand> runCommandIn(String projectPath, { List<String>? arguments }) async {
|
||||
final BuildBundleCommand command = BuildBundleCommand(bundleBuilder: fakeBundleBuilder);
|
||||
final CommandRunner<void> runner = createTestCommandRunner(command);
|
||||
await runner.run(<String>[
|
||||
@ -470,14 +468,14 @@ void main() {
|
||||
class FakeBundleBuilder extends Fake implements BundleBuilder {
|
||||
@override
|
||||
Future<void> build({
|
||||
@required TargetPlatform platform,
|
||||
@required BuildInfo buildInfo,
|
||||
FlutterProject project,
|
||||
String mainPath,
|
||||
required TargetPlatform platform,
|
||||
required BuildInfo buildInfo,
|
||||
FlutterProject? project,
|
||||
String? mainPath,
|
||||
String manifestPath = defaultManifestPath,
|
||||
String applicationKernelFilePath,
|
||||
String depfilePath,
|
||||
String assetDirPath,
|
||||
@visibleForTesting BuildSystem buildSystem,
|
||||
String? applicationKernelFilePath,
|
||||
String? depfilePath,
|
||||
String? assetDirPath,
|
||||
@visibleForTesting BuildSystem? buildSystem,
|
||||
}) async {}
|
||||
}
|
||||
|
@ -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:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io' as io;
|
||||
@ -60,12 +58,12 @@ const String samplesIndexJson = '''
|
||||
]''';
|
||||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
Directory projectDir;
|
||||
FakeFlutterVersion fakeFlutterVersion;
|
||||
LoggingProcessManager loggingProcessManager;
|
||||
FakeProcessManager fakeProcessManager;
|
||||
BufferLogger logger;
|
||||
late Directory tempDir;
|
||||
late Directory projectDir;
|
||||
late FakeFlutterVersion fakeFlutterVersion;
|
||||
late LoggingProcessManager loggingProcessManager;
|
||||
late FakeProcessManager fakeProcessManager;
|
||||
late BufferLogger logger;
|
||||
|
||||
setUpAll(() async {
|
||||
Cache.disableLocking();
|
||||
@ -569,7 +567,7 @@ void main() {
|
||||
// Expect the dependency on flutter_web_plugins exists
|
||||
expect(pubspec.dependencies, contains('flutter_web_plugins'));
|
||||
// The platform is correctly registered
|
||||
final YamlMap web = ((pubspec.flutter['plugin'] as YamlMap)['platforms'] as YamlMap)['web'] as YamlMap;
|
||||
final YamlMap web = ((pubspec.flutter!['plugin'] as YamlMap)['platforms'] as YamlMap)['web'] as YamlMap;
|
||||
expect(web['pluginClass'], 'FlutterProjectWeb');
|
||||
expect(web['fileName'], 'flutter_project_web.dart');
|
||||
expect(logger.errorText, isNot(contains(_kNoPlatformsMessage)));
|
||||
@ -599,7 +597,7 @@ void main() {
|
||||
final String pluginName = projectDir.basename;
|
||||
expect(pubspec.dependencies, contains(pluginName));
|
||||
expect(pubspec.dependencies[pluginName] is PathDependency, isTrue);
|
||||
final PathDependency pathDependency = pubspec.dependencies[pluginName] as PathDependency;
|
||||
final PathDependency pathDependency = pubspec.dependencies[pluginName]! as PathDependency;
|
||||
expect(pathDependency.path, '../');
|
||||
}, overrides: <Type, Generator>{
|
||||
Pub: () => Pub(
|
||||
@ -1158,7 +1156,7 @@ void main() {
|
||||
final String original = file.readAsStringSync();
|
||||
|
||||
final Process process = await Process.start(
|
||||
globals.artifacts.getHostArtifact(HostArtifact.engineDartBinary).path,
|
||||
globals.artifacts!.getHostArtifact(HostArtifact.engineDartBinary).path,
|
||||
<String>['format', '--output=show', file.path],
|
||||
workingDirectory: projectDir.path,
|
||||
);
|
||||
@ -1255,7 +1253,7 @@ void main() {
|
||||
final String original = file.readAsStringSync();
|
||||
|
||||
final Process process = await Process.start(
|
||||
globals.artifacts.getHostArtifact(HostArtifact.engineDartBinary).path,
|
||||
globals.artifacts!.getHostArtifact(HostArtifact.engineDartBinary).path,
|
||||
<String>['format', '--output=show', file.path],
|
||||
workingDirectory: projectDir.path,
|
||||
);
|
||||
@ -2548,9 +2546,9 @@ void main() {
|
||||
await runner.run(<String>['create', '--no-pub', '--template=plugin', projectDir.path]);
|
||||
final String rawPubspec = await projectDir.childFile('pubspec.yaml').readAsString();
|
||||
final Pubspec pubspec = Pubspec.parse(rawPubspec);
|
||||
final Map<String, VersionConstraint> env = pubspec.environment;
|
||||
expect(env['flutter'].allows(Version(2, 5, 0)), true);
|
||||
expect(env['flutter'].allows(Version(2, 4, 9)), false);
|
||||
final Map<String, VersionConstraint?> env = pubspec.environment!;
|
||||
expect(env['flutter']!.allows(Version(2, 5, 0)), true);
|
||||
expect(env['flutter']!.allows(Version(2, 4, 9)), false);
|
||||
});
|
||||
|
||||
testUsingContext('default app uses flutter default versions', () async {
|
||||
@ -3084,7 +3082,7 @@ Future<void> _analyzeProject(String workingDir, { List<String> expectedFailures
|
||||
];
|
||||
|
||||
final ProcessResult exec = await Process.run(
|
||||
globals.artifacts.getHostArtifact(HostArtifact.engineDartBinary).path,
|
||||
globals.artifacts!.getHostArtifact(HostArtifact.engineDartBinary).path,
|
||||
args,
|
||||
workingDirectory: workingDir,
|
||||
);
|
||||
@ -3124,7 +3122,7 @@ Future<void> _getPackages(Directory workingDir) async {
|
||||
// While flutter test does get packages, it doesn't write version
|
||||
// files anymore.
|
||||
await Process.run(
|
||||
globals.artifacts.getHostArtifact(HostArtifact.engineDartBinary).path,
|
||||
globals.artifacts!.getHostArtifact(HostArtifact.engineDartBinary).path,
|
||||
<String>[
|
||||
flutterToolsSnapshotPath,
|
||||
'packages',
|
||||
@ -3134,7 +3132,7 @@ Future<void> _getPackages(Directory workingDir) async {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _runFlutterTest(Directory workingDir, { String target }) async {
|
||||
Future<void> _runFlutterTest(Directory workingDir, { String? target }) async {
|
||||
final String flutterToolsSnapshotPath = globals.fs.path.absolute(globals.fs.path.join(
|
||||
'..',
|
||||
'..',
|
||||
@ -3153,7 +3151,7 @@ Future<void> _runFlutterTest(Directory workingDir, { String target }) async {
|
||||
];
|
||||
|
||||
final ProcessResult exec = await Process.run(
|
||||
globals.artifacts.getHostArtifact(HostArtifact.engineDartBinary).path,
|
||||
globals.artifacts!.getHostArtifact(HostArtifact.engineDartBinary).path,
|
||||
args,
|
||||
workingDirectory: workingDir.path,
|
||||
);
|
||||
@ -3171,8 +3169,8 @@ class LoggingProcessManager extends LocalProcessManager {
|
||||
@override
|
||||
Future<Process> start(
|
||||
List<Object> command, {
|
||||
String workingDirectory,
|
||||
Map<String, String> environment,
|
||||
String? workingDirectory,
|
||||
Map<String, String>? environment,
|
||||
bool includeParentEnvironment = true,
|
||||
bool runInShell = false,
|
||||
ProcessStartMode mode = ProcessStartMode.normal,
|
||||
@ -3193,14 +3191,14 @@ class LoggingProcessManager extends LocalProcessManager {
|
||||
}
|
||||
}
|
||||
|
||||
String _getStringValueFromPlist({File plistFile, String key}) {
|
||||
String _getStringValueFromPlist({required File plistFile, String? key}) {
|
||||
final List<String> plist = plistFile.readAsLinesSync().map((String line) => line.trim()).toList();
|
||||
final int keyIndex = plist.indexOf('<key>$key</key>');
|
||||
assert(keyIndex > 0);
|
||||
return plist[keyIndex+1].replaceAll('<string>', '').replaceAll('</string>', '');
|
||||
}
|
||||
|
||||
bool _getBooleanValueFromPlist({File plistFile, String key}) {
|
||||
bool _getBooleanValueFromPlist({required File plistFile, String? key}) {
|
||||
final List<String> plist = plistFile.readAsLinesSync().map((String line) => line.trim()).toList();
|
||||
final int keyIndex = plist.indexOf('<key>$key</key>');
|
||||
assert(keyIndex > 0);
|
||||
|
@ -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';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
@ -20,8 +18,8 @@ import '../../src/fakes.dart';
|
||||
import '../../src/test_flutter_command_runner.dart';
|
||||
|
||||
void main() {
|
||||
FakeDeviceManager deviceManager;
|
||||
BufferLogger logger;
|
||||
late FakeDeviceManager deviceManager;
|
||||
late BufferLogger logger;
|
||||
|
||||
setUpAll(() {
|
||||
Cache.disableLocking();
|
||||
@ -87,10 +85,10 @@ class FakeDeviceManager extends Fake implements DeviceManager {
|
||||
List<Device> devices = <Device>[];
|
||||
|
||||
@override
|
||||
String specifiedDeviceId;
|
||||
String? specifiedDeviceId;
|
||||
|
||||
@override
|
||||
Future<List<Device>> refreshAllConnectedDevices({Duration timeout}) async {
|
||||
Future<List<Device>> refreshAllConnectedDevices({Duration? timeout}) async {
|
||||
return devices;
|
||||
}
|
||||
}
|
||||
|
@ -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/command_runner.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
@ -16,7 +14,7 @@ import '../../src/test_flutter_command_runner.dart';
|
||||
|
||||
void main() {
|
||||
group('format', () {
|
||||
Directory tempDir;
|
||||
late Directory tempDir;
|
||||
|
||||
setUp(() {
|
||||
Cache.disableLocking();
|
||||
|
@ -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/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
@ -18,12 +16,12 @@ import '../../src/context.dart';
|
||||
import '../../src/test_flutter_command_runner.dart';
|
||||
|
||||
void main() {
|
||||
FileSystem fileSystem;
|
||||
BufferLogger logger;
|
||||
Platform platform;
|
||||
Terminal terminal;
|
||||
ProcessManager processManager;
|
||||
Directory appDir;
|
||||
late FileSystem fileSystem;
|
||||
late BufferLogger logger;
|
||||
late Platform platform;
|
||||
late Terminal terminal;
|
||||
late ProcessManager processManager;
|
||||
late Directory appDir;
|
||||
|
||||
setUp(() {
|
||||
fileSystem = globals.localFileSystem;
|
||||
|
@ -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/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
@ -18,12 +16,12 @@ import '../../src/context.dart';
|
||||
import '../../src/test_flutter_command_runner.dart';
|
||||
|
||||
void main() {
|
||||
FileSystem fileSystem;
|
||||
BufferLogger logger;
|
||||
Platform platform;
|
||||
Terminal terminal;
|
||||
ProcessManager processManager;
|
||||
Directory appDir;
|
||||
late FileSystem fileSystem;
|
||||
late BufferLogger logger;
|
||||
late Platform platform;
|
||||
late Terminal terminal;
|
||||
late ProcessManager processManager;
|
||||
late Directory appDir;
|
||||
|
||||
setUp(() {
|
||||
fileSystem = globals.localFileSystem;
|
||||
|
@ -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/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
@ -18,12 +16,12 @@ import '../../src/context.dart';
|
||||
import '../../src/test_flutter_command_runner.dart';
|
||||
|
||||
void main() {
|
||||
FileSystem fileSystem;
|
||||
BufferLogger logger;
|
||||
Platform platform;
|
||||
Terminal terminal;
|
||||
ProcessManager processManager;
|
||||
Directory appDir;
|
||||
late FileSystem fileSystem;
|
||||
late BufferLogger logger;
|
||||
late Platform platform;
|
||||
late Terminal terminal;
|
||||
late ProcessManager processManager;
|
||||
late Directory appDir;
|
||||
|
||||
setUp(() {
|
||||
fileSystem = globals.localFileSystem;
|
||||
|
@ -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
|
||||
|
||||
// TODO(gspencergoog): Remove this tag once this test's state leaks/test
|
||||
// dependencies have been fixed.
|
||||
// https://github.com/flutter/flutter/issues/85160
|
||||
@ -34,7 +32,7 @@ import '../../src/test_flutter_command_runner.dart';
|
||||
void main() {
|
||||
Cache.disableLocking();
|
||||
group('packages get/upgrade', () {
|
||||
Directory tempDir;
|
||||
late Directory tempDir;
|
||||
|
||||
setUp(() {
|
||||
tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
|
||||
@ -44,7 +42,7 @@ void main() {
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
|
||||
Future<String> createProjectWithPlugin(String plugin, { List<String> arguments }) async {
|
||||
Future<String> createProjectWithPlugin(String plugin, { List<String>? arguments }) async {
|
||||
final String projectPath = await createProject(tempDir, arguments: arguments);
|
||||
final File pubspec = globals.fs.file(globals.fs.path.join(projectPath, 'pubspec.yaml'));
|
||||
String content = await pubspec.readAsString();
|
||||
@ -60,7 +58,7 @@ void main() {
|
||||
return projectPath;
|
||||
}
|
||||
|
||||
Future<PackagesCommand> runCommandIn(String projectPath, String verb, { List<String> args }) async {
|
||||
Future<PackagesCommand> runCommandIn(String projectPath, String verb, { List<String>? args }) async {
|
||||
final PackagesCommand command = PackagesCommand();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(command);
|
||||
await runner.run(<String>[
|
||||
@ -243,7 +241,7 @@ void main() {
|
||||
removeGeneratedFiles(projectPath);
|
||||
|
||||
final PackagesCommand command = await runCommandIn(projectPath, 'get');
|
||||
final PackagesGetCommand getCommand = command.subcommands['get'] as PackagesGetCommand;
|
||||
final PackagesGetCommand getCommand = command.subcommands['get']! as PackagesGetCommand;
|
||||
|
||||
expect((await getCommand.usageValues).commandPackagesNumberPlugins, 0);
|
||||
}, overrides: <Type, Generator>{
|
||||
@ -265,7 +263,7 @@ void main() {
|
||||
final String exampleProjectPath = globals.fs.path.join(projectPath, 'example');
|
||||
|
||||
final PackagesCommand command = await runCommandIn(exampleProjectPath, 'get');
|
||||
final PackagesGetCommand getCommand = command.subcommands['get'] as PackagesGetCommand;
|
||||
final PackagesGetCommand getCommand = command.subcommands['get']! as PackagesGetCommand;
|
||||
|
||||
expect((await getCommand.usageValues).commandPackagesNumberPlugins, 1);
|
||||
}, overrides: <Type, Generator>{
|
||||
@ -285,7 +283,7 @@ void main() {
|
||||
removeGeneratedFiles(projectPath);
|
||||
|
||||
final PackagesCommand command = await runCommandIn(projectPath, 'get');
|
||||
final PackagesGetCommand getCommand = command.subcommands['get'] as PackagesGetCommand;
|
||||
final PackagesGetCommand getCommand = command.subcommands['get']! as PackagesGetCommand;
|
||||
|
||||
expect((await getCommand.usageValues).commandPackagesProjectModule, false);
|
||||
}, overrides: <Type, Generator>{
|
||||
@ -305,7 +303,7 @@ void main() {
|
||||
removeGeneratedFiles(projectPath);
|
||||
|
||||
final PackagesCommand command = await runCommandIn(projectPath, 'get');
|
||||
final PackagesGetCommand getCommand = command.subcommands['get'] as PackagesGetCommand;
|
||||
final PackagesGetCommand getCommand = command.subcommands['get']! as PackagesGetCommand;
|
||||
|
||||
expect((await getCommand.usageValues).commandPackagesProjectModule, true);
|
||||
}, overrides: <Type, Generator>{
|
||||
@ -334,7 +332,7 @@ void main() {
|
||||
androidManifest.writeAsStringSync(updatedAndroidManifestString);
|
||||
|
||||
final PackagesCommand command = await runCommandIn(projectPath, 'get');
|
||||
final PackagesGetCommand getCommand = command.subcommands['get'] as PackagesGetCommand;
|
||||
final PackagesGetCommand getCommand = command.subcommands['get']! as PackagesGetCommand;
|
||||
|
||||
expect((await getCommand.usageValues).commandPackagesAndroidEmbeddingVersion, 'v1');
|
||||
}, overrides: <Type, Generator>{
|
||||
@ -354,7 +352,7 @@ void main() {
|
||||
removeGeneratedFiles(projectPath);
|
||||
|
||||
final PackagesCommand command = await runCommandIn(projectPath, 'get');
|
||||
final PackagesGetCommand getCommand = command.subcommands['get'] as PackagesGetCommand;
|
||||
final PackagesGetCommand getCommand = command.subcommands['get']! as PackagesGetCommand;
|
||||
|
||||
expect((await getCommand.usageValues).commandPackagesAndroidEmbeddingVersion, 'v2');
|
||||
}, overrides: <Type, Generator>{
|
||||
@ -439,8 +437,8 @@ void main() {
|
||||
});
|
||||
|
||||
group('packages test/pub', () {
|
||||
FakeProcessManager processManager;
|
||||
FakeStdio mockStdio;
|
||||
late FakeProcessManager processManager;
|
||||
late FakeStdio mockStdio;
|
||||
|
||||
setUp(() {
|
||||
processManager = FakeProcessManager.empty();
|
||||
|
@ -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:io';
|
||||
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
|
@ -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/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
@ -23,10 +21,10 @@ import '../../src/test_flutter_command_runner.dart';
|
||||
|
||||
void main() {
|
||||
group('UpgradeCommandRunner', () {
|
||||
FakeUpgradeCommandRunner fakeCommandRunner;
|
||||
UpgradeCommandRunner realCommandRunner;
|
||||
FakeProcessManager processManager;
|
||||
FakePlatform fakePlatform;
|
||||
late FakeUpgradeCommandRunner fakeCommandRunner;
|
||||
late UpgradeCommandRunner realCommandRunner;
|
||||
late FakeProcessManager processManager;
|
||||
late FakePlatform fakePlatform;
|
||||
const GitTagVersion gitTagVersion = GitTagVersion(
|
||||
x: 1,
|
||||
y: 2,
|
||||
@ -349,7 +347,7 @@ void main() {
|
||||
});
|
||||
|
||||
testUsingContext('does not throw on unknown tag, official branch, force', () async {
|
||||
fakeCommandRunner.remoteVersion = FakeFlutterVersion(frameworkRevision: null);
|
||||
fakeCommandRunner.remoteVersion = FakeFlutterVersion(frameworkRevision: '1234');
|
||||
final FakeFlutterVersion flutterVersion = FakeFlutterVersion(channel: 'beta');
|
||||
|
||||
final Future<FlutterCommandResult> result = fakeCommandRunner.runCommand(
|
||||
@ -369,7 +367,7 @@ void main() {
|
||||
|
||||
testUsingContext('does not throw tool exit with uncommitted changes and force', () async {
|
||||
final FakeFlutterVersion flutterVersion = FakeFlutterVersion(channel: 'beta');
|
||||
fakeCommandRunner.remoteVersion = FakeFlutterVersion(frameworkRevision: null);
|
||||
fakeCommandRunner.remoteVersion = FakeFlutterVersion(frameworkRevision: '1234');
|
||||
fakeCommandRunner.willHaveUncommittedChanges = true;
|
||||
|
||||
final Future<FlutterCommandResult> result = fakeCommandRunner.runCommand(
|
||||
@ -389,7 +387,7 @@ void main() {
|
||||
|
||||
testUsingContext("Doesn't throw on known tag, beta branch, no force", () async {
|
||||
final FakeFlutterVersion flutterVersion = FakeFlutterVersion(channel: 'beta');
|
||||
fakeCommandRunner.remoteVersion = FakeFlutterVersion(frameworkRevision: null);
|
||||
fakeCommandRunner.remoteVersion = FakeFlutterVersion(frameworkRevision: '1234');
|
||||
|
||||
final Future<FlutterCommandResult> result = fakeCommandRunner.runCommand(
|
||||
force: false,
|
||||
@ -407,9 +405,9 @@ void main() {
|
||||
});
|
||||
|
||||
group('full command', () {
|
||||
FakeProcessManager fakeProcessManager;
|
||||
Directory tempDir;
|
||||
File flutterToolState;
|
||||
late FakeProcessManager fakeProcessManager;
|
||||
late Directory tempDir;
|
||||
late File flutterToolState;
|
||||
|
||||
setUp(() {
|
||||
Cache.disableLocking();
|
||||
@ -470,10 +468,10 @@ class FakeUpgradeCommandRunner extends UpgradeCommandRunner {
|
||||
bool willHaveUncommittedChanges = false;
|
||||
bool alreadyUpToDate = false;
|
||||
|
||||
FlutterVersion remoteVersion;
|
||||
late FlutterVersion remoteVersion;
|
||||
|
||||
@override
|
||||
Future<FlutterVersion> fetchLatestVersion({FlutterVersion localVersion}) async => remoteVersion;
|
||||
Future<FlutterVersion> fetchLatestVersion({FlutterVersion? localVersion}) async => remoteVersion;
|
||||
|
||||
@override
|
||||
Future<bool> hasUncommittedChanges() async => willHaveUncommittedChanges;
|
||||
|
Loading…
x
Reference in New Issue
Block a user