Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: pkg/dev_compiler/test/codegen_test.dart

Issue 2474523003: fix #27607, add dev_compiler summary to the SDK and move JS files (Closed)
Patch Set: fix typo Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 RegExp filePattern; 62 RegExp filePattern;
63 63
64 main(List<String> arguments) { 64 main(List<String> arguments) {
65 if (arguments == null) arguments = []; 65 if (arguments == null) arguments = [];
66 ArgResults args = argParser.parse(arguments); 66 ArgResults args = argParser.parse(arguments);
67 filePattern = new RegExp(args.rest.length > 0 ? args.rest[0] : '.'); 67 filePattern = new RegExp(args.rest.length > 0 ? args.rest[0] : '.');
68 68
69 var sdkDir = path.join(repoDirectory, 'gen', 'patched_sdk'); 69 var sdkDir = path.join(repoDirectory, 'gen', 'patched_sdk');
70 var sdkSummaryFile = 70 var sdkSummaryFile =
71 path.join(testDirectory, '..', 'lib', 'js', 'amd', 'dart_sdk.sum'); 71 path.join(testDirectory, '..', 'lib', 'sdk', 'ddc_sdk.sum');
72 72
73 var summaryPaths = new Directory(path.join(codegenOutputDir, 'pkg')) 73 var summaryPaths = new Directory(path.join(codegenOutputDir, 'pkg'))
74 .listSync() 74 .listSync()
75 .map((e) => e.path) 75 .map((e) => e.path)
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);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 167 }
168 168
169 void _writeModule(String outPath, String expectPath, ModuleFormat format, 169 void _writeModule(String outPath, String expectPath, ModuleFormat format,
170 JSModuleFile result) { 170 JSModuleFile result) {
171 _ensureDirectory(path.dirname(outPath)); 171 _ensureDirectory(path.dirname(outPath));
172 172
173 String errors = result.errors.join('\n'); 173 String errors = result.errors.join('\n');
174 if (errors.isNotEmpty && !errors.endsWith('\n')) errors += '\n'; 174 if (errors.isNotEmpty && !errors.endsWith('\n')) errors += '\n';
175 new File(outPath + '.txt').writeAsStringSync(errors); 175 new File(outPath + '.txt').writeAsStringSync(errors);
176 176
177 result.writeCodeSync(format, false, outPath + '.js'); 177 result.writeCodeSync(format, outPath + '.js');
178 178
179 if (result.summaryBytes != null) { 179 if (result.summaryBytes != null) {
180 new File(outPath + '.sum').writeAsBytesSync(result.summaryBytes); 180 new File(outPath + '.sum').writeAsBytesSync(result.summaryBytes);
181 } 181 }
182 182
183 // Write the expectation file if needed. 183 // Write the expectation file if needed.
184 // Generally speaking we try to avoid these tests, but they are occasionally 184 // Generally speaking we try to avoid these tests, but they are occasionally
185 // useful. 185 // useful.
186 if (expectPath != null) { 186 if (expectPath != null) {
187 _ensureDirectory(path.dirname(expectPath)); 187 _ensureDirectory(path.dirname(expectPath));
188 188
189 var expectFile = new File(expectPath + '.js'); 189 var expectFile = new File(expectPath + '.js');
190 if (result.isValid) { 190 if (result.isValid) {
191 result.writeCodeSync(format, false, expectFile.path); 191 result.writeCodeSync(format, expectFile.path);
192 } else { 192 } else {
193 expectFile.writeAsStringSync("//FAILED TO COMPILE"); 193 expectFile.writeAsStringSync("//FAILED TO COMPILE");
194 } 194 }
195 } 195 }
196 } 196 }
197 197
198 void _buildSunflower( 198 void _buildSunflower(
199 ModuleCompiler compiler, String outputDir, String expectDir) { 199 ModuleCompiler compiler, String outputDir, String expectDir) {
200 var baseDir = path.join(codegenDir, 'sunflower'); 200 var baseDir = path.join(codegenDir, 'sunflower');
201 var files = ['sunflower', 'circle', 'painter'] 201 var files = ['sunflower', 'circle', 'painter']
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 /// Simplified from ParseDartTask.resolveDirective. 325 /// Simplified from ParseDartTask.resolveDirective.
326 String _resolveDirective(UriBasedDirective directive) { 326 String _resolveDirective(UriBasedDirective directive) {
327 StringLiteral uriLiteral = directive.uri; 327 StringLiteral uriLiteral = directive.uri;
328 String uriContent = uriLiteral.stringValue; 328 String uriContent = uriLiteral.stringValue;
329 if (uriContent != null) { 329 if (uriContent != null) {
330 uriContent = uriContent.trim(); 330 uriContent = uriContent.trim();
331 directive.uriContent = uriContent; 331 directive.uriContent = uriContent;
332 } 332 }
333 return directive.validate() == null ? uriContent : null; 333 return directive.validate() == null ? uriContent : null;
334 } 334 }
OLDNEW
« no previous file with comments | « pkg/dev_compiler/lib/src/js_ast/module_transform.dart ('k') | pkg/dev_compiler/tool/build_pkgs.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698