| 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/commandline_options.dart'; | 9 import 'package:compiler/src/commandline_options.dart'; |
| 10 import 'package:compiler/src/filenames.dart'; | 10 import 'package:compiler/src/filenames.dart'; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 main(List<String> args) { | 22 main(List<String> args) { |
| 23 asyncTest(() async { | 23 asyncTest(() async { |
| 24 Arguments arguments = new Arguments.from(args); | 24 Arguments arguments = new Arguments.from(args); |
| 25 SerializedData serializedData = | 25 SerializedData serializedData = |
| 26 await serializeDartCore(arguments: arguments); | 26 await serializeDartCore(arguments: arguments); |
| 27 if (arguments.filename != null) { | 27 if (arguments.filename != null) { |
| 28 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename)); | 28 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename)); |
| 29 SerializationResult result = await serialize(entryPoint, | 29 SerializationResult result = await serialize(entryPoint, |
| 30 memorySourceFiles: serializedData.toMemorySourceFiles(), | 30 memorySourceFiles: serializedData.toMemorySourceFiles(), |
| 31 resolutionInputs: serializedData.toUris()); | 31 resolutionInputs: serializedData.toUris()); |
| 32 await compile( | 32 await compile(entryPoint, |
| 33 entryPoint, | |
| 34 resolutionInputs: result.serializedData.toUris(), | 33 resolutionInputs: result.serializedData.toUris(), |
| 35 sourceFiles: result.serializedData.toMemorySourceFiles()); | 34 sourceFiles: result.serializedData.toMemorySourceFiles()); |
| 36 } else { | 35 } else { |
| 37 Uri entryPoint = Uri.parse('memory:main.dart'); | 36 Uri entryPoint = Uri.parse('memory:main.dart'); |
| 38 await arguments.forEachTest(serializedData, TESTS, compile); | 37 await arguments.forEachTest(serializedData, TESTS, compile); |
| 39 } | 38 } |
| 40 printMeasurementResults(); | 39 printMeasurementResults(); |
| 41 }); | 40 }); |
| 42 } | 41 } |
| 43 | 42 |
| 44 Future compile( | 43 Future compile(Uri entryPoint, |
| 45 Uri entryPoint, | |
| 46 {Map<String, String> sourceFiles: const <String, String>{}, | 44 {Map<String, String> sourceFiles: const <String, String>{}, |
| 47 List<Uri> resolutionInputs, | 45 List<Uri> resolutionInputs, |
| 48 int index, | 46 int index, |
| 49 Test test, | 47 Test test, |
| 50 bool verbose: false}) async { | 48 bool verbose: false}) async { |
| 51 String testDescription = test != null ? test.name : '${entryPoint}'; | 49 String testDescription = test != null ? test.name : '${entryPoint}'; |
| 52 String id = index != null ? '$index: ' : ''; | 50 String id = index != null ? '$index: ' : ''; |
| 53 String title = '${id}${testDescription}'; | 51 String title = '${id}${testDescription}'; |
| 54 OutputCollector outputCollector = new OutputCollector(); | 52 OutputCollector outputCollector = new OutputCollector(); |
| 55 await measure(title, 'compile', () async { | 53 await measure(title, 'compile', () async { |
| 56 List<String> options = []; | 54 List<String> options = []; |
| 57 if (test != null && test.checkedMode) { | 55 if (test != null && test.checkedMode) { |
| 58 options.add(Flags.enableCheckedMode); | 56 options.add(Flags.enableCheckedMode); |
| 59 } | 57 } |
| 60 await runCompiler( | 58 await runCompiler( |
| 61 entryPoint: entryPoint, | 59 entryPoint: entryPoint, |
| 62 memorySourceFiles: sourceFiles, | 60 memorySourceFiles: sourceFiles, |
| 63 resolutionInputs: resolutionInputs, | 61 resolutionInputs: resolutionInputs, |
| 64 options: options, | 62 options: options, |
| 65 outputProvider: outputCollector); | 63 outputProvider: outputCollector); |
| 66 }); | 64 }); |
| 67 if (verbose) { | 65 if (verbose) { |
| 68 print(outputCollector.getOutput('', 'js')); | 66 print(outputCollector.getOutput('', 'js')); |
| 69 } | 67 } |
| 70 } | 68 } |
| 71 | |
| OLD | NEW |