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

Unified Diff: test/worker/worker_test.dart

Issue 1892553003: dont reuse the analysis context across worker requests (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: remove unused import Created 4 years, 8 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 | « test/worker/hello_world.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/worker/worker_test.dart
diff --git a/test/worker/worker_test.dart b/test/worker/worker_test.dart
index 80ee1fb40199830708a442a8ac796d9c57a3f235..43a8c3573d6c954bcbbd0def07d1f8642f64847f 100644
--- a/test/worker/worker_test.dart
+++ b/test/worker/worker_test.dart
@@ -2,6 +2,7 @@
// 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:convert';
import 'dart:io';
@@ -27,7 +28,13 @@ main() {
inputDartFile.path,
];
+ setUp(() {
+ inputDartFile.createSync();
+ inputDartFile.writeAsStringSync('main() => print("hello world");');
+ });
+
tearDown(() {
+ if (inputDartFile.existsSync()) inputDartFile.deleteSync();
if (outputJsFile.existsSync()) outputJsFile.deleteSync();
});
@@ -38,23 +45,23 @@ main() {
var request = new WorkRequest();
request.arguments.addAll(compilerArgs);
-
process.stdin.add(protoToDelimitedBuffer(request));
- var buffer = await messageGrouper.next;
- WorkResponse response;
- try {
- response = new WorkResponse.fromBuffer(buffer);
- } catch (_) {
- throw 'Failed to parse response: \n'
- 'bytes: $buffer\n'
- 'String: ${new String.fromCharCodes(buffer)}\n';
- }
-
+ var response = await _readResponse(messageGrouper);
expect(response.exitCode, EXIT_CODE_OK, reason: response.output);
expect(response.output, isEmpty);
expect(outputJsFile.existsSync(), isTrue);
+ expect(outputJsFile.readAsStringSync(), contains('hello world'));
+
+ /// Now update hello_world.dart and send another [WorkRequest].
+ inputDartFile.writeAsStringSync('main() => print("goodbye world");');
+ process.stdin.add(protoToDelimitedBuffer(request));
+
+ response = await _readResponse(messageGrouper);
+ expect(response.exitCode, EXIT_CODE_OK, reason: response.output);
+ expect(response.output, isEmpty);
+ expect(outputJsFile.readAsStringSync(), contains('goodbye world'));
process.kill();
@@ -75,3 +82,14 @@ main() {
});
});
}
+
+Future<WorkResponse> _readResponse(MessageGrouper messageGrouper) async {
+ var buffer = await messageGrouper.next;
+ try {
+ return new WorkResponse.fromBuffer(buffer);
+ } catch (_) {
+ throw 'Failed to parse response: \n'
+ 'bytes: $buffer\n'
+ 'String: ${new String.fromCharCodes(buffer)}\n';
+ }
+}
« no previous file with comments | « test/worker/hello_world.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698