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_impact_test; | 5 library dart2js.serialization_impact_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/common/resolution.dart'; | 10 import 'package:compiler/src/common/resolution.dart'; |
11 import 'package:compiler/src/compiler.dart'; | 11 import 'package:compiler/src/compiler.dart'; |
12 import 'package:compiler/src/elements/elements.dart'; | 12 import 'package:compiler/src/elements/elements.dart'; |
13 import 'package:compiler/src/filenames.dart'; | 13 import 'package:compiler/src/filenames.dart'; |
14 import 'package:compiler/src/serialization/equivalence.dart'; | 14 import 'package:compiler/src/serialization/equivalence.dart'; |
15 import 'memory_compiler.dart'; | 15 import 'memory_compiler.dart'; |
16 import 'serialization_helper.dart'; | 16 import 'serialization_helper.dart'; |
17 import 'serialization_test_helper.dart'; | 17 import 'serialization_test_helper.dart'; |
18 | 18 |
19 main(List<String> arguments) { | 19 main(List<String> args) { |
| 20 Arguments arguments = new Arguments.from(args); |
20 asyncTest(() async { | 21 asyncTest(() async { |
21 String serializedData = await serializeDartCore(); | 22 String serializedData = await serializeDartCore(arguments: arguments); |
22 if (arguments.isNotEmpty) { | 23 if (arguments.filename != null) { |
23 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.last)); | 24 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename)); |
24 await check(serializedData, entryPoint); | 25 await check(serializedData, entryPoint); |
25 } else { | 26 } else { |
26 Uri entryPoint = Uri.parse('memory:main.dart'); | 27 Uri entryPoint = Uri.parse('memory:main.dart'); |
27 await check(serializedData, entryPoint, {'main.dart': 'main() {}'}); | 28 await check(serializedData, entryPoint, |
| 29 sourceFiles: {'main.dart': 'main() {}'}, |
| 30 verbose: arguments.verbose); |
28 } | 31 } |
29 }); | 32 }); |
30 } | 33 } |
31 | 34 |
32 Future check( | 35 Future check( |
33 String serializedData, | 36 String serializedData, |
34 Uri entryPoint, | 37 Uri entryPoint, |
35 [Map<String, String> sourceFiles = const <String, String>{}]) async { | 38 {Map<String, String> sourceFiles: const <String, String>{}, |
| 39 bool verbose: false}) async { |
36 | 40 |
37 Compiler compilerNormal = compilerFor( | 41 Compiler compilerNormal = compilerFor( |
38 memorySourceFiles: sourceFiles, | 42 memorySourceFiles: sourceFiles, |
39 options: [Flags.analyzeOnly]); | 43 options: [Flags.analyzeAll]); |
40 compilerNormal.resolution.retainCachesForTesting = true; | 44 compilerNormal.resolution.retainCachesForTesting = true; |
41 await compilerNormal.run(entryPoint); | 45 await compilerNormal.run(entryPoint); |
42 | 46 |
43 Compiler compilerDeserialized = compilerFor( | 47 Compiler compilerDeserialized = compilerFor( |
44 memorySourceFiles: sourceFiles, | 48 memorySourceFiles: sourceFiles, |
45 options: [Flags.analyzeOnly]); | 49 options: [Flags.analyzeAll]); |
46 compilerDeserialized.resolution.retainCachesForTesting = true; | 50 compilerDeserialized.resolution.retainCachesForTesting = true; |
47 deserialize(compilerDeserialized, serializedData); | 51 deserialize(compilerDeserialized, serializedData); |
48 await compilerDeserialized.run(entryPoint); | 52 await compilerDeserialized.run(entryPoint); |
49 | 53 |
50 checkAllImpacts(compilerNormal, compilerDeserialized, verbose: true); | 54 checkAllImpacts(compilerNormal, compilerDeserialized, verbose: verbose); |
51 } | 55 } |
OLD | NEW |