OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, 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 server.performance; |
| 6 |
| 7 import 'dart:async'; |
| 8 |
| 9 import 'package:analysis_server/src/protocol.dart'; |
| 10 import 'package:unittest/unittest.dart'; |
| 11 |
| 12 import '../../test/integration/integration_tests.dart'; |
| 13 |
| 14 /** |
| 15 * Base class for analysis server performance tests. |
| 16 */ |
| 17 abstract class AbstractAnalysisServerPerformanceTest |
| 18 extends AbstractAnalysisServerIntegrationTest { |
| 19 /** |
| 20 * Stopwatch for timing results; |
| 21 */ |
| 22 Stopwatch stopwatch = new Stopwatch(); |
| 23 |
| 24 /** |
| 25 * Send the server an 'analysis.setAnalysisRoots' command directing it to |
| 26 * analyze [sourceDirectory]. |
| 27 */ |
| 28 Future setAnalysisRoot() { |
| 29 return sendAnalysisSetAnalysisRoots([sourceDirectory.path], []); |
| 30 } |
| 31 |
| 32 /** |
| 33 * Enable [SERVER_STATUS] notifications so that [analysisFinished] |
| 34 * can be used. |
| 35 */ |
| 36 Future subscribeToStatusNotifications() { |
| 37 List<Future> futures = <Future>[]; |
| 38 futures.add(sendServerSetSubscriptions([ServerService.STATUS])); |
| 39 return Future.wait(futures); |
| 40 } |
| 41 |
| 42 /** |
| 43 * The server is automatically started before every test. |
| 44 */ |
| 45 @override |
| 46 Future setUp() { |
| 47 onAnalysisErrors.listen((AnalysisErrorsParams params) { |
| 48 currentAnalysisErrors[params.file] = params.errors; |
| 49 }); |
| 50 onServerError.listen((ServerErrorParams params) { |
| 51 // A server error should never happen during an integration test. |
| 52 fail('${params.message}\n${params.stackTrace}'); |
| 53 }); |
| 54 Completer serverConnected = new Completer(); |
| 55 onServerConnected.listen((_) { |
| 56 expect(serverConnected.isCompleted, isFalse); |
| 57 serverConnected.complete(); |
| 58 }); |
| 59 return startServer().then((_) { |
| 60 server.listenToOutput(dispatchNotification); |
| 61 server.exitCode.then((_) { |
| 62 skipShutdown = true; |
| 63 }); |
| 64 return serverConnected.future; |
| 65 }); |
| 66 } |
| 67 |
| 68 /** |
| 69 * After every test, the server is stopped. |
| 70 */ |
| 71 @override |
| 72 Future tearDown() { |
| 73 return shutdownIfNeeded(); |
| 74 } |
| 75 } |
OLD | NEW |