| 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'; |
| 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 /// Number of tests that are not part of the automatic test grouping. | 16 /// Number of tests that are not part of the automatic test grouping. |
| 17 int SKIP_COUNT = 2; | 17 int SKIP_COUNT = 2; |
| 18 | 18 |
| 19 /// Number of groups that the [TESTS] are split into. | 19 /// Number of groups that the [TESTS] are split into. |
| 20 int SPLIT_COUNT = 5; | 20 int SPLIT_COUNT = 5; |
| 21 | 21 |
| 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, |
| 30 memorySourceFiles: serializedData.toMemorySourceFiles(), |
| 31 resolutionInputs: serializedData.toUris()); |
| 29 await compile( | 32 await compile( |
| 30 entryPoint, | 33 entryPoint, |
| 31 resolutionInputs: serializedData.toUris(), | 34 resolutionInputs: result.serializedData.toUris(), |
| 32 sourceFiles: serializedData.toMemorySourceFiles()); | 35 sourceFiles: result.serializedData.toMemorySourceFiles()); |
| 33 } else { | 36 } else { |
| 34 Uri entryPoint = Uri.parse('memory:main.dart'); | 37 Uri entryPoint = Uri.parse('memory:main.dart'); |
| 35 await arguments.forEachTest(serializedData, TESTS, compile); | 38 await arguments.forEachTest(serializedData, TESTS, compile); |
| 36 } | 39 } |
| 37 printMeasurementResults(); | 40 printMeasurementResults(); |
| 38 }); | 41 }); |
| 39 } | 42 } |
| 40 | 43 |
| 41 Future compile( | 44 Future compile( |
| 42 Uri entryPoint, | 45 Uri entryPoint, |
| 43 {Map<String, String> sourceFiles: const <String, String>{}, | 46 {Map<String, String> sourceFiles: const <String, String>{}, |
| 44 List<Uri> resolutionInputs, | 47 List<Uri> resolutionInputs, |
| 45 int index, | 48 int index, |
| 46 Test test, | 49 Test test, |
| 47 bool verbose: false}) async { | 50 bool verbose: false}) async { |
| 48 String testDescription = test != null ? test.name : '${entryPoint}'; | 51 String testDescription = test != null ? test.name : '${entryPoint}'; |
| 49 String id = index != null ? '$index: ' : ''; | 52 String id = index != null ? '$index: ' : ''; |
| 50 String title = '${id}${testDescription}'; | 53 String title = '${id}${testDescription}'; |
| 51 OutputCollector outputCollector = new OutputCollector(); | 54 OutputCollector outputCollector = new OutputCollector(); |
| 52 await measure(title, 'compile', () async { | 55 await measure(title, 'compile', () async { |
| 53 List<String> options = []; | 56 List<String> options = []; |
| 54 if (test.checkedMode) { | 57 if (test != null && test.checkedMode) { |
| 55 options.add(Flags.enableCheckedMode); | 58 options.add(Flags.enableCheckedMode); |
| 56 } | 59 } |
| 57 await runCompiler( | 60 await runCompiler( |
| 58 entryPoint: entryPoint, | 61 entryPoint: entryPoint, |
| 59 memorySourceFiles: sourceFiles, | 62 memorySourceFiles: sourceFiles, |
| 60 resolutionInputs: resolutionInputs, | 63 resolutionInputs: resolutionInputs, |
| 61 options: options, | 64 options: options, |
| 62 outputProvider: outputCollector); | 65 outputProvider: outputCollector); |
| 63 }); | 66 }); |
| 64 if (verbose) { | 67 if (verbose) { |
| 65 print(outputCollector.getOutput('', 'js')); | 68 print(outputCollector.getOutput('', 'js')); |
| 66 } | 69 } |
| 67 } | 70 } |
| 68 | 71 |
| OLD | NEW |