@@ -885,107 +885,6 @@ main() => print('b:b');
885885 );
886886 });
887887 });
888-
889- group ('Observatory' , () {
890- void generateServedTest ({
891- required bool serve,
892- required bool enableAuthCodes,
893- required bool explicitRun,
894- required bool withDds,
895- }) {
896- test (
897- '${serve ? 'served by default' : 'not served' } ${enableAuthCodes ? "with" : "without" } '
898- 'auth codes, ${explicitRun ? 'explicit' : 'implicit' } run,${withDds ? ' ' : 'no' } DDS' ,
899- () async {
900- p = project (
901- mainSrc:
902- 'void main() { print("ready"); int i = 0; while(true) { i++; } }' ,
903- );
904- Process process = await p.start ([
905- if (explicitRun) 'run' ,
906- '--enable-vm-service=0' ,
907- if (! withDds) '--no-dds' ,
908- if (! enableAuthCodes) '--disable-service-auth-codes' ,
909- if (serve) '--serve-observatory' ,
910- p.relativeFilePath,
911- ]);
912-
913- final completer = Completer <void >();
914-
915- late final StreamSubscription <String > sub;
916- late final String uri;
917- sub = process.stdout.transform (utf8.decoder).listen ((event) async {
918- if (event.contains (dartVMServiceRegExp)) {
919- uri = dartVMServiceRegExp.firstMatch (event)! .group (1 )! ;
920- await sub.cancel ();
921- completer.complete ();
922- }
923- });
924-
925- // Wait for process to start.
926- await completer.future;
927- final client = HttpClient ();
928-
929- Future <String > makeServiceHttpRequest ({String method = '' }) async {
930- var request = await client.getUrl (Uri .parse ('$uri $method ' ));
931- var response = await request.close ();
932- return await response.transform (utf8.decoder).join ();
933- }
934-
935- var content = await makeServiceHttpRequest ();
936- const observatoryText = 'Dart VM Observatory' ;
937- expect (content.contains (observatoryText), serve);
938- if (! serve) {
939- if (withDds) {
940- expect (content.contains ('DevTools' ), true );
941- } else {
942- expect (
943- content,
944- 'This VM does not have a registered Dart '
945- 'Development Service (DDS) instance and is not currently serving '
946- 'Dart DevTools.' ,
947- );
948- }
949- }
950-
951- // Ensure we can always make VM service requests via HTTP.
952- content = await makeServiceHttpRequest (method: 'getVM' );
953- expect (content.contains ('"jsonrpc":"2.0"' ), true );
954-
955- // If Observatory isn't being served, ensure we can enable it.
956- if (! serve) {
957- content = await makeServiceHttpRequest (method: '_serveObservatory' );
958- expect (content.contains ('"type":"Success"' ), true );
959-
960- // Ensure Observatory is now being served.
961- content = await makeServiceHttpRequest ();
962- expect (content.contains (observatoryText), true );
963- }
964-
965- process.kill ();
966- },
967- );
968- }
969-
970- const flags = < bool > [true , false ];
971- // TODO(jcollins): Disabling serving no longer seems to produce
972- // the expected output. Maybe this is because the web interface has
973- // changed?
974- for (final serve in [true ]) {
975- for (final enableAuthCodes in flags) {
976- for (final explicitRun in flags) {
977- for (final withDds in flags) {
978- generateServedTest (
979- serve: serve,
980- enableAuthCodes: enableAuthCodes,
981- explicitRun: explicitRun,
982- withDds: withDds,
983- );
984- }
985- }
986- }
987- }
988- });
989888}
990889
991890void residentRun () {
0 commit comments