Unverified Commit 0f03af01 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Migrate visual_studio_test (#80088)

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