-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[tools] Add Xcode version to non-verbose Flutter doctor #87022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tools] Add Xcode version to non-verbose Flutter doctor #87022
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding versionInfo to ValidationResult which won't be used by any of the existing validators that report a version (and will therefore be unexpectedly null) and it looks like is only used in the unit test?, instead fix the regression introduced in #73808 and just set xcodeVersionInfo with its , parsing logic.
if (versionText != null) {
xcodeVersionInfo = versionText;
if (xcodeVersionInfo.contains(',')) {
xcodeVersionInfo = xcodeVersionInfo.substring(0, xcodeVersionInfo.indexOf(','));
}|
|
||
| import 'package:meta/meta.dart'; | ||
|
|
||
| import './base/version.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| import './base/version.dart'; | |
| import 'base/version.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now this can be removed.
| import './base/version.dart'; |
| // A short message about the status. | ||
| final String? statusInfo; | ||
| final List<ValidationMessage> messages; | ||
| final Version? versionInfo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only used in the unit test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
| final Version? versionInfo; |
| ); | ||
| final XcodeValidator validator = XcodeValidator(xcode: xcode, userMessages: UserMessages()); | ||
| final ValidationResult result = await validator.validate(); | ||
| expect('${validator.title} (version ${result.versionInfo})', 'Xcode - develop for iOS and macOS (version 12.0.1)'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're doing the string concatenation in the test and then checking it, which only verifies your test, not the real code. Instead, a test like this should check that the actual code produces the expected string. In this case, result.statusInfo. Also, the xcode validator doesn't have a concept of doctor verbosity, you're just checking that the result status info is correct.
I suspect you probably got stuck because XcodeProjectInterpreter.test doesn't set up _versionText since this is the first test that needs it. The XcodeProjectInterpreter._ constructor can set _versionText.
flutter/packages/flutter_tools/lib/src/ios/xcodeproj.dart
Lines 60 to 61 in 59f201f
| _version = version, | |
| _usage = usage; |
becomes
_version = version,
_versionText = version?.toString(),
_usage = usage; A better way to test this change would be to check result.statusInfo and result.messages on every existing test.
testWithoutContext('Emits missing status when Xcode is not installed', () async {
...
expect(result.type, ValidationType.missing);
expect(result.statusInfo, isNull);
expect(result.messages.last.type, ValidationMessageType.error);
expect(result.messages.last.message, contains('Xcode not installed'));
});
...
testWithoutContext('Succeeds when all checks pass', () async {
...
expect(result.type, ValidationType.installed);
expect(result.statusInfo, '12.0.1');
expect(result.messages.length, 2);
final ValidationMessage firstMessage = result.messages.first;
expect(firstMessage.type, ValidationMessageType.information);
expect(firstMessage.message, 'Xcode at /Library/Developer/CommandLineTools');
final ValidationMessage lastMessage = result.messages.last;
expect(lastMessage.type, ValidationMessageType.information);
expect(lastMessage.message, '1000.0.0');
});|
@TahaTesser are you still working on this? |
|
@jmagman |
| '(or visit ${_androidSdkInstallUrl(platform)} for detailed instructions).'; | ||
|
|
||
| // Messages used in XcodeValidator | ||
| String xcodeVersion(String version) => 'version $version'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unused.
| String xcodeVersion(String version) => 'version $version'; |
|
|
||
| import 'package:meta/meta.dart'; | ||
|
|
||
| import './base/version.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now this can be removed.
| import './base/version.dart'; |
| /// [ValidationResult.type] should only equal [ValidationResult.installed] | ||
| /// if no [messages] are hints or errors. | ||
| const ValidationResult(this.type, this.messages, { this.statusInfo }); | ||
| const ValidationResult(this.type, this.messages, { this.statusInfo, this.versionInfo }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this.
| const ValidationResult(this.type, this.messages, { this.statusInfo, this.versionInfo }); | |
| const ValidationResult(this.type, this.messages, { this.statusInfo }); |
| // A short message about the status. | ||
| final String? statusInfo; | ||
| final List<ValidationMessage> messages; | ||
| final Version? versionInfo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
| final Version? versionInfo; |
| } | ||
|
|
||
| return ValidationResult(xcodeStatus, messages, statusInfo: xcodeVersionInfo); | ||
| return ValidationResult(xcodeStatus, messages, statusInfo: xcodeVersionInfo, versionInfo: _xcode.currentVersion); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
| return ValidationResult(xcodeStatus, messages, statusInfo: xcodeVersionInfo, versionInfo: _xcode.currentVersion); | |
| return ValidationResult(xcodeStatus, messages, statusInfo: xcodeVersionInfo); |
| expect(result.messages.last.message, contains('Flutter requires a minimum Xcode version of 12.0.1')); | ||
| }); | ||
|
|
||
| testWithoutContext('Check for Xcode version in non-verbose flutter doctor', () async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the xcode validator doesn't have a concept of doctor verbosity, you're just checking that the result status info is correct.
See my comment in #87022 (comment), this test is the same case as Succeeds when all checks pass so it doesn't add any test coverage. So you can remove it, you're covered by the new statusInfo expectations.
If you want you can add the ValidationMessage test expectations I already wrote in that comment, but that's optional.
|
@jmagman
messages length is only 1, so I have updated the test for the first message only Thank you so much! |
jmagman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @TahaTesser!
| ); | ||
| final XcodeValidator validator = XcodeValidator(xcode: xcode, userMessages: UserMessages()); | ||
| final ValidationResult result = await validator.validate(); | ||
| expect(result.type, ValidationType.installed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #86902
Before
After
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.