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

Side by Side Diff: test/worker/worker_test.dart

Issue 2016483002: Enable strong mode in DDC, fix all warnings/errors (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « test/codegen_test.dart ('k') | tool/analyze.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:bazel_worker/bazel_worker.dart'; 9 import 'package:bazel_worker/bazel_worker.dart';
10 // TODO(jakemac): Remove once this is a part of the testing library. 10 // TODO(jakemac): Remove once this is a part of the testing library.
(...skipping 23 matching lines...) Expand all
34 inputDartFile.writeAsStringSync('main() => print("hello world");'); 34 inputDartFile.writeAsStringSync('main() => print("hello world");');
35 }); 35 });
36 36
37 tearDown(() { 37 tearDown(() {
38 if (inputDartFile.existsSync()) inputDartFile.deleteSync(); 38 if (inputDartFile.existsSync()) inputDartFile.deleteSync();
39 if (outputJsFile.existsSync()) outputJsFile.deleteSync(); 39 if (outputJsFile.existsSync()) outputJsFile.deleteSync();
40 if (argsFile.existsSync()) argsFile.deleteSync(); 40 if (argsFile.existsSync()) argsFile.deleteSync();
41 }); 41 });
42 42
43 test('can compile in worker mode', () async { 43 test('can compile in worker mode', () async {
44 var args = new List.from(executableArgs)..add('--persistent_worker'); 44 var args = executableArgs.toList()..add('--persistent_worker');
45 var process = await Process.start('dart', args); 45 var process = await Process.start('dart', args);
46 var messageGrouper = new AsyncMessageGrouper(process.stdout); 46 var messageGrouper = new AsyncMessageGrouper(process.stdout);
47 47
48 var request = new WorkRequest(); 48 var request = new WorkRequest();
49 request.arguments.addAll(compilerArgs); 49 request.arguments.addAll(compilerArgs);
50 process.stdin.add(protoToDelimitedBuffer(request)); 50 process.stdin.add(protoToDelimitedBuffer(request));
51 51
52 var response = await _readResponse(messageGrouper); 52 var response = await _readResponse(messageGrouper);
53 expect(response.exitCode, EXIT_CODE_OK, reason: response.output); 53 expect(response.exitCode, EXIT_CODE_OK, reason: response.output);
54 expect(response.output, isEmpty); 54 expect(response.output, isEmpty);
(...skipping 11 matching lines...) Expand all
66 expect(outputJsFile.readAsStringSync(), contains('goodbye world')); 66 expect(outputJsFile.readAsStringSync(), contains('goodbye world'));
67 67
68 process.kill(); 68 process.kill();
69 69
70 // TODO(jakemac): This shouldn't be necessary, but it is for the process 70 // TODO(jakemac): This shouldn't be necessary, but it is for the process
71 // to exit properly. 71 // to exit properly.
72 expect(await messageGrouper.next, isNull); 72 expect(await messageGrouper.next, isNull);
73 }); 73 });
74 74
75 test('can compile in basic mode', () { 75 test('can compile in basic mode', () {
76 var args = new List.from(executableArgs)..addAll(compilerArgs); 76 var args = executableArgs.toList()..addAll(compilerArgs);
77 var result = Process.runSync('dart', args); 77 var result = Process.runSync('dart', args);
78 78
79 expect(result.exitCode, EXIT_CODE_OK); 79 expect(result.exitCode, EXIT_CODE_OK);
80 expect(result.stdout, isEmpty); 80 expect(result.stdout, isEmpty);
81 expect(result.stderr, isEmpty); 81 expect(result.stderr, isEmpty);
82 expect(outputJsFile.existsSync(), isTrue); 82 expect(outputJsFile.existsSync(), isTrue);
83 }); 83 });
84 84
85 test('can compile in basic mode with args in a file', () async { 85 test('can compile in basic mode with args in a file', () async {
86 argsFile.createSync(); 86 argsFile.createSync();
87 argsFile.writeAsStringSync(compilerArgs.join('\n')); 87 argsFile.writeAsStringSync(compilerArgs.join('\n'));
88 var args = new List.from(executableArgs)..add('@${argsFile.path}'); 88 var args = executableArgs.toList()..add('@${argsFile.path}');
89 var process = await Process.start('dart', args); 89 var process = await Process.start('dart', args);
90 stderr.addStream(process.stderr); 90 stderr.addStream(process.stderr);
91 var futureProcessOutput = process.stdout.map(UTF8.decode).toList(); 91 var futureProcessOutput = process.stdout.map(UTF8.decode).toList();
92 92
93 expect(await process.exitCode, EXIT_CODE_OK); 93 expect(await process.exitCode, EXIT_CODE_OK);
94 expect((await futureProcessOutput).join(), isEmpty); 94 expect((await futureProcessOutput).join(), isEmpty);
95 expect(outputJsFile.existsSync(), isTrue); 95 expect(outputJsFile.existsSync(), isTrue);
96 }); 96 });
97 }); 97 });
98 98
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 startsWith('[warning] ${unusedPartWarningCode.message} ' 253 startsWith('[warning] ${unusedPartWarningCode.message} '
254 '(test/worker/greeting.dart, line 1, col 1)')); 254 '(test/worker/greeting.dart, line 1, col 1)'));
255 expect(result.stderr, isEmpty); 255 expect(result.stderr, isEmpty);
256 expect(result.exitCode, 0); 256 expect(result.exitCode, 0);
257 expect(outJS.existsSync(), isTrue); 257 expect(outJS.existsSync(), isTrue);
258 }); 258 });
259 }); 259 });
260 } 260 }
261 261
262 Future<WorkResponse> _readResponse(MessageGrouper messageGrouper) async { 262 Future<WorkResponse> _readResponse(MessageGrouper messageGrouper) async {
263 var buffer = await messageGrouper.next; 263 var buffer = (await messageGrouper.next) as List<int>;
264 try { 264 try {
265 return new WorkResponse.fromBuffer(buffer); 265 return new WorkResponse.fromBuffer(buffer);
266 } catch (_) { 266 } catch (_) {
267 var bufferAsString = 267 var bufferAsString =
268 buffer == null ? '' : 'String: ${UTF8.decode(buffer)}\n'; 268 buffer == null ? '' : 'String: ${UTF8.decode(buffer)}\n';
269 throw 'Failed to parse response:\nbytes: $buffer\n$bufferAsString'; 269 throw 'Failed to parse response:\nbytes: $buffer\n$bufferAsString';
270 } 270 }
271 } 271 }
OLDNEW
« no previous file with comments | « test/codegen_test.dart ('k') | tool/analyze.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698