Add a --print-dtd flag to print the DTD address served by DevTools server#144272
Add a --print-dtd flag to print the DTD address served by DevTools server#144272kenzieschmoll merged 25 commits intoflutter:masterfrom
--print-dtd flag to print the DTD address served by DevTools server#144272Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
| final Match? dtdMatch = _serveDtdPattern.firstMatch(line); | ||
| if (dtdMatch != null) { | ||
| final String uri = dtdMatch[1]!; | ||
| dtdUri = Uri.parse(uri); |
There was a problem hiding this comment.
nit, we can return here and not bother checking for _serveDevToolsPattern, right?
There was a problem hiding this comment.
No these are independent of one another. The _serveDevToolsPattern should always be in the stdout. The _serveDtdPattern might be there depending on whether the --print-dtd flag was passed to the dart devtools command above.
There was a problem hiding this comment.
Would they be on the same line though?
There was a problem hiding this comment.
No these will be on separate lines.
|
|
||
| devToolsUrl = await completer.future; | ||
| // We do not need to wait for a [Completer] holding the DTD URI because | ||
| // the DTD URI will be output to stdout before the DevTools URI. Awaiting |
There was a problem hiding this comment.
Is this an implementation detail that could be inadvertently broken in a future refactor?
There was a problem hiding this comment.
Could also be a reason to use the nifty new FutureRecord2 extension method .wait() :)
https://api.dart.dev/stable/3.3.0/dart-async/FutureRecord2/wait.html
There was a problem hiding this comment.
The DTD uri won't always be available here, so we can't await a completer with the guarantee that it will complete. I can add tests in https://dart-review.googlesource.com/c/sdk/+/354460 that verify the order, with a comment that if the order or strings should change, that we will need to update the Flutter tools launcher. We could already get in a broken state with the existing "Serving DevTools" string if that were ever to change.
There was a problem hiding this comment.
ahhhh, I see. A test sounds great, thanks!
|
Just added testing. Please review with "Hide whitespace" enabled. I fixed a formatting issue as a yak-shave. |
| argParser.addFlag( | ||
| FlutterGlobalOptions.kPrintDtdUri, | ||
| negatable: false, | ||
| help: 'Print the URI of the Dart Tooling Daemon, if one is hosted by the Flutter CLI.', |
There was a problem hiding this comment.
@christopherfujino is it okay to say "the Flutter CLI" here? Technically it is hosted by DevTools server, but that seemed like an implementation detail that wouldn't mean anything to the end user.
--print-dtd-uri flag to print the DTD address served by DevTools server--print-dtd flag to print the DTD address served by DevTools server
|
I'm seeing test failures that I'm 99% sure are not related to your change: |
|
merging in upstream master, in case it was fixed there. it might also have been a recipe change... |
|
The failure is being triggered from this line: @christopherfujino any ideas on why that artifact would not be available in a test environment? Or how to make it so that it is available? Another thought is to wrap |
|
All tests are passing with the try / catch. @christopherfujino let me know if you think this is an acceptable solution. |
Hmm, a lot of this code (not from your PR) looks wrong to me, but I'm not fully grokking what happened. I'm investigating now... |
Now that https://dart-review.googlesource.com/c/sdk/+/354460 has landed, DevTools server (or DDS depending on how DDS is started) will spawn the Dart Tooling Daemon (DTD). We need a way to access this URI from both the Dart CLI (dart-lang/sdk#55034) and Flutter CLI (#144270)
This PR
adds a command runner flag

--print-dtdthat is passed along to theDevToolsLauncherclass. This value is then read when printing the DevTools output to determine whether we should also print a DTD uri.[cleanup for testing] merges multiple
FakeDevtoolsLauncherclasses into a single fake defined infakes.dartFixes #144270.
@bkonyi @christopherfujino