Skip to content

Conversation

@TahaTesser
Copy link
Member

@TahaTesser TahaTesser commented Jul 26, 2021

Fixes #86902

Before

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 2.4.0-5.0.pre.180, on macOS 11.4 20F71 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web

After

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel xcode_non_verbose_version, 2.4.0-5.0.pre.183, on macOS 11.4 20F71 darwin-x64, locale
    en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (version 12.5.0)
[✓] Chrome - develop for the web

Pre-launch Checklist

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

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

@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Jul 26, 2021
@TahaTesser TahaTesser requested a review from jmagman July 26, 2021 00:17
@google-cla google-cla bot added the cla: yes label Jul 26, 2021
Copy link
Member

@jmagman jmagman left a 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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import './base/version.dart';
import 'base/version.dart';

Copy link
Member

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.

Suggested change
import './base/version.dart';

// A short message about the status.
final String? statusInfo;
final List<ValidationMessage> messages;
final Version? versionInfo;
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert.

Suggested change
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)');
Copy link
Member

@jmagman jmagman Jul 27, 2021

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.

_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');
    });

@christopherfujino christopherfujino added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Aug 12, 2021
@christopherfujino
Copy link
Contributor

@TahaTesser are you still working on this?

@TahaTesser
Copy link
Member Author

@jmagman
That was interesting, I made the changes in the code and tests, please take a look, thank you

@TahaTesser TahaTesser requested a review from jmagman August 15, 2021 18:29
@TahaTesser TahaTesser removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Aug 15, 2021
'(or visit ${_androidSdkInstallUrl(platform)} for detailed instructions).';

// Messages used in XcodeValidator
String xcodeVersion(String version) => 'version $version';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unused.

Suggested change
String xcodeVersion(String version) => 'version $version';


import 'package:meta/meta.dart';

import './base/version.dart';
Copy link
Member

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.

Suggested change
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 });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this.

Suggested change
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert.

Suggested change
final Version? versionInfo;

}

return ValidationResult(xcodeStatus, messages, statusInfo: xcodeVersionInfo);
return ValidationResult(xcodeStatus, messages, statusInfo: xcodeVersionInfo, versionInfo: _xcode.currentVersion);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert.

Suggested change
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 {
Copy link
Member

@jmagman jmagman Aug 16, 2021

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.

@TahaTesser
Copy link
Member Author

TahaTesser commented Aug 17, 2021

@jmagman
I should have reverted these changes earlier for versionInfo, my bad, now it's done, still getting used to get to this process

expect(result.messages.length, 2);

messages length is only 1, so I have updated the test for the first message only

Thank you so much!

@TahaTesser TahaTesser requested a review from jmagman August 17, 2021 19:55
Copy link
Member

@jmagman jmagman left a 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);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmagman
This was accidentally removed, restored it cb7aa1b

@fluttergithubbot fluttergithubbot merged commit 42a6b79 into flutter:master Aug 17, 2021
@TahaTesser TahaTesser deleted the xcode_non_verbose_version branch August 17, 2021 22:59
blasten pushed a commit to blasten/flutter that referenced this pull request Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Xcode version to top level of non-verbose "flutter doctor" output

4 participants