OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 // Helper to test compilation equivalence between source and .dill based | 5 // Helper to test compilation equivalence between source and .dill based |
6 // compilation. | 6 // compilation. |
7 library dart2js.kernel.compile_from_dill_test_helper; | 7 library dart2js.kernel.compile_from_dill_test_helper; |
8 | 8 |
9 import 'dart:async'; | 9 import 'dart:async'; |
10 import 'dart:io'; | |
11 | 10 |
12 import 'package:compiler/compiler_new.dart'; | 11 import 'package:compiler/compiler_new.dart'; |
13 import 'package:compiler/src/commandline_options.dart'; | 12 import 'package:compiler/src/commandline_options.dart'; |
14 import 'package:compiler/src/common.dart'; | 13 import 'package:compiler/src/common.dart'; |
15 import 'package:compiler/src/compiler.dart'; | 14 import 'package:compiler/src/compiler.dart'; |
16 import 'package:compiler/src/elements/elements.dart'; | 15 import 'package:compiler/src/elements/elements.dart'; |
17 import 'package:compiler/src/elements/types.dart'; | 16 import 'package:compiler/src/elements/types.dart'; |
18 import 'package:compiler/src/kernel/element_map.dart'; | 17 import 'package:compiler/src/kernel/element_map.dart'; |
19 import 'package:compiler/src/kernel/kernel_backend_strategy.dart'; | 18 import 'package:compiler/src/kernel/kernel_backend_strategy.dart'; |
20 import 'package:compiler/src/kernel/kernel_strategy.dart'; | 19 import 'package:compiler/src/kernel/kernel_strategy.dart'; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 {bool skipWarnings: false, | 220 {bool skipWarnings: false, |
222 bool skipErrors: false, | 221 bool skipErrors: false, |
223 bool verbose: false, | 222 bool verbose: false, |
224 List<String> options: const <String>[], | 223 List<String> options: const <String>[], |
225 bool expectAstEquivalence: false, | 224 bool expectAstEquivalence: false, |
226 bool expectIdenticalOutput: true}) async { | 225 bool expectIdenticalOutput: true}) async { |
227 enableDebugMode(); | 226 enableDebugMode(); |
228 EnumCreator.matchKernelRepresentationForTesting = true; | 227 EnumCreator.matchKernelRepresentationForTesting = true; |
229 Elements.usePatchedDart2jsSdkSorting = true; | 228 Elements.usePatchedDart2jsSdkSorting = true; |
230 | 229 |
231 Directory dir = await Directory.systemTemp.createTemp('dart2js-with-dill'); | 230 entryPoint = |
232 print('--- create temp directory $dir -------------------------------'); | 231 await createTemp(entryPoint, memorySourceFiles, printSteps: true); |
233 memorySourceFiles.forEach((String name, String source) { | |
234 new File.fromUri(dir.uri.resolve(name)).writeAsStringSync(source); | |
235 }); | |
236 entryPoint = dir.uri.resolve(entryPoint.path); | |
237 | 232 |
238 print('---- compile from ast ----------------------------------------------'); | 233 print('---- compile from ast ----------------------------------------------'); |
239 DiagnosticCollector collector = new DiagnosticCollector(); | 234 DiagnosticCollector collector = new DiagnosticCollector(); |
240 OutputCollector collector1 = new OutputCollector(); | 235 OutputCollector collector1 = new OutputCollector(); |
241 Compiler compiler1 = compilerFor( | 236 Compiler compiler1 = compilerFor( |
242 entryPoint: entryPoint, | 237 entryPoint: entryPoint, |
243 diagnosticHandler: collector, | 238 diagnosticHandler: collector, |
244 outputProvider: collector1, | 239 outputProvider: collector1, |
245 options: <String>[]..addAll(commonOptions)..addAll(options)); | 240 options: <String>[]..addAll(commonOptions)..addAll(options)); |
246 ElementResolutionWorldBuilder.useInstantiationMap = true; | 241 ElementResolutionWorldBuilder.useInstantiationMap = true; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 Map<String, BufferedOutputSink> map2 = collector2.outputMap[outputType]; | 335 Map<String, BufferedOutputSink> map2 = collector2.outputMap[outputType]; |
341 checkSets(map1.keys, map2.keys, 'output', equality); | 336 checkSets(map1.keys, map2.keys, 'output', equality); |
342 map1.forEach((String name, BufferedOutputSink output1) { | 337 map1.forEach((String name, BufferedOutputSink output1) { |
343 BufferedOutputSink output2 = map2[name]; | 338 BufferedOutputSink output2 = map2[name]; |
344 Expect.stringEquals(output1.text, output2.text); | 339 Expect.stringEquals(output1.text, output2.text); |
345 }); | 340 }); |
346 }); | 341 }); |
347 } | 342 } |
348 return ResultKind.success; | 343 return ResultKind.success; |
349 } | 344 } |
OLD | NEW |