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 /// 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:convert' show JSON; | 10 import 'dart:convert' show JSON; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 'corelib', | 43 'corelib', |
44 path.join('lib', 'convert'), | 44 path.join('lib', 'convert'), |
45 path.join('lib', 'html'), | 45 path.join('lib', 'html'), |
46 path.join('lib', 'math'), | 46 path.join('lib', 'math'), |
47 path.join('lib', 'typed_data') | 47 path.join('lib', 'typed_data') |
48 ]; | 48 ]; |
49 | 49 |
50 var multitests = expandMultiTests(testDirs, filePattern); | 50 var multitests = expandMultiTests(testDirs, filePattern); |
51 | 51 |
52 // Build packages tests depend on | 52 // Build packages tests depend on |
53 var compiler = new ModuleCompiler( | 53 var generatedSdkDir = path.join(testDirectory, '..', 'tool', 'generated_sdk'); |
54 new AnalyzerOptions(customUrlMappings: packageUrlMappings)); | 54 var analyzerOptions = new AnalyzerOptions( |
| 55 customUrlMappings: packageUrlMappings, dartSdkPath: generatedSdkDir); |
| 56 var compiler = new ModuleCompiler(analyzerOptions); |
55 | 57 |
56 group('dartdevc package', () { | 58 group('dartdevc package', () { |
57 _buildPackages(compiler, expectDir); | 59 _buildPackages(compiler, expectDir); |
58 | 60 |
59 test('matcher', () { | 61 test('matcher', () { |
60 _buildPackage(compiler, expectDir, "matcher"); | 62 _buildPackage(compiler, expectDir, "matcher"); |
61 }); | 63 }); |
62 | 64 |
63 test('unittest', () { | 65 test('unittest', () { |
64 _buildPackage(compiler, expectDir, "unittest"); | 66 _buildPackage(compiler, expectDir, "unittest"); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 moduleName, baseDir, files.toList(), _moduleForLibrary); | 121 moduleName, baseDir, files.toList(), _moduleForLibrary); |
120 var module = compiler.compile(unit, options); | 122 var module = compiler.compile(unit, options); |
121 _writeModule(path.join(outDir.path, filename), module); | 123 _writeModule(path.join(outDir.path, filename), module); |
122 }); | 124 }); |
123 } | 125 } |
124 }); | 126 }); |
125 } | 127 } |
126 | 128 |
127 if (codeCoverage) { | 129 if (codeCoverage) { |
128 test('build_sdk code coverage', () { | 130 test('build_sdk code coverage', () { |
129 var generatedSdkDir = | |
130 path.join(testDirectory, '..', 'tool', 'generated_sdk'); | |
131 return build_sdk.main(['--dart-sdk', generatedSdkDir, '-o', expectDir]); | 131 return build_sdk.main(['--dart-sdk', generatedSdkDir, '-o', expectDir]); |
132 }); | 132 }); |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 void _writeModule(String outPath, JSModuleFile result) { | 136 void _writeModule(String outPath, JSModuleFile result) { |
137 new Directory(path.dirname(outPath)).createSync(recursive: true); | 137 new Directory(path.dirname(outPath)).createSync(recursive: true); |
138 | 138 |
139 String errors = result.errors.join('\n'); | 139 String errors = result.errors.join('\n'); |
140 if (errors.isNotEmpty && !errors.endsWith('\n')) errors += '\n'; | 140 if (errors.isNotEmpty && !errors.endsWith('\n')) errors += '\n'; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 /// Simplified from ParseDartTask.resolveDirective. | 306 /// Simplified from ParseDartTask.resolveDirective. |
307 String _resolveDirective(UriBasedDirective directive) { | 307 String _resolveDirective(UriBasedDirective directive) { |
308 StringLiteral uriLiteral = directive.uri; | 308 StringLiteral uriLiteral = directive.uri; |
309 String uriContent = uriLiteral.stringValue; | 309 String uriContent = uriLiteral.stringValue; |
310 if (uriContent != null) { | 310 if (uriContent != null) { |
311 uriContent = uriContent.trim(); | 311 uriContent = uriContent.trim(); |
312 directive.uriContent = uriContent; | 312 directive.uriContent = uriContent; |
313 } | 313 } |
314 return directive.validate() == null ? uriContent : null; | 314 return directive.validate() == null ? uriContent : null; |
315 } | 315 } |
OLD | NEW |