Skip to content

DevTools extensions don't load for a test ran with flutter test or dart test #7183

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

Closed
kenzieschmoll opened this issue Feb 8, 2024 · 7 comments · Fixed by #7717
Closed

DevTools extensions don't load for a test ran with flutter test or dart test #7183

kenzieschmoll opened this issue Feb 8, 2024 · 7 comments · Fixed by #7717
Labels
devtools extensions Issues related to DevTools extensions P1 high priority issues at the top of the work list, actively being worked on.

Comments

@kenzieschmoll
Copy link
Member

  • When running flutter test test/app_that_uses_foo_test.dart --start-paused , the package:foo DevTools extension does not load
  • When running flutter run test/app_that_uses_foo_test.dart --start-paused -d flutter-tester, the package:foo DevTools extension does load.

In the flutter test case, rootLibraryForMainIsolate is returning file:///var/folders/gf/14ctmb656m3100h5z857669800fv4z/T/flutter_tools.9i1YVt/flutter_test_listener.ASUv35/listener.dart, whereas in the flutter run case it returns the expected path to the test file.

Since we have DevTools extensions intended for test files (e.g. Patrol), we should fix this and cherry pick to stable.

CC @bkonyi @DanTup for any ideas you have on how we can get the proper root lib or isolate for the flutter test case.

@kenzieschmoll kenzieschmoll added devtools extensions Issues related to DevTools extensions P1 high priority issues at the top of the work list, actively being worked on. labels Feb 8, 2024
@kenzieschmoll
Copy link
Member Author

What is odd is that the Flutter sidebar DevTools menu properly detects the foo extension even though DevTools itself cannot:
Screenshot 2024-02-07 at 4 20 01 PM

We get the app root directly from VS code in the sidebar case: https://github.com/flutter/devtools/blob/master/packages/devtools_app/lib/src/standalone_ui/vs_code/debug_sessions.dart/#L166

Whereas in DevTools itself, we try to get the URI from the isolate:
https://github.com/flutter/devtools/blob/master/packages/devtools_app/lib/src/extensions/extension_service.dart#L185

@DanTup how are you passing the proper URI for the debug session, and is this something we can get on the DevTools side too from the VM service?

@DanTup
Copy link
Contributor

DanTup commented Feb 8, 2024

@DanTup how are you passing the proper URI for the debug session, and is this something we can get on the DevTools side too from the VM service?

VS Code knows where the root of the project is because when we start a debugging session we need to work out where the project root is to know if it's a Dart/Flutter project. So against the debug session information, we keep track of this (and we include it when we tell the sidebar a debug session started).

I guess we could pass this info along to DevTools somehow, but I'm not sure what the best way would be (because it's tied to a specific debug session). We could perhaps provide the running debug sessions to DTD and include this, or we could perhaps include it when we tell the DevTools server about the VM Services:

https://github.com/Dart-Code/Dart-Code/blob/95dfe4e8ca027ec9ce19565ed3d59009d0654ffb/src/extension/sdk/dev_tools/manager.ts#L463

(We currently call vm.register for each debug session.. I think it's currently only used to let DevTools server register the launchDevTools service to allow us to launch DevTools in Chrome without doing the Chrome search in Dart-Code)

@DanTup
Copy link
Contributor

DanTup commented Feb 8, 2024

We could also perhaps include it on the querystring if we're launching DevTools I think?

@kenzieschmoll
Copy link
Member Author

The one problem with having the IDEs pass in a value somehow is that this also needs to work in the command line case where a user is running a test with dart test or flutter test.

@bkonyi
Copy link
Contributor

bkonyi commented Feb 8, 2024

The right thing is probably to have both dart test and flutter test explicitly mark the main isolate as a system isolate so that DevTools will ignore it by default.

@kenzieschmoll
Copy link
Member Author

The right thing is probably to have both dart test and flutter test explicitly mark the main isolate as a system isolate so that DevTools will ignore it by default.

When I printed out all the isolates DevTools was aware of, there was only one available.

@bkonyi
Copy link
Contributor

bkonyi commented Feb 8, 2024

The right thing is probably to have both dart test and flutter test explicitly mark the main isolate as a system isolate so that DevTools will ignore it by default.

When I printed out all the isolates DevTools was aware of, there was only one available.

Which one? The listener.dart isolate? Was it paused at start? If it was marked as a system isolate it wouldn't pause at start and the isolate it spawns would, which is probably the behavior we would want anyway.

@kenzieschmoll kenzieschmoll changed the title DevTools extensions don't load for a test ran with flutter test DevTools extensions don't load for a test ran with flutter test or dart test Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devtools extensions Issues related to DevTools extensions P1 high priority issues at the top of the work list, actively being worked on.
Projects
None yet
3 participants