-
Notifications
You must be signed in to change notification settings - Fork 6k
Adds package:litetest, uses it instead of package:test under testing/dart #26215
Conversation
ab5238c
to
abd7b11
Compare
@@ -44,78 +44,82 @@ void isolateSpawnEntrypoint(SendPort port) { | |||
} | |||
|
|||
void main() { | |||
tearDown(() { |
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.
Replacing this tearDown
with try {} finally {}
in the tests.
import 'package:vm_service/vm_service.dart' as vms; | ||
import 'package:vm_service/vm_service_io.dart'; | ||
|
||
void main() { | ||
late vms.VmService vmService; | ||
|
||
setUpAll(() async { |
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.
Replacing setUpAll
and tearDownAll
by inlining the code directly into the single 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.
Very cool! Only a couple real change requests (the instantiateImageCodec, adding a smoke test, and not using FutureOr). Otherwise nits.
'src/third_party/pkg/image': | ||
Var('github_git') + '/brendan-duncan/image.git' + '@' + '3.0.2', | ||
|
||
'src/third_party/pkg/petitparser': | ||
Var('github_git') + '/petitparser/dart-petitparser' + '@' + '4.1.0', |
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.
These dependencies (and XML) could be painful to upgrade, which we'll eventually want to do. Can we just get rid of them?
It looks like we only use this to encode and write a PNG image. We should be able to do that via dart:ui
.
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, of course, should be done in a separate PR, and I'm not terribly partial to whether it's done before or after this one lands)
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.
Filed
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.
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.
Yeah, in this PR, I think I should leave the test logic as-is, but I am totally on board with cutting down on the dependencies.
expect(const Color(0x12345678), equals(const Color(0x12345678))); | ||
expect(const Color(0x12345678), equals(Color(0x12345678))); // ignore: prefer_const_constructors | ||
expect(const Color(0x12345678), isNot(equals(const Color(0x87654321)))); | ||
expect(const Color(0x12345678), isNot(equals(const NotAColor(0x12345678)))); | ||
expect(const NotAColor(0x12345678), isNot(equals(const Color(0x12345678)))); | ||
expect(const Color(0x12345678), notEquals(const Color(0x87654321))); | ||
expect(const Color(0x12345678), notEquals(const NotAColor(0x12345678))); | ||
expect(const NotAColor(0x12345678), notEquals(const Color(0x12345678))); | ||
expect(const NotAColor(0x12345678), equals(const NotAColor(0x12345678))); |
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.
FWIW, I'm not a fan of these kind of matchers anyway. I'd much rather just see expect(Color(...) == Color(...), true);
, or even just make the second parameter to expect optional so that it more or less workslike assert
.
That said, I like notEquals
better than isNot(somethingElse(isNot(.....
.
/cc @jonahwilliams @Hixie who will probably find this interesting. |
1371d68
to
f38a8cd
Compare
Scandalous! |
f38a8cd
to
9ffb882
Compare
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
Thanks for the thorough review! |
If we're finding a way to get rid of |
|
Those advantages could also be achieved by using different files for tests that need isolating from each other. That would have the advantage of actually isolating the tests, rather than only isolating some aspects of the tests (I frequently see issues where tests interfere with each other due to shared singletons, for example). |
Towards flutter/flutter#82134.
This PR adds a Dart testing library under
testing/litetest
. It is essentially a wrapper aroundpackage:async_helper
from the Dart SDK source repo at//pkg/async_helper
with modifications to make it work in the environment offlutter_tester
. This wrapper is needed to ensure that all tests run to completion before the process exits. This is accomplished by opening aReceivePort
for each test, which is only closed when the test finishes running.The API of
package:litetest
is pretty close to the parts ofpackage:test
used by the tests undertesting/dart
with some small differences requiring patch-ups that are included in this PR.