| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 tests.forEach((name, contents) { | 114 tests.forEach((name, contents) { |
| 115 new File(path.join(languageDir, '${filename}_${name}_multi.dart')) | 115 new File(path.join(languageDir, '${filename}_${name}_multi.dart')) |
| 116 .writeAsStringSync(contents); | 116 .writeAsStringSync(contents); |
| 117 }); | 117 }); |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 | 121 |
| 122 for (var dir in [null, 'language']) { | 122 for (var dir in [null, 'language']) { |
| 123 group('dartdevc ' + path.join('test', 'codegen', dir), () { | 123 group('dartdevc ' + path.join('test', 'codegen', dir), () { |
| 124 var outDir = path.join(expectDir, dir); | 124 var outDir = new Directory(path.join(expectDir, dir)); |
| 125 if (!outDir.existsSync()) outDir.createSync(recursive: true); |
| 125 | 126 |
| 126 var testFiles = _findTests(path.join(inputDir, dir), filePattern); | 127 var testFiles = _findTests(path.join(inputDir, dir), filePattern); |
| 127 for (var filePath in testFiles) { | 128 for (var filePath in testFiles) { |
| 128 var filename = path.basenameWithoutExtension(filePath); | 129 var filename = path.basenameWithoutExtension(filePath); |
| 129 | 130 |
| 130 test('$filename.dart', () { | 131 test('$filename.dart', () { |
| 131 compilerMessages.writeln('// Messages from compiling $filename.dart'); | 132 compilerMessages.writeln('// Messages from compiling $filename.dart'); |
| 132 | 133 |
| 133 // TODO(jmesserly): this was added to get some coverage of source maps | 134 // TODO(jmesserly): this was added to get some coverage of source maps |
| 134 // and closure annotations. | 135 // and closure annotations. |
| 135 // We need a more comprehensive strategy to test them. | 136 // We need a more comprehensive strategy to test them. |
| 136 var sourceMaps = filename == 'map_keys'; | 137 var sourceMaps = filename == 'map_keys'; |
| 137 var closure = filename == 'closure'; | 138 var closure = filename == 'closure'; |
| 138 var success = compile(filePath, realSdkContext, | 139 var success = compile(filePath, realSdkContext, |
| 139 sourceMaps: sourceMaps, closure: closure); | 140 sourceMaps: sourceMaps, closure: closure); |
| 140 | 141 |
| 141 // Write compiler messages to disk. | 142 // Write compiler messages to disk. |
| 142 new File(path.join(outDir, '$filename.txt')) | 143 new File(path.join(outDir.path, '$filename.txt')) |
| 143 .writeAsStringSync('$compilerMessages'); | 144 .writeAsStringSync('$compilerMessages'); |
| 144 | 145 |
| 145 var outFile = new File(path.join(outDir, '$filename.js')); | 146 var outFile = new File(path.join(outDir.path, '$filename.js')); |
| 146 expect(outFile.existsSync(), success, | 147 expect(outFile.existsSync(), success, |
| 147 reason: '${outFile.path} was created iff compilation succeeds'); | 148 reason: '${outFile.path} was created iff compilation succeeds'); |
| 148 }); | 149 }); |
| 149 } | 150 } |
| 150 }); | 151 }); |
| 151 } | 152 } |
| 152 | 153 |
| 153 if (Platform.environment.containsKey('COVERALLS_TOKEN')) { | 154 if (Platform.environment.containsKey('COVERALLS_TOKEN')) { |
| 154 group('sdk', () { | 155 group('sdk', () { |
| 155 // The analyzer does not bubble exception messages for certain internal | 156 // The analyzer does not bubble exception messages for certain internal |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 print('[AnalysisEngine] error $message $exception'); | 239 print('[AnalysisEngine] error $message $exception'); |
| 239 } | 240 } |
| 240 | 241 |
| 241 @override void logError2(String message, Object exception) { | 242 @override void logError2(String message, Object exception) { |
| 242 print('[AnalysisEngine] error $message $exception'); | 243 print('[AnalysisEngine] error $message $exception'); |
| 243 } | 244 } |
| 244 | 245 |
| 245 void logInformation(String message, [CaughtException exception]) {} | 246 void logInformation(String message, [CaughtException exception]) {} |
| 246 void logInformation2(String message, Object exception) {} | 247 void logInformation2(String message, Object exception) {} |
| 247 } | 248 } |
| OLD | NEW |