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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // Messages from compiling ${path.basenameWithoutExtension(url)}.dart | 96 // Messages from compiling ${path.basenameWithoutExtension(url)}.dart |
97 $compilerMessages'''; | 97 $compilerMessages'''; |
98 var dir = file.parent; | 98 var dir = file.parent; |
99 if (!dir.existsSync()) dir.createSync(recursive: true); | 99 if (!dir.existsSync()) dir.createSync(recursive: true); |
100 file.writeAsStringSync(message); | 100 file.writeAsStringSync(message); |
101 compilerMessages.clear(); | 101 compilerMessages.clear(); |
102 }); | 102 }); |
103 return !compiler.failure; | 103 return !compiler.failure; |
104 } | 104 } |
105 | 105 |
| 106 var testDirs = <String>['language', path.join('lib', 'typed_data')]; |
| 107 |
106 var multitests = new Set<String>(); | 108 var multitests = new Set<String>(); |
107 { | 109 { |
108 // Expand wacky multitests into a bunch of test files. | 110 // Expand wacky multitests into a bunch of test files. |
109 // We'll compile each one as if it was an input. | 111 // We'll compile each one as if it was an input. |
110 var languageDir = path.join(inputDir, 'language'); | 112 for (var testDir in testDirs) { |
111 var testFiles = _findTests(languageDir, filePattern); | 113 var fullDir = path.join(inputDir, testDir); |
| 114 var testFiles = _findTests(fullDir, filePattern); |
112 | 115 |
113 for (var filePath in testFiles) { | 116 for (var filePath in testFiles) { |
114 if (filePath.endsWith('_multi.dart')) continue; | 117 if (filePath.endsWith('_multi.dart')) continue; |
115 | 118 |
116 var contents = new File(filePath).readAsStringSync(); | 119 var contents = new File(filePath).readAsStringSync(); |
117 if (isMultiTest(contents)) { | 120 if (isMultiTest(contents)) { |
118 multitests.add(filePath); | 121 multitests.add(filePath); |
119 | 122 |
120 var tests = new Map<String, String>(); | 123 var tests = new Map<String, String>(); |
121 var outcomes = new Map<String, Set<String>>(); | 124 var outcomes = new Map<String, Set<String>>(); |
122 extractTestsFromMultitest(filePath, contents, tests, outcomes); | 125 extractTestsFromMultitest(filePath, contents, tests, outcomes); |
123 | 126 |
124 var filename = path.basenameWithoutExtension(filePath); | 127 var filename = path.basenameWithoutExtension(filePath); |
125 tests.forEach((name, contents) { | 128 tests.forEach((name, contents) { |
126 new File(path.join(languageDir, '${filename}_${name}_multi.dart')) | 129 new File(path.join(fullDir, '${filename}_${name}_multi.dart')) |
127 .writeAsStringSync(contents); | 130 .writeAsStringSync(contents); |
128 }); | 131 }); |
| 132 } |
129 } | 133 } |
130 } | 134 } |
131 } | 135 } |
132 | 136 |
133 var batchCompiler = createCompiler(realSdkContext); | 137 var batchCompiler = createCompiler(realSdkContext); |
134 | 138 |
135 for (var dir in [null, 'language']) { | 139 var allDirs = [null]; |
136 if (codeCoverage && dir == 'language') continue; | 140 allDirs.addAll(testDirs); |
| 141 for (var dir in allDirs) { |
| 142 if (codeCoverage && dir != null) continue; |
137 | 143 |
138 group('dartdevc ' + path.join('test', 'codegen', dir), () { | 144 group('dartdevc ' + path.join('test', 'codegen', dir), () { |
139 var outDir = new Directory(path.join(expectDir, dir)); | 145 var outDir = new Directory(path.join(expectDir, dir)); |
140 if (!outDir.existsSync()) outDir.createSync(recursive: true); | 146 if (!outDir.existsSync()) outDir.createSync(recursive: true); |
141 | 147 |
142 var testFiles = _findTests(path.join(inputDir, dir), filePattern); | 148 var testFiles = _findTests(path.join(inputDir, dir), filePattern); |
143 for (var filePath in testFiles) { | 149 for (var filePath in testFiles) { |
144 if (multitests.contains(filePath)) continue; | 150 if (multitests.contains(filePath)) continue; |
145 | 151 |
146 var filename = path.basenameWithoutExtension(filePath); | 152 var filename = path.basenameWithoutExtension(filePath); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 255 |
250 /// An implementation of analysis engine's [Logger] that prints. | 256 /// An implementation of analysis engine's [Logger] that prints. |
251 class PrintLogger implements Logger { | 257 class PrintLogger implements Logger { |
252 @override void logError(String message, [CaughtException exception]) { | 258 @override void logError(String message, [CaughtException exception]) { |
253 print('[AnalysisEngine] error $message $exception'); | 259 print('[AnalysisEngine] error $message $exception'); |
254 } | 260 } |
255 | 261 |
256 void logInformation(String message, [CaughtException exception]) {} | 262 void logInformation(String message, [CaughtException exception]) {} |
257 void logInformation2(String message, Object exception) {} | 263 void logInformation2(String message, Object exception) {} |
258 } | 264 } |
OLD | NEW |