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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 } | 85 } |
86 | 86 |
87 bool compile(BatchCompiler compiler, String filePath) { | 87 bool compile(BatchCompiler compiler, String filePath) { |
88 compiler.compileFromUriString(filePath, (String url) { | 88 compiler.compileFromUriString(filePath, (String url) { |
89 // Write compiler messages to disk. | 89 // Write compiler messages to disk. |
90 var messagePath = '${path.withoutExtension(url)}.txt'; | 90 var messagePath = '${path.withoutExtension(url)}.txt'; |
91 var file = new File(messagePath); | 91 var file = new File(messagePath); |
92 var message = ''' | 92 var message = ''' |
93 // Messages from compiling ${path.basenameWithoutExtension(url)}.dart | 93 // Messages from compiling ${path.basenameWithoutExtension(url)}.dart |
94 $compilerMessages'''; | 94 $compilerMessages'''; |
95 var dir = file.parent; | |
96 if (!dir.existsSync()) dir.createSync(recursive: true); | |
95 file.writeAsStringSync(message); | 97 file.writeAsStringSync(message); |
96 compilerMessages.clear(); | 98 compilerMessages.clear(); |
97 }); | 99 }); |
98 return !compiler.failure; | 100 return !compiler.failure; |
99 } | 101 } |
100 | 102 |
101 var multitests = new Set<String>(); | 103 var multitests = new Set<String>(); |
102 { | 104 { |
103 // Expand wacky multitests into a bunch of test files. | 105 // Expand wacky multitests into a bunch of test files. |
104 // We'll compile each one as if it was an input. | 106 // We'll compile each one as if it was an input. |
(...skipping 20 matching lines...) Expand all Loading... | |
125 } | 127 } |
126 } | 128 } |
127 | 129 |
128 var batchCompiler = createCompiler(realSdkContext); | 130 var batchCompiler = createCompiler(realSdkContext); |
129 | 131 |
130 for (var dir in [null, 'language']) { | 132 for (var dir in [null, 'language']) { |
131 if (codeCoverage && dir == 'language') continue; | 133 if (codeCoverage && dir == 'language') continue; |
132 | 134 |
133 group('dartdevc ' + path.join('test', 'codegen', dir), () { | 135 group('dartdevc ' + path.join('test', 'codegen', dir), () { |
134 var outDir = new Directory(path.join(expectDir, dir)); | 136 var outDir = new Directory(path.join(expectDir, dir)); |
135 if (!outDir.existsSync()) outDir.createSync(recursive: true); | 137 if (!outDir.existsSync()) outDir.createSync(recursive: true); |
Jennifer Messerly
2015/10/03 00:23:02
hmm, shouldn't this line do what we need?
ideally
| |
136 | 138 |
137 var testFiles = _findTests(path.join(inputDir, dir), filePattern); | 139 var testFiles = _findTests(path.join(inputDir, dir), filePattern); |
138 for (var filePath in testFiles) { | 140 for (var filePath in testFiles) { |
139 if (multitests.contains(filePath)) continue; | 141 if (multitests.contains(filePath)) continue; |
140 | 142 |
141 var filename = path.basenameWithoutExtension(filePath); | 143 var filename = path.basenameWithoutExtension(filePath); |
142 | 144 |
143 test('$filename.dart', () { | 145 test('$filename.dart', () { |
144 // TODO(jmesserly): this was added to get some coverage of source maps | 146 // TODO(jmesserly): this was added to get some coverage of source maps |
145 // and closure annotations. | 147 // and closure annotations. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 print('[AnalysisEngine] error $message $exception'); | 243 print('[AnalysisEngine] error $message $exception'); |
242 } | 244 } |
243 | 245 |
244 @override void logError2(String message, Object exception) { | 246 @override void logError2(String message, Object exception) { |
245 print('[AnalysisEngine] error $message $exception'); | 247 print('[AnalysisEngine] error $message $exception'); |
246 } | 248 } |
247 | 249 |
248 void logInformation(String message, [CaughtException exception]) {} | 250 void logInformation(String message, [CaughtException exception]) {} |
249 void logInformation2(String message, Object exception) {} | 251 void logInformation2(String message, Object exception) {} |
250 } | 252 } |
OLD | NEW |