| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library test.integration.analysis.error; | |
| 6 | |
| 7 import 'dart:async'; | |
| 8 | |
| 9 import 'package:test_reflective_loader/test_reflective_loader.dart'; | |
| 10 import 'package:unittest/unittest.dart'; | |
| 11 | |
| 12 import '../utils.dart'; | |
| 13 import 'integration_tests.dart'; | |
| 14 | |
| 15 main() { | |
| 16 initializeTestEnvironment(); | |
| 17 // defineReflectiveTests(AsynchronyIntegrationTest); | |
| 18 } | |
| 19 | |
| 20 /** | |
| 21 * Verify that the server's input and output streams are asynchronous by | |
| 22 * attempting to flood its input buffer with commands without listening to | |
| 23 * its output buffer for responses. The server should continue to train its | |
| 24 * input buffer even though its output buffer is full. | |
| 25 * | |
| 26 * Once enough commands have been sent, we begin reading from the server's | |
| 27 * output buffer, and verify that it responds to the last command. | |
| 28 * | |
| 29 * NB. | |
| 30 * | |
| 31 * This test was intentionally disabled, because after r43123 server | |
| 32 * writes to stdout synchronously. So, now it is the client's responsibility | |
| 33 * to read stdout in a timely manner to avoid blocking the server. | |
| 34 */ | |
| 35 @reflectiveTest | |
| 36 class AsynchronyIntegrationTest { | |
| 37 /** | |
| 38 * Number of messages to queue up before listening for responses. | |
| 39 */ | |
| 40 static const MESSAGE_COUNT = 10000; | |
| 41 | |
| 42 /** | |
| 43 * Connection to the analysis server. | |
| 44 */ | |
| 45 final Server server = new Server(); | |
| 46 | |
| 47 Future setUp() { | |
| 48 return server.start(); | |
| 49 } | |
| 50 | |
| 51 test_asynchrony() { | |
| 52 // Send MESSAGE_COUNT messages to the server without listening for | |
| 53 // responses. | |
| 54 Future lastMessageResult; | |
| 55 for (int i = 0; i < MESSAGE_COUNT; i++) { | |
| 56 lastMessageResult = server.send('server.getVersion', null); | |
| 57 } | |
| 58 | |
| 59 // Flush the server's standard input stream to verify that it has really | |
| 60 // received them all. If the server is blocked waiting for us to read | |
| 61 // its responses, the flush will never complete. | |
| 62 return server.flushCommands().then((_) { | |
| 63 // Begin processing responses from the server. | |
| 64 server.listenToOutput((String event, params) { | |
| 65 // The only expected notification is server.connected. | |
| 66 if (event != 'server.connected') { | |
| 67 fail('Unexpected notification: $event'); | |
| 68 } | |
| 69 }); | |
| 70 | |
| 71 // Terminate the test when the response to the last message is received. | |
| 72 return lastMessageResult.then((_) { | |
| 73 server.send("server.shutdown", null).then((_) { | |
| 74 return server.exitCode; | |
| 75 }); | |
| 76 }); | |
| 77 }); | |
| 78 } | |
| 79 } | |
| OLD | NEW |