Unverified Commit b4753c32 authored by Loïc Sharma's avatar Loïc Sharma Committed by GitHub

Improve doctor output on incomplete Visual Studio installation (#133390)

Flutter doctor warns if the user is updating Visual Studio or has paused
a Visual Studio update. The current output recommends reinstalling
Visual Studio. This is unnecessary as the user should be able to use the
Visual Studio Installer app to complete the installation:


![image](https://github.com/flutter/flutter/assets/737941/49547413-ece1-4214-a971-f512bc39419f)

This message is covered by this existing test:


https://github.com/flutter/flutter/blob/229b74d987720a0437039b6e44e13f20fb94ad51/packages/flutter_tools/test/general.shard/windows/visual_studio_validator_test.dart#L68-L81

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
parent e98d3929
...@@ -239,7 +239,8 @@ class UserMessages { ...@@ -239,7 +239,8 @@ class UserMessages {
'supported by Flutter yet.'; 'supported by Flutter yet.';
String get visualStudioNotLaunchable => String get visualStudioNotLaunchable =>
'The current Visual Studio installation is not launchable. Please reinstall Visual Studio.'; 'The current Visual Studio installation is not launchable. Please reinstall Visual Studio.';
String get visualStudioIsIncomplete => 'The current Visual Studio installation is incomplete. Please reinstall Visual Studio.'; String get visualStudioIsIncomplete => 'The current Visual Studio installation is incomplete.\n'
'Please use Visual Studio Installer to complete the installation or reinstall Visual Studio.';
String get visualStudioRebootRequired => 'Visual Studio requires a reboot of your system to complete installation.'; String get visualStudioRebootRequired => 'Visual Studio requires a reboot of your system to complete installation.';
// Messages used in LinuxDoctorValidator // Messages used in LinuxDoctorValidator
......
...@@ -60,9 +60,12 @@ void main() { ...@@ -60,9 +60,12 @@ void main() {
fakeVisualStudio.isPrerelease = true; fakeVisualStudio.isPrerelease = true;
final ValidationResult result = await validator.validate(); final ValidationResult result = await validator.validate();
final ValidationMessage expectedMessage = ValidationMessage(userMessages.visualStudioIsPrerelease); const ValidationMessage expectedMessage = ValidationMessage(
'The current Visual Studio installation is a pre-release version. '
'It may not be supported by Flutter yet.',
);
expect(result.messages.contains(expectedMessage), true); expect(result.messages, contains(expectedMessage));
}); });
testWithoutContext('Emits a partial status when Visual Studio installation is incomplete', () async { testWithoutContext('Emits a partial status when Visual Studio installation is incomplete', () async {
...@@ -74,9 +77,12 @@ void main() { ...@@ -74,9 +77,12 @@ void main() {
fakeVisualStudio.isComplete = false; fakeVisualStudio.isComplete = false;
final ValidationResult result = await validator.validate(); final ValidationResult result = await validator.validate();
final ValidationMessage expectedMessage = ValidationMessage.error(userMessages.visualStudioIsIncomplete); const ValidationMessage expectedMessage = ValidationMessage.error(
'The current Visual Studio installation is incomplete.\n'
'Please use Visual Studio Installer to complete the installation or reinstall Visual Studio.',
);
expect(result.messages.contains(expectedMessage), true); expect(result.messages, contains(expectedMessage));
expect(result.type, ValidationType.partial); expect(result.type, ValidationType.partial);
}); });
...@@ -89,9 +95,11 @@ void main() { ...@@ -89,9 +95,11 @@ void main() {
fakeVisualStudio.isRebootRequired = true; fakeVisualStudio.isRebootRequired = true;
final ValidationResult result = await validator.validate(); final ValidationResult result = await validator.validate();
final ValidationMessage expectedMessage = ValidationMessage.error(userMessages.visualStudioRebootRequired); const ValidationMessage expectedMessage = ValidationMessage.error(
'Visual Studio requires a reboot of your system to complete installation.',
);
expect(result.messages.contains(expectedMessage), true); expect(result.messages, contains(expectedMessage));
expect(result.type, ValidationType.partial); expect(result.type, ValidationType.partial);
}); });
...@@ -104,9 +112,11 @@ void main() { ...@@ -104,9 +112,11 @@ void main() {
fakeVisualStudio.isLaunchable = false; fakeVisualStudio.isLaunchable = false;
final ValidationResult result = await validator.validate(); final ValidationResult result = await validator.validate();
final ValidationMessage expectedMessage = ValidationMessage.error(userMessages.visualStudioNotLaunchable); const ValidationMessage expectedMessage = ValidationMessage.error(
'The current Visual Studio installation is not launchable. Please reinstall Visual Studio.',
);
expect(result.messages.contains(expectedMessage), true); expect(result.messages, contains(expectedMessage));
expect(result.type, ValidationType.partial); expect(result.type, ValidationType.partial);
}); });
...@@ -118,14 +128,13 @@ void main() { ...@@ -118,14 +128,13 @@ void main() {
configureMockVisualStudioAsTooOld(); configureMockVisualStudioAsTooOld();
final ValidationResult result = await validator.validate(); final ValidationResult result = await validator.validate();
final ValidationMessage expectedMessage = ValidationMessage.error( const ValidationMessage expectedMessage = ValidationMessage.error(
userMessages.visualStudioTooOld( 'Visual Studio 2019 or later is required.\n'
fakeVisualStudio.minimumVersionDescription, 'Download at https://visualstudio.microsoft.com/downloads/.\n'
fakeVisualStudio.workloadDescription, 'Please install the "Desktop development" workload, including all of its default components',
),
); );
expect(result.messages.contains(expectedMessage), true); expect(result.messages, contains(expectedMessage));
expect(result.type, ValidationType.partial); expect(result.type, ValidationType.partial);
}); });
...@@ -161,10 +170,11 @@ void main() { ...@@ -161,10 +170,11 @@ void main() {
configureMockVisualStudioAsInstalled(); configureMockVisualStudioAsInstalled();
final ValidationResult result = await validator.validate(); final ValidationResult result = await validator.validate();
final ValidationMessage expectedDisplayNameMessage = ValidationMessage( const ValidationMessage expectedDisplayNameMessage = ValidationMessage(
userMessages.visualStudioVersion(fakeVisualStudio.displayName!, fakeVisualStudio.fullVersion!)); 'Visual Studio Community 2019 version 16.2',
);
expect(result.messages.contains(expectedDisplayNameMessage), true); expect(result.messages, contains(expectedDisplayNameMessage));
expect(result.type, ValidationType.success); expect(result.type, ValidationType.success);
}); });
...@@ -176,13 +186,13 @@ void main() { ...@@ -176,13 +186,13 @@ void main() {
configureMockVisualStudioAsNotInstalled(); configureMockVisualStudioAsNotInstalled();
final ValidationResult result = await validator.validate(); final ValidationResult result = await validator.validate();
final ValidationMessage expectedMessage = ValidationMessage.error( const ValidationMessage expectedMessage = ValidationMessage.error(
userMessages.visualStudioMissing( 'Visual Studio not installed; this is necessary to develop Windows apps.\n'
fakeVisualStudio.workloadDescription, 'Download at https://visualstudio.microsoft.com/downloads/.\n'
), 'Please install the "Desktop development" workload, including all of its default components'
); );
expect(result.messages.contains(expectedMessage), true); expect(result.messages, contains(expectedMessage));
expect(result.type, ValidationType.missing); expect(result.type, ValidationType.missing);
}); });
}); });
......
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