-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[flutter_tools] Add support for URI formats like ?line=x for "flutter test" #119740
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
Conversation
8f6cc86
to
32c77d3
Compare
// We don't scan the entire package, only the test/ subdirectory, so that | ||
// files with names like "hit_test.dart" don't get run. | ||
final Directory testDir = globals.fs.directory('test'); | ||
if (!testDir.existsSync()) { | ||
throwToolExit('Test directory "${testDir.path}" not found.'); | ||
} | ||
_testFiles = _findTests(testDir).toList(); | ||
if (_testFiles.isEmpty) { | ||
_testFileUris..clear()..addAll(_findTests(testDir).map(Uri.file)); |
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.
why do we have to clear _testFileUris
?
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.
We shouldn't. I guess I did this to preserve the original semantics (the original _testFiles
was overwritten). Unless this verifyThenRunCommand
method is being called multiple times on a single instance, it shouldn't make a difference.
(I've removed it now).
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
This allows tests to be filtered by name/line/col using a URI format passed to
flutter test
, asdart test
now does (dart-lang/test#1604).Mostly it's just changing some
String
s toURI
s, which are then passed on topackage:test
.The motivation here is to be able to run tests by the line they appear on from IDE UIs, because currently they have to use
--name
which doesn't handle overlapping or dynamic names very well (or test names with characters that are complicated to escape when using shell-execute).Fixes #114968.
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.