| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 new File(mapPath) | 157 new File(mapPath) |
| 158 .writeAsStringSync(JSON.encode(result.placeSourceMap(mapPath))); | 158 .writeAsStringSync(JSON.encode(result.placeSourceMap(mapPath))); |
| 159 } | 159 } |
| 160 | 160 |
| 161 // There are no errors, so delete any stale ".err" file. | 161 // There are no errors, so delete any stale ".err" file. |
| 162 if (errorFile.existsSync()) { | 162 if (errorFile.existsSync()) { |
| 163 errorFile.deleteSync(); | 163 errorFile.deleteSync(); |
| 164 } | 164 } |
| 165 } else { | 165 } else { |
| 166 // Also write the errors to a '.err' file for easy counting. | 166 // Also write the errors to a '.err' file for easy counting. |
| 167 errorFile.writeAsStringSync(errors); | 167 var moduleName = result.name; |
| 168 var libraryName = path.split(moduleName).last; |
| 169 var count = "[error]".allMatches(errors).length; |
| 170 var text = ''' |
| 171 dart_library.library('$moduleName', null, [ |
| 172 'dart_sdk', |
| 173 'expect' |
| 174 ], function(exports, dart_sdk, expect) { |
| 175 const message = `DDC Compilation Error: $moduleName has $count errors`; |
| 176 const error = new Error(message); |
| 177 exports.$libraryName = Object.create(null); |
| 178 exports.$libraryName.main = function() { |
| 179 throw error; |
| 180 } |
| 181 }); |
| 182 '''; |
| 183 errorFile.writeAsStringSync(text); |
| 168 | 184 |
| 169 // There are errors, so delete any stale ".js" file. | 185 // There are errors, so delete any stale ".js" file. |
| 170 if (jsFile.existsSync()) { | 186 if (jsFile.existsSync()) { |
| 171 jsFile.deleteSync(); | 187 jsFile.deleteSync(); |
| 172 } | 188 } |
| 173 } | 189 } |
| 174 } | 190 } |
| 175 | 191 |
| 176 void _buildAllPackages(ModuleCompiler compiler) { | 192 void _buildAllPackages(ModuleCompiler compiler) { |
| 177 group('dartdevc package', () { | 193 group('dartdevc package', () { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 /// Simplified from ParseDartTask.resolveDirective. | 399 /// Simplified from ParseDartTask.resolveDirective. |
| 384 String _resolveDirective(UriBasedDirective directive) { | 400 String _resolveDirective(UriBasedDirective directive) { |
| 385 StringLiteral uriLiteral = directive.uri; | 401 StringLiteral uriLiteral = directive.uri; |
| 386 String uriContent = uriLiteral.stringValue; | 402 String uriContent = uriLiteral.stringValue; |
| 387 if (uriContent != null) { | 403 if (uriContent != null) { |
| 388 uriContent = uriContent.trim(); | 404 uriContent = uriContent.trim(); |
| 389 directive.uriContent = uriContent; | 405 directive.uriContent = uriContent; |
| 390 } | 406 } |
| 391 return directive.validate() == null ? uriContent : null; | 407 return directive.validate() == null ? uriContent : null; |
| 392 } | 408 } |
| OLD | NEW |