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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // TODO(jmesserly): switch this to a .packages file. | 56 // TODO(jmesserly): switch this to a .packages file. |
57 final packageUrlMappings = { | 57 final packageUrlMappings = { |
58 'package:expect/expect.dart': path.join(codegenDir, 'expect.dart'), | 58 'package:expect/expect.dart': path.join(codegenDir, 'expect.dart'), |
59 'package:async_helper/async_helper.dart': | 59 'package:async_helper/async_helper.dart': |
60 path.join(codegenDir, 'async_helper.dart'), | 60 path.join(codegenDir, 'async_helper.dart'), |
61 'package:js/js.dart': path.join(codegenDir, 'packages', 'js', 'js.dart') | 61 'package:js/js.dart': path.join(codegenDir, 'packages', 'js', 'js.dart') |
62 }; | 62 }; |
63 | 63 |
64 final codeCoverage = Platform.environment.containsKey('COVERALLS_TOKEN'); | 64 final codeCoverage = Platform.environment.containsKey('COVERALLS_TOKEN'); |
65 | 65 |
66 main(arguments) { | 66 main(List<String> arguments) { |
67 if (arguments == null) arguments = []; | 67 if (arguments == null) arguments = []; |
68 ArgResults args = argParser.parse(arguments); | 68 ArgResults args = argParser.parse(arguments); |
69 var filePattern = new RegExp(args.rest.length > 0 ? args.rest[0] : '.'); | 69 var filePattern = new RegExp(args.rest.length > 0 ? args.rest[0] : '.'); |
70 | 70 |
71 var sdkDir = path.join(repoDirectory, 'gen', 'patched_sdk'); | 71 var sdkDir = path.join(repoDirectory, 'gen', 'patched_sdk'); |
72 var sdkSummaryFile = | 72 var sdkSummaryFile = |
73 path.join(testDirectory, '..', 'lib', 'runtime', 'dart_sdk.sum'); | 73 path.join(testDirectory, '..', 'lib', 'runtime', 'dart_sdk.sum'); |
74 var analyzerOptions = new AnalyzerOptions( | 74 var analyzerOptions = new AnalyzerOptions( |
75 customUrlMappings: packageUrlMappings, | 75 customUrlMappings: packageUrlMappings, |
76 dartSdkSummaryPath: sdkSummaryFile); | 76 dartSdkSummaryPath: sdkSummaryFile); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 268 |
269 String _moduleForLibrary(Source source) { | 269 String _moduleForLibrary(Source source) { |
270 var scheme = source.uri.scheme; | 270 var scheme = source.uri.scheme; |
271 if (scheme == 'package') { | 271 if (scheme == 'package') { |
272 return source.uri.pathSegments.first; | 272 return source.uri.pathSegments.first; |
273 } | 273 } |
274 throw new Exception('Module not found for library "${source.fullName}"'); | 274 throw new Exception('Module not found for library "${source.fullName}"'); |
275 } | 275 } |
276 | 276 |
277 List<String> _setUpTests(List<String> testDirs, RegExp filePattern) { | 277 List<String> _setUpTests(List<String> testDirs, RegExp filePattern) { |
278 var testFiles = []; | 278 var testFiles = <String>[]; |
279 | 279 |
280 for (var testDir in testDirs) { | 280 for (var testDir in testDirs) { |
281 for (var file in _listFiles(path.join(codegenDir, testDir), filePattern, | 281 for (var file in _listFiles(path.join(codegenDir, testDir), filePattern, |
282 recursive: true)) { | 282 recursive: true)) { |
283 var relativePath = path.relative(file, from: codegenDir); | 283 var relativePath = path.relative(file, from: codegenDir); |
284 var outputPath = path.join(codegenTestDir, relativePath); | 284 var outputPath = path.join(codegenTestDir, relativePath); |
285 | 285 |
286 _ensureDirectory(path.dirname(outputPath)); | 286 _ensureDirectory(path.dirname(outputPath)); |
287 | 287 |
288 // Copy it over. We do this even for multitests because import_self_test | 288 // Copy it over. We do this even for multitests because import_self_test |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 /// Simplified from ParseDartTask.resolveDirective. | 383 /// Simplified from ParseDartTask.resolveDirective. |
384 String _resolveDirective(UriBasedDirective directive) { | 384 String _resolveDirective(UriBasedDirective directive) { |
385 StringLiteral uriLiteral = directive.uri; | 385 StringLiteral uriLiteral = directive.uri; |
386 String uriContent = uriLiteral.stringValue; | 386 String uriContent = uriLiteral.stringValue; |
387 if (uriContent != null) { | 387 if (uriContent != null) { |
388 uriContent = uriContent.trim(); | 388 uriContent = uriContent.trim(); |
389 directive.uriContent = uriContent; | 389 directive.uriContent = uriContent; |
390 } | 390 } |
391 return directive.validate() == null ? uriContent : null; | 391 return directive.validate() == null ? uriContent : null; |
392 } | 392 } |
OLD | NEW |