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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 var sdkDir = path.join(repoDirectory, 'gen', 'patched_sdk'); | 72 var sdkDir = path.join(repoDirectory, 'gen', 'patched_sdk'); |
73 var sdkSummaryFile = | 73 var sdkSummaryFile = |
74 path.join(testDirectory, '..', 'lib', 'sdk', 'ddc_sdk.sum'); | 74 path.join(testDirectory, '..', 'lib', 'sdk', 'ddc_sdk.sum'); |
75 | 75 |
76 var summaryPaths = new Directory(path.join(codegenOutputDir, 'pkg')) | 76 var summaryPaths = new Directory(path.join(codegenOutputDir, 'pkg')) |
77 .listSync() | 77 .listSync() |
78 .map((e) => e.path) | 78 .map((e) => e.path) |
79 .where((p) => p.endsWith('.sum')) | 79 .where((p) => p.endsWith('.sum')) |
80 .toList(); | 80 .toList(); |
81 | 81 |
82 var sharedCompiler = new ModuleCompiler(new AnalyzerOptions.basic( | 82 var sharedCompiler = new ModuleCompiler( |
83 dartSdkSummaryPath: sdkSummaryFile, summaryPaths: summaryPaths)); | 83 repoDirectory, |
| 84 new AnalyzerOptions.basic( |
| 85 dartSdkSummaryPath: sdkSummaryFile, summaryPaths: summaryPaths)); |
84 | 86 |
85 var testDirs = [ | 87 var testDirs = [ |
86 'language', | 88 'language', |
87 'corelib', | 89 'corelib', |
88 path.join('corelib', 'regexp'), | 90 path.join('corelib', 'regexp'), |
89 path.join('lib', 'collection'), | 91 path.join('lib', 'collection'), |
90 path.join('lib', 'convert'), | 92 path.join('lib', 'convert'), |
91 path.join('lib', 'html'), | 93 path.join('lib', 'html'), |
92 // TODO(vsm): Fix these - they import files from a different directory | 94 // TODO(vsm): Fix these - they import files from a different directory |
93 // - this triggers an invalid library root build error. | 95 // - this triggers an invalid library root build error. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 var moduleFormat = parseModuleFormatOption(argResults).first; | 151 var moduleFormat = parseModuleFormatOption(argResults).first; |
150 | 152 |
151 // Collect any other files we've imported. | 153 // Collect any other files we've imported. |
152 var files = new Set<String>(); | 154 var files = new Set<String>(); |
153 _collectTransitiveImports(contents, files, from: testFile); | 155 _collectTransitiveImports(contents, files, from: testFile); |
154 var unit = new BuildUnit( | 156 var unit = new BuildUnit( |
155 name, path.dirname(testFile), files.toList(), _moduleForLibrary); | 157 name, path.dirname(testFile), files.toList(), _moduleForLibrary); |
156 | 158 |
157 var compiler = sharedCompiler; | 159 var compiler = sharedCompiler; |
158 if (analyzerOptions.declaredVariables.isNotEmpty) { | 160 if (analyzerOptions.declaredVariables.isNotEmpty) { |
159 compiler = new ModuleCompiler(analyzerOptions); | 161 compiler = new ModuleCompiler(repoDirectory, analyzerOptions); |
160 } | 162 } |
161 var module = compiler.compile(unit, options); | 163 var module = compiler.compile(unit, options); |
162 | 164 |
163 bool notStrong = notYetStrongTests.contains(name); | 165 bool notStrong = notYetStrongTests.contains(name); |
164 if (module.isValid) { | 166 if (module.isValid) { |
165 _writeModule( | 167 _writeModule( |
166 path.join(codegenOutputDir, name), | 168 path.join(codegenOutputDir, name), |
167 isTopLevelTest ? path.join(codegenExpectDir, name) : null, | 169 isTopLevelTest ? path.join(codegenExpectDir, name) : null, |
168 moduleFormat, | 170 moduleFormat, |
169 module); | 171 module); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 StringLiteral uriLiteral = directive.uri; | 360 StringLiteral uriLiteral = directive.uri; |
359 String uriContent = uriLiteral.stringValue; | 361 String uriContent = uriLiteral.stringValue; |
360 if (uriContent != null) { | 362 if (uriContent != null) { |
361 uriContent = uriContent.trim(); | 363 uriContent = uriContent.trim(); |
362 directive.uriContent = uriContent; | 364 directive.uriContent = uriContent; |
363 } | 365 } |
364 return (directive as UriBasedDirectiveImpl).validate() == null | 366 return (directive as UriBasedDirectiveImpl).validate() == null |
365 ? uriContent | 367 ? uriContent |
366 : null; | 368 : null; |
367 } | 369 } |
OLD | NEW |