-
Notifications
You must be signed in to change notification settings - Fork 121
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
Make testBenchmarks() synchronous. #1499
Conversation
This avoids calling group() after an async pause, which breaks running short_format_test.dart and tall_format_test.dart outside of the test runner.
FWIW the late final List<Benchmark> benchmarks;
setUpAll(() async {
benchmarks = await Benchmark.findAll();
});
Can you clarify this? In |
What do you think of dart-lang/test#2251 This would change the error output to:
|
Yeah, that's definitely clearer. At the same time... I wonder if it would be better for the test package to have the same semantics when you run a test file standalone or not? That would be a breaking change and maybe hard to roll out, but it would avoid problems like this. |
I think I have a vague recollection of discussing this previously and deciding against it, but I can't track it down. My understanding is that the vast majority of tests are run with the test runner so most users never see this difference. A downside to changing behavior would be that many more people will hit this error, with the upside that it's less confusing for the small fraction of users who do run tests standalone. |
Fwiw, when macros are released we could very likely fix this issue for standalone tests because we could wrap the users main and await the future it returns. |
Interesting - so as long as the user applies the macro to |
Oh, geez, you're right. Sorry, still got some brain fog. Actually, now I don't know how this PR fixes the issue. It definitely does. I couldn't run the tests standalone before this change but I can now. Given that this is a fix for an unusual way of running the tests, I'm inclined to just leave it alone but I do wonder what's going on here. There is a whole bunch of other async work that happens to queue up tests (all of the |
Any concern with moving to the |
Oh, this falls into the second category of my message. Async work that is required before declaring tests. I'm also confused how this change caused them to start passing... It looks like it would be pretty invasive to refactor these tests with all async work done before the first test is declared. |
Yeah, it would be hard. Doable, but annoying. |
If you hit more problems with the standalone test behavior add a comment on dart-lang/test#2253 and we can consider something like If the current tests are working then I think it's OK to wait until they break again to worry about it further. I have no idea what async interleaving happens to make it work, but all the test cases are running and it's passing so 🤷 |
This avoids calling group() after an async pause, which breaks running short_format_test.dart and tall_format_test.dart outside of the test runner.
cc @scheglov