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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 var files = new Set<String>(); | 152 var files = new Set<String>(); |
153 _collectTransitiveImports(contents, files, from: testFile); | 153 _collectTransitiveImports(contents, files, from: testFile); |
154 var unit = new BuildUnit( | 154 var unit = new BuildUnit( |
155 name, path.dirname(testFile), files.toList(), _moduleForLibrary); | 155 name, path.dirname(testFile), files.toList(), _moduleForLibrary); |
156 | 156 |
157 var compiler = sharedCompiler; | 157 var compiler = sharedCompiler; |
158 if (analyzerOptions.declaredVariables.isNotEmpty) { | 158 if (analyzerOptions.declaredVariables.isNotEmpty) { |
159 compiler = new ModuleCompiler(analyzerOptions); | 159 compiler = new ModuleCompiler(analyzerOptions); |
160 } | 160 } |
161 JSModuleFile module = null; | 161 JSModuleFile module = null; |
| 162 var error, trace; |
162 try { | 163 try { |
163 module = compiler.compile(unit, options); | 164 module = compiler.compile(unit, options); |
164 } catch (e) {} | 165 } catch (e, t) { |
| 166 error = e; |
| 167 trace = t; |
| 168 } |
165 | 169 |
166 bool notStrong = notYetStrongTests.contains(name); | 170 bool notStrong = notYetStrongTests.contains(name); |
167 bool crashing = _crashingTests.contains(name); | 171 bool crashing = _crashingTests.contains(name); |
168 | 172 |
169 if (module == null) { | 173 if (module == null) { |
170 expect(crashing, isTrue, | 174 expect(crashing, isTrue, |
171 reason: "test $name crashes during compilation."); | 175 reason: "test $name crashes during compilation.\n\n" |
| 176 "Exception: $error\n\nStack trace:\n\n$trace"); |
172 } else if (module.isValid) { | 177 } else if (module.isValid) { |
173 _writeModule( | 178 _writeModule( |
174 path.join(codegenOutputDir, name), | 179 path.join(codegenOutputDir, name), |
175 isTopLevelTest ? path.join(codegenExpectDir, name) : null, | 180 isTopLevelTest ? path.join(codegenExpectDir, name) : null, |
176 moduleFormat, | 181 moduleFormat, |
177 module); | 182 module); |
178 | 183 |
179 expect(crashing, isFalse, reason: "test $name no longer crashes."); | 184 expect(crashing, isFalse, reason: "test $name no longer crashes."); |
180 expect(notStrong, isFalse, | 185 expect(notStrong, isFalse, |
181 reason: "test $name expected strong mode errors, but compiled."); | 186 reason: "test $name expected strong mode errors, but compiled."); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 'language/mixin_illegal_syntax_test_06_multi', | 391 'language/mixin_illegal_syntax_test_06_multi', |
387 'language/mixin_illegal_syntax_test_07_multi', | 392 'language/mixin_illegal_syntax_test_07_multi', |
388 'language/mixin_illegal_syntax_test_08_multi', | 393 'language/mixin_illegal_syntax_test_08_multi', |
389 'language/mixin_illegal_syntax_test_09_multi', | 394 'language/mixin_illegal_syntax_test_09_multi', |
390 'language/mixin_illegal_syntax_test_10_multi', | 395 'language/mixin_illegal_syntax_test_10_multi', |
391 'language/mixin_illegal_syntax_test_11_multi', | 396 'language/mixin_illegal_syntax_test_11_multi', |
392 'language/mixin_illegal_syntax_test_12_multi', | 397 'language/mixin_illegal_syntax_test_12_multi', |
393 'language/mixin_illegal_syntax_test_13_multi', | 398 'language/mixin_illegal_syntax_test_13_multi', |
394 'language/mixin_illegal_syntax_test_14_multi' | 399 'language/mixin_illegal_syntax_test_14_multi' |
395 ]); | 400 ]); |
OLD | NEW |