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 /// Tests code generation. | 5 /// Tests code generation. |
6 /// | 6 /// |
7 /// Runs Dart Dev Compiler on all input in the `codegen` directory and checks | 7 /// Runs Dart Dev Compiler on all input in the `codegen` directory and checks |
8 /// that the output is what we expected. | 8 /// that the output is what we expected. |
9 library dev_compiler.test.codegen_test; | 9 library dev_compiler.test.codegen_test; |
10 | 10 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 var files = new Set<String>(); | 149 var files = new Set<String>(); |
150 _collectTransitiveImports(contents, files, from: testFile); | 150 _collectTransitiveImports(contents, files, from: testFile); |
151 var unit = new BuildUnit( | 151 var unit = new BuildUnit( |
152 name, path.dirname(testFile), files.toList(), _moduleForLibrary); | 152 name, path.dirname(testFile), files.toList(), _moduleForLibrary); |
153 | 153 |
154 var compiler = sharedCompiler; | 154 var compiler = sharedCompiler; |
155 if (analyzerOptions.declaredVariables.isNotEmpty) { | 155 if (analyzerOptions.declaredVariables.isNotEmpty) { |
156 compiler = new ModuleCompiler(analyzerOptions); | 156 compiler = new ModuleCompiler(analyzerOptions); |
157 } | 157 } |
158 JSModuleFile module = null; | 158 JSModuleFile module = null; |
| 159 var error, trace; |
159 try { | 160 try { |
160 module = compiler.compile(unit, options); | 161 module = compiler.compile(unit, options); |
161 } catch (e) {} | 162 } catch (e, t) { |
| 163 error = e; |
| 164 trace = t; |
| 165 } |
162 | 166 |
163 bool notStrong = notYetStrongTests.contains(name); | 167 bool notStrong = notYetStrongTests.contains(name); |
164 bool crashing = _crashingTests.contains(name); | 168 bool crashing = _crashingTests.contains(name); |
165 | 169 |
166 if (module == null) { | 170 if (module == null) { |
167 expect(crashing, isTrue, | 171 expect(crashing, isTrue, |
168 reason: "test $name crashes during compilation."); | 172 reason: "test $name crashes during compilation.\n\n" |
| 173 "Exception: $error\n\nStack trace:\n\n$trace"); |
169 } else if (module.isValid) { | 174 } else if (module.isValid) { |
170 _writeModule( | 175 _writeModule( |
171 path.join(codegenOutputDir, name), | 176 path.join(codegenOutputDir, name), |
172 isTopLevelTest ? path.join(codegenExpectDir, name) : null, | 177 isTopLevelTest ? path.join(codegenExpectDir, name) : null, |
173 moduleFormat, | 178 moduleFormat, |
174 module); | 179 module); |
175 | 180 |
176 expect(crashing, isFalse, reason: "test $name no longer crashes."); | 181 expect(crashing, isFalse, reason: "test $name no longer crashes."); |
177 expect(notStrong, isFalse, | 182 expect(notStrong, isFalse, |
178 reason: "test $name expected strong mode errors, but compiled."); | 183 reason: "test $name expected strong mode errors, but compiled."); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 'language/mixin_illegal_syntax_test_14_multi', | 396 'language/mixin_illegal_syntax_test_14_multi', |
392 | 397 |
393 // TODO(vsm): Fix these - they import files from a different directory | 398 // TODO(vsm): Fix these - they import files from a different directory |
394 // - this triggers an invalid library root build error. | 399 // - this triggers an invalid library root build error. |
395 'lib/html/custom/attribute_changed_callback_test', | 400 'lib/html/custom/attribute_changed_callback_test', |
396 'lib/html/custom/entered_left_view_test', | 401 'lib/html/custom/entered_left_view_test', |
397 'lib/html/custom/js_custom_test', | 402 'lib/html/custom/js_custom_test', |
398 'lib/html/custom/mirrors_test', | 403 'lib/html/custom/mirrors_test', |
399 'lib/html/custom/regress_194523002_test', | 404 'lib/html/custom/regress_194523002_test', |
400 ]); | 405 ]); |
OLD | NEW |