Fix DevTools extensions not being resolved when app's Dart entrypoint is located in `integration_test` directory (#6644)
diff --git a/packages/devtools_app/lib/src/extensions/extension_service.dart b/packages/devtools_app/lib/src/extensions/extension_service.dart index 4d7a51c..33b7c72 100644 --- a/packages/devtools_app/lib/src/extensions/extension_service.dart +++ b/packages/devtools_app/lib/src/extensions/extension_service.dart
@@ -162,11 +162,12 @@ // server and having the server look for the package folder that contains the // `.dart_tool` directory. - // Assume that the parent folder of `lib` is the package root. - final libDirectoryRegExp = RegExp(r'\/lib\/[^\/.]*.dart'); - final libDirectoryIndex = fileUri.indexOf(libDirectoryRegExp); - if (libDirectoryIndex != -1) { - fileUri = fileUri.substring(0, libDirectoryIndex); + final directoryRegExp = + RegExp(r'\/(lib|integration_test|test|bin)\/[^\/.]*.dart'); + final directoryIndex = fileUri.indexOf(directoryRegExp); + if (directoryIndex != -1) { + fileUri = fileUri.substring(0, directoryIndex); } + return fileUri; }
diff --git a/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md b/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md index 8527d59..d48505b 100644 --- a/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md +++ b/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md
@@ -10,7 +10,10 @@ ## General updates -TODO: Remove this section if there are not any general updates. +* Enabled DevTools extensions when debugging a Dart entry point that is not +under `lib` (e.g. a unit test or integration test). Thanks to +[@bartekpacia](https://github.com/bartekpacia) for this change! - +[#6644](https://github.com/flutter/devtools/pull/6644) ## Inspector updates