OLD | NEW |
| (Empty) |
1 // Copyright (c) 2014, 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 // Helper file that can be used to manually test the stability of incremental | |
6 // compilation. Currently this test is not run automatically. | |
7 | |
8 import 'dart:async'; | |
9 | |
10 import 'dart:io'; | |
11 | |
12 import 'dart:developer' show UserTag; | |
13 | |
14 import 'package:dart2js_incremental/dart2js_incremental.dart' | |
15 show IncrementalCompiler; | |
16 import 'package:compiler/src/source_file_provider.dart' | |
17 show FormattingDiagnosticHandler; | |
18 | |
19 import '../memory_source_file_helper.dart' show CompilerImpl; | |
20 | |
21 import '../memory_compiler.dart' show compilerFor; | |
22 | |
23 const bool verbose = false; | |
24 | |
25 main(List<String> arguments) { | |
26 Stopwatch sw = new Stopwatch()..start(); | |
27 Map<String, String> sources = <String, String>{}; | |
28 for (String argument in arguments) { | |
29 Uri uri = new Uri(scheme: 'memory', path: argument); | |
30 String source = | |
31 new File.fromUri(Uri.base.resolve(argument)).readAsStringSync(); | |
32 sources['${uri.path}'] = source; | |
33 } | |
34 sw.stop(); | |
35 print(sw.elapsedMilliseconds); | |
36 compileTests(sources); | |
37 } | |
38 | |
39 void compileTests(Map<String, String> sources) { | |
40 int testCount = 0; | |
41 int skipCount = 0; | |
42 Set<String> crashes = new Set<String>(); | |
43 CompilerImpl memoryCompiler = compilerFor(memorySourceFiles: sources); | |
44 FormattingDiagnosticHandler handler = memoryCompiler.handler; | |
45 handler.verbose = verbose; | |
46 var options = ['--analyze-main']; | |
47 if (true || verbose) options.add('--verbose'); | |
48 IncrementalCompiler compiler = new IncrementalCompiler( | |
49 libraryRoot: memoryCompiler.libraryRoot, | |
50 inputProvider: memoryCompiler.provider, | |
51 outputProvider: memoryCompiler.userOutputProvider, | |
52 diagnosticHandler: memoryCompiler.handler, | |
53 packageRoot: memoryCompiler.options.packageRoot, | |
54 options: options); | |
55 Future.forEach(sources.keys, (String path) { | |
56 UserTag.defaultTag.makeCurrent(); | |
57 if (!path.endsWith('_test.dart')) return new Future.value(null); | |
58 testCount++; | |
59 for (String brokenTest in brokenTests) { | |
60 if (path.endsWith(brokenTest)) { | |
61 print('Skipped broken test $path'); | |
62 skipCount++; | |
63 return new Future.value(null); | |
64 } | |
65 } | |
66 Stopwatch sw = new Stopwatch()..start(); | |
67 return compiler.compile(Uri.parse('memory:$path')).then((bool success) { | |
68 UserTag.defaultTag.makeCurrent(); | |
69 sw.stop(); | |
70 print('Compiled $path in ${sw.elapsedMilliseconds}'); | |
71 sw | |
72 ..reset() | |
73 ..start(); | |
74 }).catchError((error, trace) { | |
75 sw.stop(); | |
76 print('$error\n$trace'); | |
77 print('Crash when compiling $path after ${sw.elapsedMilliseconds}'); | |
78 sw | |
79 ..reset() | |
80 ..start(); | |
81 crashes.add(path); | |
82 }); | |
83 }).then((_) { | |
84 percent(i) => '${(i/testCount*100).toStringAsFixed(3)}%'; | |
85 print(''' | |
86 | |
87 Total: $testCount tests | |
88 * ${crashes.length} tests (${percent(crashes.length)}) crashed the compiler | |
89 * $skipCount tests (${percent(skipCount)}) were skipped | |
90 '''); | |
91 for (String crash in crashes) { | |
92 print('Crashed: $crash'); | |
93 } | |
94 if (!crashes.isEmpty) { | |
95 throw 'Test had crashes'; | |
96 } | |
97 }); | |
98 } | |
99 | |
100 Set<String> brokenTests = new Set<String>.from([ | |
101 // TODO(ahe): Fix the outputProvider to not throw an error. | |
102 "/dart2js_extra/deferred/deferred_class_library.dart", | |
103 "/dart2js_extra/deferred/deferred_class_library2.dart", | |
104 "/dart2js_extra/deferred/deferred_class_test.dart", | |
105 "/dart2js_extra/deferred/deferred_constant2_test.dart", | |
106 "/dart2js_extra/deferred/deferred_constant3_test.dart", | |
107 "/dart2js_extra/deferred/deferred_constant4_test.dart", | |
108 "/dart2js_extra/deferred/deferred_constant_test.dart", | |
109 "/dart2js_extra/deferred/deferred_function_library.dart", | |
110 "/dart2js_extra/deferred/deferred_function_test.dart", | |
111 "/dart2js_extra/deferred/deferred_overlapping_lib1.dart", | |
112 "/dart2js_extra/deferred/deferred_overlapping_lib2.dart", | |
113 "/dart2js_extra/deferred/deferred_overlapping_lib3.dart", | |
114 "/dart2js_extra/deferred/deferred_overlapping_test.dart", | |
115 "/dart2js_extra/deferred/deferred_unused_classes_test.dart", | |
116 "/language/deferred_closurize_load_library_lib.dart", | |
117 "/language/deferred_closurize_load_library_test.dart", | |
118 "/language/deferred_constraints_constants_lib.dart", | |
119 "/language/deferred_constraints_constants_old_syntax_lib.dart", | |
120 "/language/deferred_constraints_constants_old_syntax_test.dart", | |
121 "/language/deferred_constraints_constants_test.dart", | |
122 "/language/deferred_constraints_lib.dart", | |
123 "/language/deferred_constraints_lib2.dart", | |
124 "/language/deferred_constraints_old_syntax_lib.dart", | |
125 "/language/deferred_constraints_type_annotation_old_syntax_test.dart", | |
126 "/language/deferred_constraints_type_annotation_test.dart", | |
127 "/language/deferred_duplicate_prefix1_test.dart", | |
128 "/language/deferred_duplicate_prefix2_test.dart", | |
129 "/language/deferred_duplicate_prefix3_test.dart", | |
130 "/language/deferred_load_inval_code_lib.dart", | |
131 "/language/deferred_load_inval_code_test.dart", | |
132 "/language/deferred_load_library_wrong_args_lib.dart", | |
133 "/language/deferred_load_library_wrong_args_test.dart", | |
134 "/language/deferred_no_prefix_test.dart", | |
135 "/language/deferred_no_such_method_lib.dart", | |
136 "/language/deferred_no_such_method_test.dart", | |
137 "/language/deferred_not_loaded_check_lib.dart", | |
138 "/language/deferred_not_loaded_check_test.dart", | |
139 "/language/deferred_prefix_constraints_lib.dart", | |
140 "/language/deferred_prefix_constraints_lib2.dart", | |
141 "/language/deferred_shadow_load_library_lib.dart", | |
142 "/language/deferred_shadow_load_library_test.dart", | |
143 | |
144 "/language/bad_constructor_test.dart", | |
145 "/language/black_listed_test.dart", | |
146 "/language/built_in_identifier_illegal_test.dart", | |
147 "/language/built_in_identifier_prefix_test.dart", | |
148 "/language/built_in_identifier_test.dart", | |
149 "/language/class_cycle2_test.dart", | |
150 "/language/class_syntax_test.dart", | |
151 "/language/cyclic_typedef_test.dart", | |
152 "/language/external_test.dart", | |
153 "/language/factory3_negative_test.dart", | |
154 "/language/generic_field_mixin4_test.dart", | |
155 "/language/generic_field_mixin5_test.dart", | |
156 "/language/interface_cycle_test.dart", | |
157 "/language/interface_injection1_negative_test.dart", | |
158 "/language/interface_injection2_negative_test.dart", | |
159 "/language/internal_library_test.dart", | |
160 "/language/malformed_inheritance_test.dart", | |
161 "/language/metadata_test.dart", | |
162 "/language/method_override2_test.dart", | |
163 "/language/mixin_illegal_syntax_test.dart", | |
164 "/language/mixin_invalid_inheritance1_test.dart", | |
165 "/language/null_test.dart", | |
166 "/language/override_inheritance_generic_test.dart", | |
167 "/language/prefix18_negative_test.dart", | |
168 "/language/prefix3_negative_test.dart", | |
169 "/language/script2_negative_test.dart", | |
170 "/language/setter_declaration2_negative_test.dart", | |
171 "/language/source_self_negative_test.dart", | |
172 "/language/syntax_test.dart", | |
173 "/language/type_variable_bounds2_test.dart", | |
174 "/language/type_variable_conflict2_test.dart", | |
175 "/language/type_variable_field_initializer_test.dart", | |
176 "/language/type_variable_nested_test.dart", | |
177 "/language/vm/reflect_core_vm_test.dart", | |
178 "/language/vm/regress_14903_test.dart", | |
179 ]); | |
OLD | NEW |