| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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 /// Runs Dart Dev Compiler on all input in the `codegen` directory and checks | 6 /// Runs Dart Dev Compiler on all input in the `codegen` directory and checks |
| 7 /// that the output is what we expected. | 7 /// that the output is what we expected. |
| 8 library dev_compiler.test.codegen_test; | 8 library dev_compiler.test.codegen_test; |
| 9 | 9 |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 if (loggerSub != null) { | 51 if (loggerSub != null) { |
| 52 loggerSub.cancel(); | 52 loggerSub.cancel(); |
| 53 loggerSub = null; | 53 loggerSub = null; |
| 54 } | 54 } |
| 55 }); | 55 }); |
| 56 | 56 |
| 57 var inputDir = path.join(testDirectory, 'codegen'); | 57 var inputDir = path.join(testDirectory, 'codegen'); |
| 58 var expectDir = path.join(inputDir, 'expect'); | 58 var expectDir = path.join(inputDir, 'expect'); |
| 59 | 59 |
| 60 bool compile(String entryPoint, AnalysisContext context, | 60 bool compile(String entryPoint, AnalysisContext context, |
| 61 {bool checkSdk: false, bool sourceMaps: false, | 61 {bool checkSdk: false, bool sourceMaps: false, bool closure: false}) { |
| 62 bool closure: false}) { | |
| 63 // TODO(jmesserly): add a way to specify flags in the test file, so | 62 // TODO(jmesserly): add a way to specify flags in the test file, so |
| 64 // they're more self-contained. | 63 // they're more self-contained. |
| 65 var runtimeDir = path.join(path.dirname(testDirectory), 'lib', 'runtime'); | 64 var runtimeDir = path.join(path.dirname(testDirectory), 'lib', 'runtime'); |
| 66 var options = new CompilerOptions( | 65 var options = new CompilerOptions( |
| 67 codegenOptions: new CodegenOptions( | 66 codegenOptions: new CodegenOptions( |
| 68 outputDir: expectDir, | 67 outputDir: expectDir, |
| 69 emitSourceMaps: sourceMaps, | 68 emitSourceMaps: sourceMaps, |
| 70 closure: closure, | 69 closure: closure, |
| 71 forceCompile: checkSdk), | 70 forceCompile: checkSdk), |
| 72 useColors: false, | 71 useColors: false, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 var filename = path.basenameWithoutExtension(filePath); | 128 var filename = path.basenameWithoutExtension(filePath); |
| 130 | 129 |
| 131 test('$filename.dart', () { | 130 test('$filename.dart', () { |
| 132 compilerMessages.writeln('// Messages from compiling $filename.dart'); | 131 compilerMessages.writeln('// Messages from compiling $filename.dart'); |
| 133 | 132 |
| 134 // TODO(jmesserly): this was added to get some coverage of source maps | 133 // TODO(jmesserly): this was added to get some coverage of source maps |
| 135 // and closure annotations. | 134 // and closure annotations. |
| 136 // We need a more comprehensive strategy to test them. | 135 // We need a more comprehensive strategy to test them. |
| 137 var sourceMaps = filename == 'map_keys'; | 136 var sourceMaps = filename == 'map_keys'; |
| 138 var closure = filename == 'closure'; | 137 var closure = filename == 'closure'; |
| 139 var success = | 138 var success = compile(filePath, realSdkContext, |
| 140 compile(filePath, realSdkContext, sourceMaps: sourceMaps, | 139 sourceMaps: sourceMaps, closure: closure); |
| 141 closure: closure); | |
| 142 | 140 |
| 143 // Write compiler messages to disk. | 141 // Write compiler messages to disk. |
| 144 new File(path.join(outDir, '$filename.txt')) | 142 new File(path.join(outDir, '$filename.txt')) |
| 145 .writeAsStringSync('$compilerMessages'); | 143 .writeAsStringSync('$compilerMessages'); |
| 146 | 144 |
| 147 var outFile = new File(path.join(outDir, '$filename.js')); | 145 var outFile = new File(path.join(outDir, '$filename.js')); |
| 148 expect(outFile.existsSync(), success, | 146 expect(outFile.existsSync(), success, |
| 149 reason: '${outFile.path} was created iff compilation succeeds'); | 147 reason: '${outFile.path} was created iff compilation succeeds'); |
| 150 }); | 148 }); |
| 151 } | 149 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 print('[AnalysisEngine] error $message $exception'); | 238 print('[AnalysisEngine] error $message $exception'); |
| 241 } | 239 } |
| 242 | 240 |
| 243 @override void logError2(String message, Object exception) { | 241 @override void logError2(String message, Object exception) { |
| 244 print('[AnalysisEngine] error $message $exception'); | 242 print('[AnalysisEngine] error $message $exception'); |
| 245 } | 243 } |
| 246 | 244 |
| 247 void logInformation(String message, [CaughtException exception]) {} | 245 void logInformation(String message, [CaughtException exception]) {} |
| 248 void logInformation2(String message, Object exception) {} | 246 void logInformation2(String message, Object exception) {} |
| 249 } | 247 } |
| OLD | NEW |