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

Unified Diff: test/worker/worker_test.dart

Issue 1884073003: Add bazel worker support to the dev compiler. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: code review updates 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') | tool/command_test.sh » ('j') | 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
new file mode 100644
index 0000000000000000000000000000000000000000..80ee1fb40199830708a442a8ac796d9c57a3f235
--- /dev/null
+++ b/test/worker/worker_test.dart
@@ -0,0 +1,77 @@
+// 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:convert';
+import 'dart:io';
+
+import 'package:bazel_worker/bazel_worker.dart';
+// TODO(jakemac): Remove once this is a part of the testing library.
+import 'package:bazel_worker/src/async_message_grouper.dart';
+import 'package:bazel_worker/testing.dart';
+import 'package:test/test.dart';
+
+main() {
+ group('Hello World', () {
+ final inputDartFile = new File('test/worker/hello_world.dart').absolute;
+ final outputJsFile = new File('test/worker/hello_world.js').absolute;
+ final executableArgs = [
+ 'bin/dartdevc.dart',
+ 'compile',
+ ];
+ final compilerArgs = [
+ '--no-source-map',
+ '--no-summarize',
+ '-o',
+ outputJsFile.path,
+ inputDartFile.path,
+ ];
+
+ tearDown(() {
+ if (outputJsFile.existsSync()) outputJsFile.deleteSync();
+ });
+
+ test('can compile in worker mode', () async {
+ var args = new List.from(executableArgs)..add('--persistent_worker');
+ var process = await Process.start('dart', args);
+ var messageGrouper = new AsyncMessageGrouper(process.stdout);
+
+ 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';
+ }
+
+ expect(response.exitCode, EXIT_CODE_OK, reason: response.output);
+ expect(response.output, isEmpty);
+
+ expect(outputJsFile.existsSync(), isTrue);
+
+ process.kill();
+
+ // TODO(jakemac): This shouldn't be necessary, but it is for the process
+ // to exit properly.
+ expect(await messageGrouper.next, isNull);
+ });
+
+ test('can compile in basic mode', () async {
+ var args = new List.from(executableArgs)..addAll(compilerArgs);
+ var process = await Process.start('dart', args);
+ stderr.addStream(process.stderr);
+ var futureProcessOutput = process.stdout.map(UTF8.decode).toList();
+
+ expect(await process.exitCode, EXIT_CODE_OK);
+ expect((await futureProcessOutput).join(), isEmpty);
+ expect(outputJsFile.existsSync(), isTrue);
+ });
+ });
+}
« no previous file with comments | « test/worker/hello_world.dart ('k') | tool/command_test.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698