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