DevTools extensions don't load for a test ran with `flutter test` or `dart test`
- When running
flutter test test/app_that_uses_foo_test.dart --start-paused, thepackage:fooDevTools extension does not load - When running
flutter run test/app_that_uses_foo_test.dart --start-paused -d flutter-tester, thepackage:fooDevTools 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.
What is odd is that the Flutter sidebar DevTools menu properly detects the foo extension even though DevTools itself cannot:
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 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)
We could also perhaps include it on the querystring if we're launching DevTools I think?
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.
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.
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.
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.