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_analysis_test; | 5 library dart2js.serialization_analysis_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:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
10 import 'package:compiler/src/commandline_options.dart'; | 10 import 'package:compiler/src/commandline_options.dart'; |
11 import 'package:compiler/src/compiler.dart'; | 11 import 'package:compiler/src/compiler.dart'; |
12 import 'package:compiler/src/filenames.dart'; | 12 import 'package:compiler/src/filenames.dart'; |
13 import '../memory_compiler.dart'; | 13 import '../memory_compiler.dart'; |
14 import 'helper.dart'; | 14 import 'helper.dart'; |
15 import 'test_data.dart'; | 15 import 'test_data.dart'; |
16 | 16 |
17 main(List<String> args) { | 17 main(List<String> args) { |
18 asyncTest(() async { | 18 asyncTest(() async { |
19 Arguments arguments = new Arguments.from(args); | 19 Arguments arguments = new Arguments.from(args); |
20 SerializedData serializedData = | 20 SerializedData serializedData = |
21 await serializeDartCore(arguments: arguments); | 21 await serializeDartCore(arguments: arguments); |
22 if (arguments.filename != null) { | 22 if (arguments.filename != null) { |
23 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename)); | 23 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename)); |
24 await analyze(entryPoint, | 24 await analyze(entryPoint, |
25 resolutionInputs: serializedData.toUris(), | 25 resolutionInputs: serializedData.toUris(), |
26 sourceFiles: serializedData.toMemorySourceFiles()); | 26 sourceFiles: serializedData.toMemorySourceFiles()); |
27 } else { | 27 } else { |
28 await arguments.forEachTest(serializedData, TESTS, analyze); | 28 await arguments.forEachTest(serializedData, TESTS, analyze); |
29 } | 29 } |
| 30 printMeasurementResults(); |
30 }); | 31 }); |
31 } | 32 } |
32 | 33 |
33 Future analyze( | 34 Future analyze( |
34 Uri entryPoint, | 35 Uri entryPoint, |
35 {Map<String, String> sourceFiles: const <String, String>{}, | 36 {Map<String, String> sourceFiles: const <String, String>{}, |
36 List<Uri> resolutionInputs, | 37 List<Uri> resolutionInputs, |
37 int index, | 38 int index, |
38 Test test, | 39 Test test, |
39 bool verbose: false}) async { | 40 bool verbose: false}) async { |
40 String testDescription = test != null ? test.name : '${entryPoint}'; | 41 String testDescription = test != null ? test.name : '${entryPoint}'; |
41 String id = index != null ? '$index: ' : ''; | 42 String id = index != null ? '$index: ' : ''; |
42 print('------------------------------------------------------------------'); | 43 String title = '${id}${testDescription}'; |
43 print('analyze ${id}${testDescription}'); | 44 await measure(title, 'analyze', () async { |
44 print('------------------------------------------------------------------'); | 45 DiagnosticCollector diagnosticCollector = new DiagnosticCollector(); |
45 DiagnosticCollector diagnosticCollector = new DiagnosticCollector(); | 46 await runCompiler( |
46 await runCompiler( | 47 entryPoint: entryPoint, |
47 entryPoint: entryPoint, | 48 resolutionInputs: resolutionInputs, |
48 resolutionInputs: resolutionInputs, | 49 memorySourceFiles: sourceFiles, |
49 memorySourceFiles: sourceFiles, | 50 options: [Flags.analyzeOnly], |
50 options: [Flags.analyzeOnly], | 51 diagnosticHandler: diagnosticCollector); |
51 diagnosticHandler: diagnosticCollector); | 52 if (test != null) { |
52 if (test != null) { | 53 Expect.equals(test.expectedErrorCount, diagnosticCollector.errors.length, |
53 Expect.equals(test.expectedErrorCount, diagnosticCollector.errors.length, | 54 "Unexpected error count."); |
54 "Unexpected error count."); | 55 Expect.equals( |
55 Expect.equals( | 56 test.expectedWarningCount, |
56 test.expectedWarningCount, | 57 diagnosticCollector.warnings.length, |
57 diagnosticCollector.warnings.length, | 58 "Unexpected warning count."); |
58 "Unexpected warning count."); | 59 Expect.equals(test.expectedHintCount, diagnosticCollector.hints.length, |
59 Expect.equals(test.expectedHintCount, diagnosticCollector.hints.length, | 60 "Unexpected hint count."); |
60 "Unexpected hint count."); | 61 Expect.equals(test.expectedInfoCount, diagnosticCollector.infos.length, |
61 Expect.equals(test.expectedInfoCount, diagnosticCollector.infos.length, | 62 "Unexpected info count."); |
62 "Unexpected info count."); | 63 } |
63 } | 64 }); |
64 } | 65 } |
65 | 66 |
OLD | NEW |