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 library dart2js.serialization_compilation_test; | 5 library dart2js.serialization_compilation_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
9 import 'package:compiler/src/compiler.dart'; | 9 import 'package:compiler/src/compiler.dart'; |
10 import 'package:compiler/src/filenames.dart'; | 10 import 'package:compiler/src/filenames.dart'; |
11 import '../memory_compiler.dart'; | 11 import '../memory_compiler.dart'; |
12 import 'helper.dart'; | 12 import 'helper.dart'; |
13 import 'test_data.dart'; | 13 import 'test_data.dart'; |
14 import '../output_collector.dart'; | 14 import '../output_collector.dart'; |
15 | 15 |
16 main(List<String> args) { | 16 main(List<String> args) { |
17 asyncTest(() async { | 17 asyncTest(() async { |
18 Arguments arguments = new Arguments.from(args); | 18 Arguments arguments = new Arguments.from(args); |
19 String serializedData = await serializeDartCore(arguments: arguments); | 19 SerializedData serializedData = |
| 20 await serializeDartCore(arguments: arguments); |
20 if (arguments.filename != null) { | 21 if (arguments.filename != null) { |
21 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename)); | 22 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename)); |
22 await compile(serializedData, entryPoint, null); | 23 await compile(serializedData, entryPoint, null); |
23 } else { | 24 } else { |
24 Uri entryPoint = Uri.parse('memory:main.dart'); | 25 Uri entryPoint = Uri.parse('memory:main.dart'); |
25 await arguments.forEachTest(TESTS, (int index, Test test) async { | 26 await arguments.forEachTest(TESTS, (int index, Test test) async { |
26 await compile(serializedData, entryPoint, test, | 27 await compile(serializedData, entryPoint, test, |
27 index: index, | 28 index: index, |
28 verbose: arguments.verbose); | 29 verbose: arguments.verbose); |
29 }); | 30 }); |
30 } | 31 } |
31 }); | 32 }); |
32 } | 33 } |
33 | 34 |
34 Future compile(String serializedData, Uri entryPoint, Test test, | 35 Future compile(SerializedData serializedData, Uri entryPoint, Test test, |
35 {int index, bool verbose: false}) async { | 36 {int index, bool verbose: false}) async { |
36 String testDescription = | 37 String testDescription = |
37 test != null ? test.sourceFiles[entryPoint.path] : '${entryPoint}'; | 38 test != null ? test.sourceFiles[entryPoint.path] : '${entryPoint}'; |
38 print('------------------------------------------------------------------'); | 39 print('------------------------------------------------------------------'); |
39 print('compile ${index != null ? '$index:' :''}${testDescription}'); | 40 print('compile ${index != null ? '$index:' :''}${testDescription}'); |
40 print('------------------------------------------------------------------'); | 41 print('------------------------------------------------------------------'); |
41 OutputCollector outputCollector = new OutputCollector(); | 42 OutputCollector outputCollector = new OutputCollector(); |
42 await runCompiler( | 43 await runCompiler( |
43 entryPoint: entryPoint, | 44 entryPoint: entryPoint, |
44 memorySourceFiles: test != null ? test.sourceFiles : const {}, | 45 resolutionInputs: serializedData.toUris(), |
| 46 memorySourceFiles: serializedData.toMemorySourceFiles( |
| 47 test != null ? test.sourceFiles : null), |
45 options: [], | 48 options: [], |
46 outputProvider: outputCollector, | 49 outputProvider: outputCollector); |
47 beforeRun: (Compiler compiler) { | |
48 compiler.serialization.deserializeFromText(serializedData); | |
49 }); | |
50 if (verbose) { | 50 if (verbose) { |
51 print(outputCollector.getOutput('', 'js')); | 51 print(outputCollector.getOutput('', 'js')); |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
OLD | NEW |