1f52372bfa
AnalysisDriverResolutionTest is partially updated, about 30 failing tests added. I will get back to it in a following CL, it is not directly CFE integration, but updated understanding how we want to resolve. For example we don't need types for non-expression identifiers. Change-Id: I3daddbb6c66ffad7a726f3313a1199fd7387aa04 Reviewed-on: https://dart-review.googlesource.com/71883 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
103 lines
3.1 KiB
Dart
103 lines
3.1 KiB
Dart
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'dart:async';
|
|
import 'dart:math';
|
|
|
|
import 'package:analysis_server/protocol/protocol_generated.dart';
|
|
import 'package:analysis_server/src/status/diagnostics.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
import '../../test/integration/support/integration_tests.dart';
|
|
|
|
void printMemoryResults(String id, String description, List<int> sizes) {
|
|
int minMemory = sizes.fold(sizes.first, min);
|
|
int maxMemory = sizes.fold(sizes.first, max);
|
|
String now = new DateTime.now().toUtc().toIso8601String();
|
|
print('$now ========== $id');
|
|
print('memory: $sizes');
|
|
print('min_memory: $minMemory');
|
|
print('max_memory: $maxMemory');
|
|
print(description.trim());
|
|
print('--------------------');
|
|
print('');
|
|
print('');
|
|
}
|
|
|
|
/**
|
|
* Base class for analysis server memory usage tests.
|
|
*/
|
|
class AnalysisServerMemoryUsageTest
|
|
extends AbstractAnalysisServerIntegrationTest {
|
|
static const int vmServicePort = 12345;
|
|
|
|
Future<int> getMemoryUsage() async {
|
|
Uri uri = Uri.parse('ws://127.0.0.1:$vmServicePort/ws');
|
|
final ServiceProtocol service = await ServiceProtocol.connect(uri);
|
|
final Map vm = await service.call('getVM');
|
|
|
|
int total = 0;
|
|
|
|
List isolateRefs = vm['isolates'];
|
|
for (Map isolateRef in isolateRefs) {
|
|
Map isolate =
|
|
await service.call('getIsolate', {'isolateId': isolateRef['id']});
|
|
|
|
Map _heaps = isolate['_heaps'];
|
|
total += _heaps['new']['used'] + _heaps['new']['external'];
|
|
total += _heaps['old']['used'] + _heaps['old']['external'];
|
|
}
|
|
|
|
service.dispose();
|
|
|
|
return total;
|
|
}
|
|
|
|
/**
|
|
* Send the server an 'analysis.setAnalysisRoots' command directing it to
|
|
* analyze [sourceDirectory].
|
|
*/
|
|
Future setAnalysisRoot() =>
|
|
sendAnalysisSetAnalysisRoots([sourceDirectory.path], []);
|
|
|
|
/**
|
|
* The server is automatically started before every test.
|
|
*/
|
|
@override
|
|
Future setUp() {
|
|
onAnalysisErrors.listen((AnalysisErrorsParams params) {
|
|
currentAnalysisErrors[params.file] = params.errors;
|
|
});
|
|
onServerError.listen((ServerErrorParams params) {
|
|
// A server error should never happen during an integration test.
|
|
fail('${params.message}\n${params.stackTrace}');
|
|
});
|
|
Completer serverConnected = new Completer();
|
|
onServerConnected.listen((_) {
|
|
outOfTestExpect(serverConnected.isCompleted, isFalse);
|
|
serverConnected.complete();
|
|
});
|
|
return startServer(servicesPort: vmServicePort).then((_) {
|
|
server.listenToOutput(dispatchNotification);
|
|
server.exitCode.then((_) {
|
|
skipShutdown = true;
|
|
});
|
|
return serverConnected.future;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* After every test, the server is stopped.
|
|
*/
|
|
Future shutdown() async => await shutdownIfNeeded();
|
|
|
|
/**
|
|
* Enable [ServerService.STATUS] notifications so that [analysisFinished]
|
|
* can be used.
|
|
*/
|
|
Future subscribeToStatusNotifications() async {
|
|
await sendServerSetSubscriptions([ServerService.STATUS]);
|
|
}
|
|
}
|