Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016, 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 import 'dart:convert'; | |
| 6 import 'dart:io'; | |
| 7 | |
| 8 import 'package:bazel_worker/bazel_worker.dart'; | |
| 9 // TODO(jakemac): Remove once this is a part of the testing library. | |
| 10 import 'package:bazel_worker/src/async_message_grouper.dart'; | |
| 11 import 'package:bazel_worker/testing.dart'; | |
| 12 import 'package:test/test.dart'; | |
| 13 | |
| 14 main() { | |
| 15 group('Hello World', () { | |
| 16 final inputDartFile = new File('test/worker/hello_world.dart').absolute; | |
| 17 final outputJsFile = new File('test/worker/hello_world.js').absolute; | |
| 18 final executableArgs = [ | |
| 19 'bin/dartdevc.dart', | |
| 20 'compile', | |
| 21 ]; | |
| 22 final compilerArgs = [ | |
| 23 '--no-source-map', | |
| 24 '--no-summarize', | |
| 25 '-o', | |
| 26 outputJsFile.path, | |
| 27 inputDartFile.path, | |
| 28 ]; | |
| 29 | |
| 30 tearDown(() { | |
| 31 if (outputJsFile.existsSync()) outputJsFile.deleteSync(); | |
| 32 }); | |
| 33 | |
| 34 test('can compile in worker mode', () async { | |
| 35 var args = new List.from(executableArgs)..add('--persistent_worker'); | |
| 36 var process = await Process.start('dart', args); | |
| 37 var messageGrouper = new AsyncMessageGrouper(process.stdout); | |
| 38 | |
| 39 var request = new WorkRequest(); | |
| 40 request.arguments.addAll(compilerArgs); | |
| 41 | |
| 42 process.stdin.add(protoToDelimitedBuffer(request)); | |
| 43 | |
| 44 var buffer = await messageGrouper.next; | |
| 45 WorkResponse response; | |
| 46 try { | |
| 47 response = new WorkResponse.fromBuffer(buffer); | |
| 48 } catch (_) { | |
| 49 throw 'Failed to parse response: \n' | |
| 50 'bytes: $buffer\n' | |
| 51 'String: ${new String.fromCharCodes(buffer)}\n'; | |
| 52 } | |
| 53 | |
| 54 expect(response.exitCode, EXIT_CODE_OK, reason: response.output); | |
| 55 expect(response.output, isEmpty); | |
| 56 | |
| 57 expect(outputJsFile.existsSync(), isTrue); | |
| 58 | |
| 59 process.kill(); | |
| 60 | |
| 61 // TODO(jakemac): This shouldn't be necessary, but it is for the process | |
| 62 // to exit properly. | |
| 63 await messageGrouper.next; | |
| 64 }); | |
| 65 | |
| 66 test('can compile in basic mode', () async { | |
|
Jennifer Messerly
2016/04/14 21:02:15
If you don't mind, delete my little command_test.s
jakemac
2016/04/14 21:48:25
Done.
| |
| 67 var args = new List.from(executableArgs)..addAll(compilerArgs); | |
| 68 var process = await Process.start('dart', args); | |
| 69 stderr.addStream(process.stderr); | |
| 70 var futureProcessOutput = process.stdout.map(UTF8.decode).toList(); | |
| 71 | |
| 72 expect(await process.exitCode, EXIT_CODE_OK); | |
| 73 expect((await futureProcessOutput).join(), isEmpty); | |
| 74 expect(outputJsFile.existsSync(), isTrue); | |
| 75 }); | |
| 76 }); | |
| 77 } | |
| OLD | NEW |