Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1700)

Unified Diff: pkg/analysis_server/bin/fuzz/logging_client_channel.dart

Issue 584963002: first cut fuzz test for analysis server (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge and address comments Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/bin/fuzz/json.dart ('k') | pkg/analysis_server/bin/fuzz/protocol.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/bin/fuzz/logging_client_channel.dart
diff --git a/pkg/analysis_server/bin/fuzz/logging_client_channel.dart b/pkg/analysis_server/bin/fuzz/logging_client_channel.dart
new file mode 100644
index 0000000000000000000000000000000000000000..941646dc43b492502fccf2e8d665686e5c1d22e1
--- /dev/null
+++ b/pkg/analysis_server/bin/fuzz/logging_client_channel.dart
@@ -0,0 +1,85 @@
+// Copyright (c) 2014, 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.
+
+part of server.manager;
+
+/**
+ * A client channel that logs communication to stdout
+ * and handles errors received from the server.
+ */
+class LoggingClientChannel implements ClientCommunicationChannel {
+ final ClientCommunicationChannel channel;
+ int serverErrorCount = 0;
+
+ LoggingClientChannel(this.channel) {
+ channel.notificationStream.listen((Notification notification) {
+ _logNotification(notification);
+ if (notification.event == 'server.error') {
+ ServerErrorParams error =
+ new ServerErrorParams.fromNotification(notification);
+ _handleError(
+ 'Server reported error: ${error.message}',
+ error.stackTrace);
+ }
+ });
+ }
+
+ @override
+ Stream<Notification> get notificationStream => channel.notificationStream;
+
+ @override
+ void set notificationStream(Stream<Notification> _notificationStream) {
+ throw 'invalid operation';
+ }
+
+ @override
+ Stream<Response> get responseStream => channel.responseStream;
+
+ @override
+ void set responseStream(Stream<Response> _responseStream) {
+ throw 'invalid operation';
+ }
+
+ @override
+ Future close() {
+ print('Requesting client channel be closed');
+ return channel.close().then((_) {
+ print('Client channel closed');
+ });
+ }
+
+ @override
+ Future<Response> sendRequest(Request request) {
+ _logOperation('=>', request);
+ return channel.sendRequest(request).then((Response response) {
+ RequestError error = response.error;
+ if (error != null) {
+ error.code;
+ stderr.write('Server Error ${error.code}: ${error.message}');
+ print(error.stackTrace);
+ exitCode = 31;
+ }
+ _logOperation('<=', request);
+ return response;
+ });
+ }
+
+ void _handleError(String errMsg, String stackTrace) {
+ //error.isFatal;
+ stderr.writeln('>>> Server reported exception');
+ stderr.writeln(errMsg);
+ print(stackTrace);
+ serverErrorCount++;
+ }
+
+ void _logNotification(Notification notification) {
+ print('<= ${notification.event}');
+ }
+
+ void _logOperation(String direction, Request request) {
+ String id = request.id.padLeft(5);
+ String method = request.method.padRight(20);
+ print('$direction $id $method');
+ }
+}
« no previous file with comments | « pkg/analysis_server/bin/fuzz/json.dart ('k') | pkg/analysis_server/bin/fuzz/protocol.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698