OLD | NEW |
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 }); | 125 }); |
126 | 126 |
127 group('Hello World with Summaries', () { | 127 group('Hello World with Summaries', () { |
128 final greetingDart = new File('test/worker/greeting.dart').absolute; | 128 final greetingDart = new File('test/worker/greeting.dart').absolute; |
129 final helloDart = new File('test/worker/hello.dart').absolute; | 129 final helloDart = new File('test/worker/hello.dart').absolute; |
130 | 130 |
131 final greetingJS = new File('test/worker/greeting.js').absolute; | 131 final greetingJS = new File('test/worker/greeting.js').absolute; |
132 final greetingSummary = new File('test/worker/greeting.api.ds').absolute; | 132 final greetingSummary = new File('test/worker/greeting.api.ds').absolute; |
133 final helloJS = new File('test/worker/hello_world.js').absolute; | 133 final helloJS = new File('test/worker/hello_world.js').absolute; |
134 | 134 |
| 135 final greeting2JS = new File('test/worker/greeting2.js').absolute; |
| 136 final greeting2Summary = new File('test/worker/greeting2.api.ds').absolute; |
| 137 |
135 setUp(() { | 138 setUp(() { |
136 greetingDart.writeAsStringSync('String greeting = "hello";'); | 139 greetingDart.writeAsStringSync('String greeting = "hello";'); |
137 helloDart.writeAsStringSync('import "greeting.dart";' | 140 helloDart.writeAsStringSync('import "greeting.dart";' |
138 'main() => print(greeting);'); | 141 'main() => print(greeting);'); |
139 }); | 142 }); |
140 | 143 |
141 tearDown(() { | 144 tearDown(() { |
142 if (greetingDart.existsSync()) greetingDart.deleteSync(); | 145 if (greetingDart.existsSync()) greetingDart.deleteSync(); |
143 if (helloDart.existsSync()) helloDart.deleteSync(); | 146 if (helloDart.existsSync()) helloDart.deleteSync(); |
144 if (greetingJS.existsSync()) greetingJS.deleteSync(); | 147 if (greetingJS.existsSync()) greetingJS.deleteSync(); |
145 if (greetingSummary.existsSync()) greetingSummary.deleteSync(); | 148 if (greetingSummary.existsSync()) greetingSummary.deleteSync(); |
| 149 if (greeting2JS.existsSync()) greeting2JS.deleteSync(); |
| 150 if (greeting2Summary.existsSync()) greeting2Summary.deleteSync(); |
146 if (helloJS.existsSync()) helloJS.deleteSync(); | 151 if (helloJS.existsSync()) helloJS.deleteSync(); |
147 }); | 152 }); |
148 | 153 |
149 test('can compile in basic mode', () { | 154 test('can compile in basic mode', () { |
150 final dartSdkSummary = new File('lib/sdk/ddc_sdk.sum').absolute; | 155 final dartSdkSummary = new File('lib/sdk/ddc_sdk.sum').absolute; |
151 var result = Process.runSync(Platform.executable, [ | 156 var result = Process.runSync(Platform.executable, [ |
152 'bin/dartdevc.dart', | 157 'bin/dartdevc.dart', |
153 '--summary-extension=api.ds', | 158 '--summary-extension=api.ds', |
154 '--no-source-map', | 159 '--no-source-map', |
155 '--dart-sdk-summary', | 160 '--dart-sdk-summary', |
(...skipping 19 matching lines...) Expand all Loading... |
175 greetingSummary.path, | 180 greetingSummary.path, |
176 '-o', | 181 '-o', |
177 helloJS.path, | 182 helloJS.path, |
178 helloDart.path, | 183 helloDart.path, |
179 ]); | 184 ]); |
180 expect(result.exitCode, EXIT_CODE_OK); | 185 expect(result.exitCode, EXIT_CODE_OK); |
181 expect(result.stdout, isEmpty); | 186 expect(result.stdout, isEmpty); |
182 expect(result.stderr, isEmpty); | 187 expect(result.stderr, isEmpty); |
183 expect(helloJS.existsSync(), isTrue); | 188 expect(helloJS.existsSync(), isTrue); |
184 }); | 189 }); |
| 190 |
| 191 test('reports error on overlapping summaries', () { |
| 192 final dartSdkSummary = new File('lib/sdk/ddc_sdk.sum').absolute; |
| 193 var result = Process.runSync(Platform.executable, [ |
| 194 'bin/dartdevc.dart', |
| 195 '--summary-extension=api.ds', |
| 196 '--no-source-map', |
| 197 '--dart-sdk-summary', |
| 198 dartSdkSummary.path, |
| 199 '-o', |
| 200 greetingJS.path, |
| 201 greetingDart.path, |
| 202 ]); |
| 203 expect(result.exitCode, EXIT_CODE_OK); |
| 204 expect(result.stdout, isEmpty); |
| 205 expect(result.stderr, isEmpty); |
| 206 expect(greetingJS.existsSync(), isTrue); |
| 207 expect(greetingSummary.existsSync(), isTrue); |
| 208 |
| 209 result = Process.runSync(Platform.executable, [ |
| 210 'bin/dartdevc.dart', |
| 211 '--summary-extension=api.ds', |
| 212 '--no-source-map', |
| 213 '--dart-sdk-summary', |
| 214 dartSdkSummary.path, |
| 215 '-o', |
| 216 greeting2JS.path, |
| 217 greetingDart.path, |
| 218 ]); |
| 219 expect(result.exitCode, EXIT_CODE_OK); |
| 220 expect(result.stdout, isEmpty); |
| 221 expect(result.stderr, isEmpty); |
| 222 expect(greeting2JS.existsSync(), isTrue); |
| 223 expect(greeting2Summary.existsSync(), isTrue); |
| 224 |
| 225 result = Process.runSync(Platform.executable, [ |
| 226 'bin/dartdevc.dart', |
| 227 '--no-source-map', |
| 228 '--no-summarize', |
| 229 '--dart-sdk-summary', |
| 230 dartSdkSummary.path, |
| 231 '--summary-extension=api.ds', |
| 232 '-s', |
| 233 greetingSummary.path, |
| 234 '-s', |
| 235 greeting2Summary.path, |
| 236 '-o', |
| 237 helloJS.path, |
| 238 helloDart.path, |
| 239 ]); |
| 240 expect(result.exitCode, 65); |
| 241 expect(result.stdout, contains("conflict")); |
| 242 expect(result.stdout, contains(greetingDart.path)); |
| 243 expect(helloJS.existsSync(), isFalse); |
| 244 }); |
185 }); | 245 }); |
186 | 246 |
187 group('Error handling', () { | 247 group('Error handling', () { |
188 final dartSdkSummary = new File('lib/sdk/ddc_sdk.sum').absolute; | 248 final dartSdkSummary = new File('lib/sdk/ddc_sdk.sum').absolute; |
189 final badFileDart = new File('test/worker/bad.dart').absolute; | 249 final badFileDart = new File('test/worker/bad.dart').absolute; |
190 final badFileJs = new File('test/worker/bad.js').absolute; | 250 final badFileJs = new File('test/worker/bad.js').absolute; |
191 | 251 |
192 tearDown(() { | 252 tearDown(() { |
193 if (badFileDart.existsSync()) badFileDart.deleteSync(); | 253 if (badFileDart.existsSync()) badFileDart.deleteSync(); |
194 if (badFileJs.existsSync()) badFileJs.deleteSync(); | 254 if (badFileJs.existsSync()) badFileJs.deleteSync(); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 Future<WorkResponse> _readResponse(MessageGrouper messageGrouper) async { | 361 Future<WorkResponse> _readResponse(MessageGrouper messageGrouper) async { |
302 var buffer = (await messageGrouper.next) as List<int>; | 362 var buffer = (await messageGrouper.next) as List<int>; |
303 try { | 363 try { |
304 return new WorkResponse.fromBuffer(buffer); | 364 return new WorkResponse.fromBuffer(buffer); |
305 } catch (_) { | 365 } catch (_) { |
306 var bufferAsString = | 366 var bufferAsString = |
307 buffer == null ? '' : 'String: ${UTF8.decode(buffer)}\n'; | 367 buffer == null ? '' : 'String: ${UTF8.decode(buffer)}\n'; |
308 throw 'Failed to parse response:\nbytes: $buffer\n$bufferAsString'; | 368 throw 'Failed to parse response:\nbytes: $buffer\n$bufferAsString'; |
309 } | 369 } |
310 } | 370 } |
OLD | NEW |