Add current version to the upgrade message of the Flutter tool#68421
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
|
@karamage can you sign the CLA? |
|
@jonahwilliams |
|
@googlebot I signed it! |
jonahwilliams
left a comment
There was a problem hiding this comment.
Seems like a nice change! If you can add a test case I'd be happy to land this
There was a problem hiding this comment.
We don't currently have any tests for what gets printed during the upgrade. The closest example is one that checks that a message is printed if nothing is upgraded:
I would see if you adapt that to add coverage for this.
There was a problem hiding this comment.
Thanks for reviewing it for you.
I agree with you about adding a test.
I'll TRY to do it.
There was a problem hiding this comment.
I'm sorry.
I tried, but I can't add the test.
I want to check the standard output, please tell me how to do it.
Reference.
expect(testLogger.statusText, contains('Flutter is already up to date'));
I ran the test and the testLogger.statusText was empty.
Please let me know.
There was a problem hiding this comment.
@karamage check if the status text you want to display is actually being displayed, like these lines in a similar test:
I think you should take this (similar)test as a reference to create your new test:
There was a problem hiding this comment.
Try this out for a bit and let me know if you make any progress. I will take a look at this PR again tomorrow and make some suggestions to get your test working correctly
There was a problem hiding this comment.
@karamage I think you need to use realCommandRunner in this case, as fakeCommandRunner.upgradeChannel doesn't do anything:
It also explains you getting Actual: '' in your test.
There was a problem hiding this comment.
Thank you. I appreciate it.
Okay, I understand.
I will try to write the test code using realCommandRunner.
There was a problem hiding this comment.
I've added the test code.
I would like you to review it.
Thank you for showing me how to test it.
The test was a success.
../../bin/dart pub run test test/commands.shard/permeable/upgrade_test.dart
00:04 +15: All tests passed!
There was a problem hiding this comment.
I would leave this message in upgradeChannel, and instead pass the upstreamRevision revision in as an argument.
There was a problem hiding this comment.
Understood. I will modify it to pass in arguments.
There was a problem hiding this comment.
For just a single identifier you don't need the{}:
| globals.printStatus('Upgrading Flutter to ${upstreamRevision} from ${flutterVersion.frameworkRevision} ($workingDirectory...)'); | |
| globals.printStatus('Upgrading Flutter to $upstreamRevision from ${flutterVersion.frameworkRevision} ($workingDirectory...)'); |
ba1ddb5 to
1b842c5
Compare
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
|
@googlebot I consent. |
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
|
@googlebot I consent. |
jonahwilliams
left a comment
There was a problem hiding this comment.
LGTM!
I'd also like @christopherfujino to double check too. Thank you @royarg02 for the help as well
There was a problem hiding this comment.
I just realized that flutterVersion.frameworkRevision is probably not what the PR was intending to use:
Take a look at these lines of code:
flutter/packages/flutter_tools/lib/src/version.dart
Lines 170 to 183 in 13896b3
My understanding is that flutterVersion.frameworkVersion should be used, but is there anyway the corresponding version of the upstreamRevision could be obtained?
There was a problem hiding this comment.
Thats a good point, it is probably printing out the commit hash right now. We should know what the tag we're checking out is
There was a problem hiding this comment.
This might be something of interest in that case:
There was a problem hiding this comment.
Thats a good point, it is probably printing out the commit hash right now. We should know what the tag we're checking out is
@jonahwilliams You're right. #68866 was merged yesterday which uses flutterVersion.frameworkRevision:
$ flutter upgrade --verify-only
A new version of Flutter is available on channel master
The latest revision: 18341efa2fb8c3570ca32e71d1a9da74e8b2cbf5
Your current version: 8b9e9680d24ffd4b3dbfa216f5f64a0490088f45
To upgrade now, run "flutter upgrade".
There was a problem hiding this comment.
@royarg02 @jonahwilliams Thanks for reviewing it for you.
I understand that using flutterVersion.frameworkRevision is a mistake.
Thank you.
I will modify it to use frameworkVersion.
There was a problem hiding this comment.
I have modified it to use frameworkVersion.
I also rewrote the test and it was successful!
Please give you a review.
There was a problem hiding this comment.
I'm taking a look now.
There was a problem hiding this comment.
Unfortunately, I don't believe this is right either. The .frameworkVersionFor() method is confusingly named. It does not return the correct version for the input revision you input, but rather the GitTagVersion that it is a method for. And on line 157, I believe that gitTagVersion is the current HEAD, or the version that the tool is currently at.
Please see my comments at @royarg02's PR for more context: https://github.com/flutter/flutter/pull/69420/files#r515275570. It seems like are both trying to hook into functionality that we don't yet support (namely, creating a GitTagVersion object for a commit that ISN'T HEAD). It would be great if the two of you could coordinate implementing this.
There was a problem hiding this comment.
@karamage I've updated #69420 as per suggestions from @christopherfujino. Please have a look at it(I've not updated the tests yet).
If you need any clarifications about my approach, or have a better idea on implementing the feature, we can discuss on the chat.
There was a problem hiding this comment.
@royarg02 @christopherfujino Thanks for your suggestion.
I'll look at #69420.
I am trying to understand your approach.
|
@royarg02 Thank you. I will work on this PR. |
459da7e to
5bba3db
Compare
|
I went back to the changes because of the conflicts. I will continue to change the PR from here. It's going to take some time to understand the changes. |
|
I saw #69420. It was very informative. Thank you. I wrote the code for this PR, but I'm not sure if it's good enough. The upgradeChannel method is gone, so I made a change to the recordState method. If I'm wrong, please let me know. I wrote the test code and ran the test. Thank you for reading. |
|
|
||
| void recordState(FlutterVersion flutterVersion) { | ||
| void recordState(FlutterVersion flutterVersion, FlutterVersion upstreamVersion) { | ||
| globals.printStatus('Upgrading Flutter to ${upstreamVersion.frameworkVersion} from ${flutterVersion.frameworkVersion} in $workingDirectory...'); |
There was a problem hiding this comment.
It might be better if you directly put this line in runCommandFirstHalf after calling recordState.
| const String upstreamVersion = '4.5.6'; | ||
|
|
||
| when(flutterVersion.frameworkRevision).thenReturn(revision); | ||
| when(flutterVersion.frameworkRevisionShort).thenReturn(revision); |
There was a problem hiding this comment.
I don't think you'll need flutterVersion.frameworkRevisionShort in your test.
Same for latestVersion.frameworkRevisionShort below.
| ), | ||
| ); | ||
| realCommandRunner.recordState(flutterVersion, latestVersion); | ||
| expect(testLogger.statusText, contains('Upgrading Flutter to ${latestVersion.frameworkVersion} from ${flutterVersion.frameworkVersion} in ${realCommandRunner.workingDirectory}')); |
There was a problem hiding this comment.
Tests should be matched against hardcoded strings.
See #69420 (comment) for context.
a313aa9 to
348656f
Compare
|
@royarg02 Your suggestions were very helpful. Thank you. |
| ]), | ||
| ]); | ||
|
|
||
| await realCommandRunner.runCommandFirstHalf(force: true, gitTagVersion: gitTagVersion, flutterVersion: flutterVersion, testFlow: true, verifyOnly: false); |
There was a problem hiding this comment.
Since the message you are expecting is in runCommandFirstHalf, it would be preferable to run fakeCommandRunner.runCommand and await for FlutterCommandResult.success instead of adding commands explicitly to processManager, just like other tests.
Also, please format the call as following:
final Future<FlutterCommandResult> result = fakeCommandRunner.runCommand(
force: false,
continueFlow: false,
testFlow: false,
gitTagVersion: gitTagVersion,
flutterVersion: flutterVersion,
verifyOnly: true,
);| ]); | ||
|
|
||
| await realCommandRunner.runCommandFirstHalf(force: true, gitTagVersion: gitTagVersion, flutterVersion: flutterVersion, testFlow: true, verifyOnly: false); | ||
| expect(testLogger.statusText, contains('Upgrading Flutter to 4.5.6 from 1.2.3 in null')); |
There was a problem hiding this comment.
Could you change null to something meaningful? I think using fakeCommandRunner.workingDirectory may fix this.
|
@royarg02 The improvements you have pointed out have been very helpful. I have fixed the test code, could you take a look at it? |
|
Everything looks good, let's see how the maintainers respond. You may want to update the original PR comment. |
Description
Add current version to the upgrade message of the Flutter tool.
I'm a first-time contributor.
There are many things I don't understand, so please let me know.
Please point out any mistakes.
Thank you for reviewing it.
Related Issues
Add current version to the upgrade message of the Flutter tool. #63023
Tests
I added the following tests:
Replace this with a list of the tests that you added as part of this PR. A change in behavior with no test covering it
will likely get reverted accidentally sooner or later. PRs must include tests for all changed/updated/fixed behaviors. See Test Coverage.
Checklist
Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.