OLD | NEW |
---|---|
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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_model_test; | 5 library dart2js.serialization_model_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'package:async_helper/async_helper.dart'; | 9 import 'package:async_helper/async_helper.dart'; |
10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
(...skipping 10 matching lines...) Expand all Loading... | |
21 import 'test_data.dart'; | 21 import 'test_data.dart'; |
22 import 'test_helper.dart'; | 22 import 'test_helper.dart'; |
23 | 23 |
24 main(List<String> args) { | 24 main(List<String> args) { |
25 asyncTest(() async { | 25 asyncTest(() async { |
26 Arguments arguments = new Arguments.from(args); | 26 Arguments arguments = new Arguments.from(args); |
27 SerializedData serializedData = | 27 SerializedData serializedData = |
28 await serializeDartCore(arguments: arguments); | 28 await serializeDartCore(arguments: arguments); |
29 if (arguments.filename != null) { | 29 if (arguments.filename != null) { |
30 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename)); | 30 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename)); |
31 await checkModels(serializedData, entryPoint); | 31 await checkModels(entryPoint, |
32 sourceFiles: serializedData.toMemorySourceFiles(), | |
33 resolutionInputs: serializedData.toUris()); | |
32 } else { | 34 } else { |
33 Uri entryPoint = Uri.parse('memory:main.dart'); | 35 Uri entryPoint = Uri.parse('memory:main.dart'); |
34 arguments.forEachTest(TESTS, (int index, Test test) async { | 36 arguments.forEachTest(serializedData, TESTS, checkModels); |
35 print('=============================================================='); | |
36 print(test.sourceFiles); | |
37 await checkModels( | |
38 serializedData, | |
39 entryPoint, | |
40 memorySourceFiles: test.sourceFiles, | |
41 verbose: arguments.verbose); | |
42 }); | |
43 } | 37 } |
44 }); | 38 }); |
45 } | 39 } |
46 | 40 |
47 Future checkModels( | 41 Future checkModels( |
48 SerializedData serializedData, | |
49 Uri entryPoint, | 42 Uri entryPoint, |
50 {Map<String, String> memorySourceFiles: const <String, String>{}, | 43 {Map<String, String> sourceFiles: const <String, String>{}, |
51 bool verbose: false}) async { | 44 List<Uri> resolutionInputs, |
45 int index, | |
46 Test test, | |
47 bool verbose: false}) async { | |
52 | 48 |
49 String testDescription = | |
50 test != null ? test.name : '${entryPoint}'; | |
53 print('------------------------------------------------------------------'); | 51 print('------------------------------------------------------------------'); |
54 print('compile normal'); | 52 print('compile normal ${index != null ? '$index: ' :''}${testDescription}'); |
Siggi Cherem (dart-lang)
2016/05/25 17:24:32
maybe define
String id = index ?? ''; (or index =
Johnni Winther
2016/05/26 10:56:37
Done.
| |
55 print('------------------------------------------------------------------'); | 53 print('------------------------------------------------------------------'); |
56 Compiler compilerNormal = compilerFor( | 54 Compiler compilerNormal = compilerFor( |
57 memorySourceFiles: memorySourceFiles, | 55 memorySourceFiles: sourceFiles, |
58 options: [Flags.analyzeOnly]); | 56 options: [Flags.analyzeOnly]); |
59 compilerNormal.resolution.retainCachesForTesting = true; | 57 compilerNormal.resolution.retainCachesForTesting = true; |
60 await compilerNormal.run(entryPoint); | 58 await compilerNormal.run(entryPoint); |
61 compilerNormal.phase = Compiler.PHASE_DONE_RESOLVING; | 59 compilerNormal.phase = Compiler.PHASE_DONE_RESOLVING; |
62 compilerNormal.world.populate(); | 60 compilerNormal.world.populate(); |
63 compilerNormal.backend.onResolutionComplete(); | 61 compilerNormal.backend.onResolutionComplete(); |
64 | 62 |
65 print('------------------------------------------------------------------'); | 63 print('------------------------------------------------------------------'); |
66 print('compile deserialized'); | 64 print('compile deserialized ' |
65 '${index != null ? '$index: ' :''}${testDescription}'); | |
67 print('------------------------------------------------------------------'); | 66 print('------------------------------------------------------------------'); |
68 Compiler compilerDeserialized = compilerFor( | 67 Compiler compilerDeserialized = compilerFor( |
69 memorySourceFiles: serializedData.toMemorySourceFiles(memorySourceFiles), | 68 memorySourceFiles: sourceFiles, |
70 resolutionInputs: serializedData.toUris(), | 69 resolutionInputs: resolutionInputs, |
71 options: [Flags.analyzeOnly]); | 70 options: [Flags.analyzeOnly]); |
72 compilerDeserialized.resolution.retainCachesForTesting = true; | 71 compilerDeserialized.resolution.retainCachesForTesting = true; |
73 await compilerDeserialized.run(entryPoint); | 72 await compilerDeserialized.run(entryPoint); |
74 compilerDeserialized.phase = Compiler.PHASE_DONE_RESOLVING; | 73 compilerDeserialized.phase = Compiler.PHASE_DONE_RESOLVING; |
75 compilerDeserialized.world.populate(); | 74 compilerDeserialized.world.populate(); |
76 compilerDeserialized.backend.onResolutionComplete(); | 75 compilerDeserialized.backend.onResolutionComplete(); |
77 | 76 |
78 checkAllImpacts( | 77 checkAllImpacts( |
79 compilerNormal, compilerDeserialized, | 78 compilerNormal, compilerDeserialized, |
80 verbose: verbose); | 79 verbose: verbose); |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
392 return true; | 391 return true; |
393 } | 392 } |
394 | 393 |
395 String nodeToString(Node node) { | 394 String nodeToString(Node node) { |
396 String text = '$node'; | 395 String text = '$node'; |
397 if (text.length > 40) { | 396 if (text.length > 40) { |
398 return '(${node.runtimeType}) ${text.substring(0, 37)}...'; | 397 return '(${node.runtimeType}) ${text.substring(0, 37)}...'; |
399 } | 398 } |
400 return '(${node.runtimeType}) $text'; | 399 return '(${node.runtimeType}) $text'; |
401 } | 400 } |
OLD | NEW |