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