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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 .where((p) => p.endsWith('.sum')) | 76 .where((p) => p.endsWith('.sum')) |
77 .toList(); | 77 .toList(); |
78 | 78 |
79 var analyzerOptions = new AnalyzerOptions( | 79 var analyzerOptions = new AnalyzerOptions( |
80 dartSdkSummaryPath: sdkSummaryFile, summaryPaths: summaryPaths); | 80 dartSdkSummaryPath: sdkSummaryFile, summaryPaths: summaryPaths); |
81 var compiler = new ModuleCompiler(analyzerOptions); | 81 var compiler = new ModuleCompiler(analyzerOptions); |
82 | 82 |
83 var testDirs = [ | 83 var testDirs = [ |
84 'language', | 84 'language', |
85 'corelib', | 85 'corelib', |
| 86 path.join('corelib', 'regexp'), |
86 path.join('lib', 'convert'), | 87 path.join('lib', 'convert'), |
87 path.join('lib', 'html'), | 88 path.join('lib', 'html'), |
| 89 // TODO(vsm): Fix these - they import files from a different directory |
| 90 // - this triggers an invalid library root build error. |
| 91 // path.join('lib', 'html', 'custom'), |
88 path.join('lib', 'math'), | 92 path.join('lib', 'math'), |
89 path.join('lib', 'mirrors'), | 93 path.join('lib', 'mirrors'), |
90 path.join('lib', 'typed_data'), | 94 path.join('lib', 'typed_data'), |
91 ]; | 95 ]; |
92 | 96 |
93 // Copy all of the test files and expanded multitest files to | 97 // Copy all of the test files and expanded multitest files to |
94 // gen/codegen_tests. We'll compile from there. | 98 // gen/codegen_tests. We'll compile from there. |
95 var testFiles = _setUpTests(testDirs); | 99 var testFiles = _setUpTests(testDirs); |
96 | 100 |
97 // Our default compiler options. Individual tests can override these. | 101 // Our default compiler options. Individual tests can override these. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 return source.uri.pathSegments.first; | 215 return source.uri.pathSegments.first; |
212 } | 216 } |
213 throw new Exception('Module not found for library "${source.fullName}"'); | 217 throw new Exception('Module not found for library "${source.fullName}"'); |
214 } | 218 } |
215 | 219 |
216 List<String> _setUpTests(List<String> testDirs) { | 220 List<String> _setUpTests(List<String> testDirs) { |
217 var testFiles = <String>[]; | 221 var testFiles = <String>[]; |
218 | 222 |
219 for (var testDir in testDirs) { | 223 for (var testDir in testDirs) { |
220 for (var file | 224 for (var file |
221 in _listFiles(path.join(codegenDir, testDir), recursive: true)) { | 225 in _listFiles(path.join(codegenDir, testDir), recursive: false)) { |
222 var relativePath = path.relative(file, from: codegenDir); | 226 var relativePath = path.relative(file, from: codegenDir); |
223 var outputPath = path.join(codegenTestDir, relativePath); | 227 var outputPath = path.join(codegenTestDir, relativePath); |
224 | 228 |
225 _ensureDirectory(path.dirname(outputPath)); | 229 _ensureDirectory(path.dirname(outputPath)); |
226 | 230 |
227 // Copy it over. We do this even for multitests because import_self_test | 231 // Copy it over. We do this even for multitests because import_self_test |
228 // is a multitest, yet imports its own unexpanded form (!). | 232 // is a multitest, yet imports its own unexpanded form (!). |
229 new File(file).copySync(outputPath); | 233 new File(file).copySync(outputPath); |
230 | 234 |
231 if (file.endsWith("_test.dart")) { | 235 if (file.endsWith("_test.dart")) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 /// Simplified from ParseDartTask.resolveDirective. | 325 /// Simplified from ParseDartTask.resolveDirective. |
322 String _resolveDirective(UriBasedDirective directive) { | 326 String _resolveDirective(UriBasedDirective directive) { |
323 StringLiteral uriLiteral = directive.uri; | 327 StringLiteral uriLiteral = directive.uri; |
324 String uriContent = uriLiteral.stringValue; | 328 String uriContent = uriLiteral.stringValue; |
325 if (uriContent != null) { | 329 if (uriContent != null) { |
326 uriContent = uriContent.trim(); | 330 uriContent = uriContent.trim(); |
327 directive.uriContent = uriContent; | 331 directive.uriContent = uriContent; |
328 } | 332 } |
329 return directive.validate() == null ? uriContent : null; | 333 return directive.validate() == null ? uriContent : null; |
330 } | 334 } |
OLD | NEW |