Migrate visual_studio_test (#80088)
This commit is contained in:
@@ -47,7 +47,7 @@ class VisualStudio {
|
||||
/// The name of the Visual Studio install.
|
||||
///
|
||||
/// For instance: "Visual Studio Community 2019".
|
||||
String get displayName => _bestVisualStudioDetails[_displayNameKey] as String;
|
||||
String? get displayName => _bestVisualStudioDetails[_displayNameKey] as String?;
|
||||
|
||||
/// The user-friendly version number of the Visual Studio install.
|
||||
///
|
||||
@@ -56,16 +56,16 @@ class VisualStudio {
|
||||
if (_bestVisualStudioDetails[_catalogKey] == null) {
|
||||
return null;
|
||||
}
|
||||
return _bestVisualStudioDetails[_catalogKey][_catalogDisplayVersionKey] as String;
|
||||
return _bestVisualStudioDetails[_catalogKey][_catalogDisplayVersionKey] as String?;
|
||||
}
|
||||
|
||||
/// The directory where Visual Studio is installed.
|
||||
String get installLocation => _bestVisualStudioDetails[_installationPathKey] as String;
|
||||
String? get installLocation => _bestVisualStudioDetails[_installationPathKey] as String?;
|
||||
|
||||
/// The full version of the Visual Studio install.
|
||||
///
|
||||
/// For instance: "15.4.27004.2002".
|
||||
String get fullVersion => _bestVisualStudioDetails[_fullVersionKey] as String;
|
||||
String? get fullVersion => _bestVisualStudioDetails[_fullVersionKey] as String?;
|
||||
|
||||
// Properties that determine the status of the installation. There might be
|
||||
// Visual Studio versions that don't include them, so default to a "valid" value to
|
||||
@@ -151,7 +151,7 @@ class VisualStudio {
|
||||
/// the components necessary to build.
|
||||
String? get cmakePath {
|
||||
final Map<String, dynamic> details = _usableVisualStudioDetails;
|
||||
if (details.isEmpty) {
|
||||
if (details.isEmpty || _usableVisualStudioDetails[_installationPathKey] == null) {
|
||||
return null;
|
||||
}
|
||||
return _fileSystem.path.joinAll(<String>[
|
||||
@@ -168,7 +168,7 @@ class VisualStudio {
|
||||
}
|
||||
|
||||
/// The major version of the Visual Studio install, as an integer.
|
||||
int? get _majorVersion => fullVersion != null ? int.tryParse(fullVersion.split('.')[0]) : null;
|
||||
int? get _majorVersion => fullVersion != null ? int.tryParse(fullVersion!.split('.')[0]) : null;
|
||||
|
||||
/// The path to vswhere.exe.
|
||||
///
|
||||
|
||||
@@ -30,12 +30,12 @@ class VisualStudioValidator extends DoctorValidator {
|
||||
status = ValidationType.installed;
|
||||
|
||||
messages.add(ValidationMessage(
|
||||
_userMessages.visualStudioLocation(_visualStudio.installLocation)
|
||||
_userMessages.visualStudioLocation(_visualStudio.installLocation ?? 'unknown')
|
||||
));
|
||||
|
||||
messages.add(ValidationMessage(_userMessages.visualStudioVersion(
|
||||
_visualStudio.displayName,
|
||||
_visualStudio.fullVersion,
|
||||
_visualStudio.displayName ?? 'unknown',
|
||||
_visualStudio.fullVersion ?? 'unknown',
|
||||
)));
|
||||
|
||||
if (_visualStudio.isPrerelease) {
|
||||
|
||||
@@ -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:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
@@ -20,7 +18,7 @@ const String kPath1 = '/bar/bin/$kExecutable';
|
||||
const String kPath2 = '/another/bin/$kExecutable';
|
||||
|
||||
void main() {
|
||||
FakeProcessManager fakeProcessManager;
|
||||
late FakeProcessManager fakeProcessManager;
|
||||
|
||||
setUp(() {
|
||||
fakeProcessManager = FakeProcessManager.list(<FakeCommand>[]);
|
||||
@@ -61,7 +59,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
final OperatingSystemUtils utils = createOSUtils(FakePlatform(operatingSystem: 'linux'));
|
||||
expect(utils.which(kExecutable).path, kPath1);
|
||||
expect(utils.which(kExecutable)!.path, kPath1);
|
||||
});
|
||||
|
||||
testWithoutContext('returns all results for whichAll', () async {
|
||||
@@ -131,7 +129,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
final OperatingSystemUtils utils = createOSUtils(FakePlatform(operatingSystem: 'windows'));
|
||||
expect(utils.which(kExecutable).path, kPath1);
|
||||
expect(utils.which(kExecutable)!.path, kPath1);
|
||||
});
|
||||
|
||||
testWithoutContext('returns all results for whichAll', () 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 'package:flutter_tools/src/base/user_messages.dart';
|
||||
import 'package:flutter_tools/src/doctor_validator.dart';
|
||||
import 'package:flutter_tools/src/linux/linux_doctor.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:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart' show ProcessException;
|
||||
@@ -102,17 +100,17 @@ const List<String> _requirementsBuildTools = <String>[
|
||||
void setMockVswhereResponse(
|
||||
FileSystem fileSystem,
|
||||
FakeProcessManager processManager, [
|
||||
List<String> requiredComponents,
|
||||
List<String> additionalArguments,
|
||||
Map<String, dynamic> response,
|
||||
String responseOverride,
|
||||
int exitCode,
|
||||
Exception exception,
|
||||
List<String>? requiredComponents,
|
||||
List<String>? additionalArguments,
|
||||
Map<String, dynamic>? response,
|
||||
String? responseOverride,
|
||||
int? exitCode,
|
||||
Exception? exception,
|
||||
]) {
|
||||
fileSystem.file(vswherePath).createSync(recursive: true);
|
||||
fileSystem.file(cmakePath).createSync(recursive: true);
|
||||
final String finalResponse = responseOverride
|
||||
?? json.encode(<Map<String, dynamic>>[response]);
|
||||
?? (response != null ? json.encode(<Map<String, dynamic>>[response]) : '');
|
||||
final List<String> requirementArguments = requiredComponents == null
|
||||
? <String>[]
|
||||
: <String>['-requires', ...requiredComponents];
|
||||
@@ -127,7 +125,7 @@ void setMockVswhereResponse(
|
||||
'-utf8',
|
||||
'-latest',
|
||||
...?additionalArguments,
|
||||
...?requirementArguments,
|
||||
...requirementArguments,
|
||||
],
|
||||
stdout: finalResponse,
|
||||
exception: exception,
|
||||
@@ -138,11 +136,11 @@ void setMockVswhereResponse(
|
||||
// Sets whether or not a vswhere query with the required components will
|
||||
// return an installation.
|
||||
void setMockCompatibleVisualStudioInstallation(
|
||||
Map<String, dynamic> response,
|
||||
Map<String, dynamic>? response,
|
||||
FileSystem fileSystem,
|
||||
FakeProcessManager processManager, [
|
||||
int exitCode,
|
||||
Exception exception,
|
||||
int? exitCode,
|
||||
Exception? exception,
|
||||
]) {
|
||||
setMockVswhereResponse(
|
||||
fileSystem,
|
||||
@@ -159,11 +157,11 @@ void setMockCompatibleVisualStudioInstallation(
|
||||
// Sets whether or not a vswhere query with the required components will
|
||||
// return a pre-release installation.
|
||||
void setMockPrereleaseVisualStudioInstallation(
|
||||
Map<String, dynamic> response,
|
||||
Map<String, dynamic>? response,
|
||||
FileSystem fileSystem,
|
||||
FakeProcessManager processManager, [
|
||||
int exitCode,
|
||||
Exception exception,
|
||||
int? exitCode,
|
||||
Exception? exception,
|
||||
]) {
|
||||
setMockVswhereResponse(
|
||||
fileSystem,
|
||||
@@ -180,11 +178,11 @@ void setMockPrereleaseVisualStudioInstallation(
|
||||
// Sets whether or not a vswhere query with the required components will
|
||||
// return an Build Tools installation.
|
||||
void setMockCompatibleVisualStudioBuildToolsInstallation(
|
||||
Map<String, dynamic> response,
|
||||
Map<String, dynamic>? response,
|
||||
FileSystem fileSystem,
|
||||
FakeProcessManager processManager, [
|
||||
int exitCode,
|
||||
Exception exception,
|
||||
int? exitCode,
|
||||
Exception? exception,
|
||||
]) {
|
||||
setMockVswhereResponse(
|
||||
fileSystem,
|
||||
@@ -201,11 +199,11 @@ void setMockCompatibleVisualStudioBuildToolsInstallation(
|
||||
// Sets whether or not a vswhere query with the required components will
|
||||
// return a pre-release Build Tools installation.
|
||||
void setMockPrereleaseVisualStudioBuildToolsInstallation(
|
||||
Map<String, dynamic> response,
|
||||
Map<String, dynamic>? response,
|
||||
FileSystem fileSystem,
|
||||
FakeProcessManager processManager, [
|
||||
int exitCode,
|
||||
Exception exception,
|
||||
int? exitCode,
|
||||
Exception? exception,
|
||||
]) {
|
||||
setMockVswhereResponse(
|
||||
fileSystem,
|
||||
@@ -222,11 +220,11 @@ void setMockPrereleaseVisualStudioBuildToolsInstallation(
|
||||
// Sets whether or not a vswhere query searching for 'all' and 'prerelease'
|
||||
// versions will return an installation.
|
||||
void setMockAnyVisualStudioInstallation(
|
||||
Map<String, dynamic> response,
|
||||
Map<String, dynamic>? response,
|
||||
FileSystem fileSystem,
|
||||
FakeProcessManager processManager, [
|
||||
int exitCode,
|
||||
Exception exception,
|
||||
int? exitCode,
|
||||
Exception? exception,
|
||||
]) {
|
||||
setMockVswhereResponse(
|
||||
fileSystem,
|
||||
|
||||
Reference in New Issue
Block a user