OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 /// Tests basic functionality of the API tree-shaker. | 5 /// Tests basic functionality of the API tree-shaker. |
6 /// | 6 /// |
7 /// Each input file is built and tree-shaken, then we check that the set of | 7 /// Each input file is built and tree-shaken, then we check that the set of |
8 /// libraries, classes, and members that are retained match those declared in an | 8 /// libraries, classes, and members that are retained match those declared in an |
9 /// expectations file. | 9 /// expectations file. |
10 /// | 10 /// |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 Future<Result<_IntermediateData>> run( | 98 Future<Result<_IntermediateData>> run( |
99 TestDescription description, TreeShakerContext context) async { | 99 TestDescription description, TreeShakerContext context) async { |
100 try { | 100 try { |
101 var platformOutline = context.loadPlatformOutline(); | 101 var platformOutline = context.loadPlatformOutline(); |
102 platformOutline.unbindCanonicalNames(); | 102 platformOutline.unbindCanonicalNames(); |
103 var dillTarget = new DillTarget( | 103 var dillTarget = new DillTarget( |
104 new Ticker(isVerbose: false), | 104 new Ticker(isVerbose: false), |
105 context.uriTranslator, | 105 context.uriTranslator, |
106 new VmFastaTarget(new TargetFlags(strongMode: false))); | 106 new VmFastaTarget(new TargetFlags(strongMode: false))); |
107 dillTarget.loader.appendLibraries(platformOutline); | 107 dillTarget.loader.appendLibraries(platformOutline); |
108 var sourceTarget = new KernelTarget( | 108 var sourceTarget = new KernelTarget(PhysicalFileSystem.instance, false, |
109 PhysicalFileSystem.instance, dillTarget, context.uriTranslator); | 109 dillTarget, context.uriTranslator); |
110 await dillTarget.buildOutlines(); | 110 await dillTarget.buildOutlines(); |
111 | 111 |
112 var inputUri = description.uri; | 112 var inputUri = description.uri; |
113 var libUri = inputUri.resolve('lib/lib.dart'); | 113 var libUri = inputUri.resolve('lib/lib.dart'); |
114 sourceTarget.read(libUri); | 114 sourceTarget.read(libUri); |
115 sourceTarget.read(inputUri); | 115 sourceTarget.read(inputUri); |
116 var contents = new File.fromUri(inputUri).readAsStringSync(); | 116 var contents = new File.fromUri(inputUri).readAsStringSync(); |
117 var showCoreLibraries = contents.contains("@@SHOW_CORE_LIBRARIES@@"); | 117 var showCoreLibraries = contents.contains("@@SHOW_CORE_LIBRARIES@@"); |
118 await sourceTarget.buildOutlines(); | 118 await sourceTarget.buildOutlines(); |
119 var program = await sourceTarget.buildProgram(); | 119 var program = await sourceTarget.buildProgram(); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 } | 219 } |
220 | 220 |
221 /// A special library used only to test the shaker. The suite above will | 221 /// A special library used only to test the shaker. The suite above will |
222 /// tree-shake the contents of this library. | 222 /// tree-shake the contents of this library. |
223 const _specialLibraryPath = 'pkg/front_end/testcases/shaker/lib/lib.dart'; | 223 const _specialLibraryPath = 'pkg/front_end/testcases/shaker/lib/lib.dart'; |
224 | 224 |
225 /// Tree-shake dart:* libraries and the library under [_specialLibraryPath]. | 225 /// Tree-shake dart:* libraries and the library under [_specialLibraryPath]. |
226 bool _isTreeShaken(Uri uri) => | 226 bool _isTreeShaken(Uri uri) => |
227 uri.isScheme('dart') || | 227 uri.isScheme('dart') || |
228 Uri.base.resolveUri(uri).path.endsWith(_specialLibraryPath); | 228 Uri.base.resolveUri(uri).path.endsWith(_specialLibraryPath); |
OLD | NEW |