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
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 (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. |
Awesome, this approach looks good to me. If you add tests, we will review it next week. |
Sure! I will add tests (in batch with my other PRs) as soon as possible when having time |
Tests added (mimicking #115160), will come back and check CI soon |
@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(), |
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.
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.
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.
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?
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.
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
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.
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
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 testArgs
list: https://github.com/flutter/flutter/pull/125942/files#diff-f3717e666fb03f50b2bb0b345f7d80d8ae1d07d7c07109ccd75ec8fdf5150ef2R112
Calls the main()
function from package:test/executable.dart: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/test/test_wrapper.dart#L26
Which gets parsed here: https://github.com/dart-lang/test/blob/master/pkgs/test_core/lib/src/runner/configuration.dart#L94 (this is from the master branch)
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.
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
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.
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
.
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.
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
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.
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.
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.
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
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, thank you for contribution! 😄
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
auto label is removed for flutter/flutter, pr: 125942, Mergeability of pull request flutter/flutter/125942 could not be determined at time of merge.. |
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
…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
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
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.