Skip to content
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

Fix that flutter test does not understand concurrency #125942

Merged
merged 5 commits into from May 8, 2023

Conversation

fzyzcjy
Copy link
Contributor

@fzyzcjy fzyzcjy commented May 3, 2023

Close #125940

I will add tests if this PR looks roughly OK :)

The fix mainly mimics #115160 - just remove the default argument.

p.s. I ran into this bug when wanting to set concurrency in my dart_test.yaml for one set of my tests which I need to be executed without parallalization.

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 this 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 May 3, 2023
@flutter-dashboard
Copy link

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 (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@christopherfujino
Copy link
Member

Awesome, this approach looks good to me. If you add tests, we will review it next week.

@fzyzcjy
Copy link
Contributor Author

fzyzcjy commented May 4, 2023

Sure! I will add tests (in batch with my other PRs) as soon as possible when having time

@fzyzcjy
Copy link
Contributor Author

fzyzcjy commented May 5, 2023

Tests added (mimicking #115160), will come back and check CI soon

@christopherfujino
Copy link
Member

@eliasyishak can you review this one?

@eliasyishak
Copy link
Contributor

@eliasyishak can you review this one?

Yep I'll take a look!

@@ -146,7 +144,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
)
..addOption('concurrency',
abbr: 'j',
defaultsTo: math.max<int>(1, globals.platform.numberOfProcessors - 2).toString(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Although we are not setting the default value for concurrency in Flutter, we are eventually calling dart test which does have a default set for concurrency. As you can see here https://pub.dev/packages/test#test-concurrency, the default is going to be half of the host's CPU cores. ie. for me I have 10, so flutter would have defaulted to 8 while dart defaulted to 5.

So instead of removing the default help text, we should pass the default from dart.

This will prevent people from thinking that they are running on one thread when in reality it is likely running on a few.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I'm not 100% sure what I said above is correct, @christopherfujino, do you know if we are passing the args from the flutter command to dart test and using the dart defaults for test? Or do we have our own implementation that doesn't use the defaults?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, then how can we read data from dart_test.yaml? If we are passing a value like dart test --concurrency sth, dart test will ignore it, and thus the bug still occurs

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, to be clear I think the changes you made are correct in this PR, I just want to specify what the default is in the help message downstream

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I was referring to the defaultsTo value that gets printed along with the help text when you run flutter test --help. I'm suggesting that we keep the changes made in this PR but for the defaultsTo value, we should refer to the default value that dart uses, which is half of the number of processors on the developer's machine

Copy link
Member

Choose a reason for hiding this comment

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

I only skimmed this change, maybe I'm misunderstanding, but I thought the fix here was to remove defaultsTo and let package:test figure it out on its own, so that it will respect dart_test.yaml.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that is correct, and @fzyzcjy PR fixes that issue.

My only concern is that flutter users may not know that under the hood package:test also has a default value for concurrency that will be applied if the flutter developer does not supply a value for concurrency.

For example, if the user runs flutter test in their app without specifying concurrent workers, they may be thinking that it will only run on one worker, when in reality package:test is doing something else.

This may not be an issue but I thought giving that information in the help text would be helpful

Copy link
Member

Choose a reason for hiding this comment

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

But if we provide a defaultsTo value, then how would package:test ever look up dart_test.yaml? It will see that it's always being passed an explicit argument.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah this is my mistake, I forgot that defaultsTo will actually pass a value. Sorry for the confusion!

This should be okay then because we will end up with the same bug. I was really just trying to document that there will likely be more than one worker running for flutter test

Copy link
Contributor

@eliasyishak eliasyishak left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for contribution! 😄

Copy link
Member

@christopherfujino christopherfujino left a comment

Choose a reason for hiding this comment

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

LGTM

@christopherfujino christopherfujino added the autosubmit Merge PR when tree becomes green via auto submit App label May 8, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 8, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented May 8, 2023

auto label is removed for flutter/flutter, pr: 125942, Mergeability of pull request flutter/flutter/125942 could not be determined at time of merge..

@eliasyishak eliasyishak added the autosubmit Merge PR when tree becomes green via auto submit App label May 8, 2023
@auto-submit auto-submit bot merged commit 2a9530f into flutter:master May 8, 2023
125 checks passed
fluttermirroringbot pushed a commit that referenced this pull request May 8, 2023
Close #125940

I will add tests if this PR looks roughly OK :)

The fix mainly mimics #115160 - just remove the default argument.

p.s. I ran into this bug when wanting to set concurrency in my dart_test.yaml for one set of my tests which I need to be executed without parallalization.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 9, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 9, 2023
auto-submit bot pushed a commit to flutter/packages that referenced this pull request May 9, 2023
flutter/flutter@4ed1c92...8c5a1ea

2023-05-08 kevmoo@users.noreply.github.com tool/web: tiniest tweak to wasm help content (flutter/flutter#126284)
2023-05-08 engine-flutter-autoroll@skia.org Roll Flutter Engine from d9184ce4ffa0 to 8d3a8162b3ab (7 revisions) (flutter/flutter#126288)
2023-05-08 5236035+fzyzcjy@users.noreply.github.com Fix that `flutter test` does not understand `concurrency` (flutter/flutter#125942)
2023-05-08 5236035+fzyzcjy@users.noreply.github.com Fix that `flutter test` does not understand `concurrency` (flutter/flutter#125942)
2023-05-08 github@alexv525.com Improve the format in `asset_bundle.dart` (flutter/flutter#126229)
2023-05-08 5236035+fzyzcjy@users.noreply.github.com Tiny cleanup for Navigator code (without introducing dependency) (flutter/flutter#125628)
2023-05-08 50433979+negotoyolo@users.noreply.github.com  [Refactor] Fix style in example (flutter/flutter#126191)
2023-05-08 engine-flutter-autoroll@skia.org Roll Flutter Engine from a8e9ac63fd95 to d9184ce4ffa0 (2 revisions) (flutter/flutter#126279)
2023-05-08 737941+loic-sharma@users.noreply.github.com [Tool] Output help on 'flutter pub' (flutter/flutter#126211)
2023-05-08 jacksongardner@google.com Always use `--concurrency=1` for web tests. (flutter/flutter#126179)
2023-05-08 42216813+eliasyishak@users.noreply.github.com Add `--verbose` flags for flakey tests (flutter/flutter#126162)
2023-05-08 engine-flutter-autoroll@skia.org Roll Packages from a0f8fd8 to 4800d65 (2 revisions) (flutter/flutter#126269)
2023-05-08 reidbaker@google.com Test AGP 8.0 using java 17 (flutter/flutter#125323)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC camillesimon@google.com,rmistry@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
nploi pushed a commit to nploi/packages that referenced this pull request Jul 16, 2023
…r#3949)

flutter/flutter@4ed1c92...8c5a1ea

2023-05-08 kevmoo@users.noreply.github.com tool/web: tiniest tweak to wasm help content (flutter/flutter#126284)
2023-05-08 engine-flutter-autoroll@skia.org Roll Flutter Engine from d9184ce4ffa0 to 8d3a8162b3ab (7 revisions) (flutter/flutter#126288)
2023-05-08 5236035+fzyzcjy@users.noreply.github.com Fix that `flutter test` does not understand `concurrency` (flutter/flutter#125942)
2023-05-08 5236035+fzyzcjy@users.noreply.github.com Fix that `flutter test` does not understand `concurrency` (flutter/flutter#125942)
2023-05-08 github@alexv525.com Improve the format in `asset_bundle.dart` (flutter/flutter#126229)
2023-05-08 5236035+fzyzcjy@users.noreply.github.com Tiny cleanup for Navigator code (without introducing dependency) (flutter/flutter#125628)
2023-05-08 50433979+negotoyolo@users.noreply.github.com  [Refactor] Fix style in example (flutter/flutter#126191)
2023-05-08 engine-flutter-autoroll@skia.org Roll Flutter Engine from a8e9ac63fd95 to d9184ce4ffa0 (2 revisions) (flutter/flutter#126279)
2023-05-08 737941+loic-sharma@users.noreply.github.com [Tool] Output help on 'flutter pub' (flutter/flutter#126211)
2023-05-08 jacksongardner@google.com Always use `--concurrency=1` for web tests. (flutter/flutter#126179)
2023-05-08 42216813+eliasyishak@users.noreply.github.com Add `--verbose` flags for flakey tests (flutter/flutter#126162)
2023-05-08 engine-flutter-autoroll@skia.org Roll Packages from a0f8fd8 to 4800d65 (2 revisions) (flutter/flutter#126269)
2023-05-08 reidbaker@google.com Test AGP 8.0 using java 17 (flutter/flutter#125323)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC camillesimon@google.com,rmistry@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flutter test does not understand concurrency
3 participants