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

[flutter_tools] Add support for URI formats like ?line=x for "flutter test" #119740

Merged
merged 7 commits into from Feb 27, 2023

Conversation

DanTup
Copy link
Contributor

@DanTup DanTup commented Feb 1, 2023

This allows tests to be filtered by name/line/col using a URI format passed to flutter test, as dart test now does (dart-lang/test#1604).

flutter test test/foo_test.dart
flutter test "test/foo_test.dart?full-name=bar"
flutter test "test/foo_test.dart?line=15"

Mostly it's just changing some Strings to URIs, which are then passed on to package: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

  • 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 team Infra upgrades, team productivity, code health, technical debt. See also team: labels. tool Affects the "flutter" command-line tool. See also t: labels. labels Feb 1, 2023
@DanTup DanTup marked this pull request as ready for review February 18, 2023 10:08
// 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));
Copy link
Member

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?

Copy link
Contributor Author

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).

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

@DanTup DanTup merged commit 06952ba into flutter:master Feb 27, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 27, 2023
@DanTup DanTup deleted the support-test-lines branch March 1, 2023 10:51
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team Infra upgrades, team productivity, code health, technical debt. See also team: labels. tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support running multiple tests by line/col (as package:test does)
2 participants