| 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 String serializedData = await serializeDartCore(arguments: arguments); |
| 20 if (arguments.filename != null) { | 20 if (arguments.filename != null) { |
| 21 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename)); | 21 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename)); |
| 22 await compile(serializedData, entryPoint, null); | 22 await compile(serializedData, entryPoint, null); |
| 23 } else { | 23 } else { |
| 24 Uri entryPoint = Uri.parse('memory:main.dart'); | 24 Uri entryPoint = Uri.parse('memory:main.dart'); |
| 25 arguments.forEachTest(TESTS, (int index, Test test) async { | 25 await arguments.forEachTest(TESTS, (int index, Test test) async { |
| 26 await compile(serializedData, entryPoint, test, | 26 await compile(serializedData, entryPoint, test, |
| 27 index: index, | 27 index: index, |
| 28 verbose: arguments.verbose); | 28 verbose: arguments.verbose); |
| 29 }); | 29 }); |
| 30 } | 30 } |
| 31 }); | 31 }); |
| 32 } | 32 } |
| 33 | 33 |
| 34 Future compile(String serializedData, Uri entryPoint, Test test, | 34 Future compile(String serializedData, Uri entryPoint, Test test, |
| 35 {int index, bool verbose: false}) async { | 35 {int index, bool verbose: false}) async { |
| 36 String testDescription = | 36 String testDescription = |
| 37 test != null ? test.sourceFiles[entryPoint.path] : '${entryPoint}'; | 37 test != null ? test.sourceFiles[entryPoint.path] : '${entryPoint}'; |
| 38 print('------------------------------------------------------------------'); | 38 print('------------------------------------------------------------------'); |
| 39 print('compile ${index != null ? '$index:' :''}${testDescription}'); | 39 print('compile ${index != null ? '$index:' :''}${testDescription}'); |
| 40 print('------------------------------------------------------------------'); | 40 print('------------------------------------------------------------------'); |
| 41 OutputCollector outputCollector = new OutputCollector(); | 41 OutputCollector outputCollector = new OutputCollector(); |
| 42 await runCompiler( | 42 await runCompiler( |
| 43 entryPoint: entryPoint, | 43 entryPoint: entryPoint, |
| 44 memorySourceFiles: test != null ? test.sourceFiles : const {}, | 44 memorySourceFiles: test != null ? test.sourceFiles : const {}, |
| 45 options: [], | 45 options: [], |
| 46 outputProvider: outputCollector, | 46 outputProvider: outputCollector, |
| 47 beforeRun: (Compiler compiler) { | 47 beforeRun: (Compiler compiler) { |
| 48 compiler.serialization.deserializeFromText(serializedData); | 48 compiler.serialization.deserializeFromText(serializedData); |
| 49 }); | 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 |