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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 return loadProgramFromBytes(outlineBytes); | 68 return loadProgramFromBytes(outlineBytes); |
69 } | 69 } |
70 | 70 |
71 static create(Map<String, String> environment) async { | 71 static create(Map<String, String> environment) async { |
72 environment[ENABLE_FULL_COMPILE] = ""; | 72 environment[ENABLE_FULL_COMPILE] = ""; |
73 environment[AST_KIND_INDEX] = "${AstKind.Kernel.index}"; | 73 environment[AST_KIND_INDEX] = "${AstKind.Kernel.index}"; |
74 bool updateExpectations = environment["updateExpectations"] == "true"; | 74 bool updateExpectations = environment["updateExpectations"] == "true"; |
75 Uri sdk = await computePatchedSdk(); | 75 Uri sdk = await computePatchedSdk(); |
76 Uri outlineUri = sdk.resolve('outline.dill'); | 76 Uri outlineUri = sdk.resolve('outline.dill'); |
77 Uri packages = Uri.base.resolve(".packages"); | 77 Uri packages = Uri.base.resolve(".packages"); |
78 TranslateUri uriTranslator = | 78 TranslateUri uriTranslator = await TranslateUri |
79 await TranslateUri.parse(PhysicalFileSystem.instance, packages); | 79 .parse(PhysicalFileSystem.instance, sdk, packages: packages); |
80 List<int> outlineBytes = new File.fromUri(outlineUri).readAsBytesSync(); | 80 List<int> outlineBytes = new File.fromUri(outlineUri).readAsBytesSync(); |
81 return new TreeShakerContext( | 81 return new TreeShakerContext( |
82 outlineUri, uriTranslator, outlineBytes, updateExpectations); | 82 outlineUri, uriTranslator, outlineBytes, updateExpectations); |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 /// Step that extracts the test-specific options and builds the program without | 86 /// Step that extracts the test-specific options and builds the program without |
87 /// applying tree-shaking. | 87 /// applying tree-shaking. |
88 class BuildProgram | 88 class BuildProgram |
89 extends Step<TestDescription, _IntermediateData, TreeShakerContext> { | 89 extends Step<TestDescription, _IntermediateData, TreeShakerContext> { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 """ | 232 """ |
233 Please create file ${expectedFile.path} with this content: | 233 Please create file ${expectedFile.path} with this content: |
234 $buffer"""); | 234 $buffer"""); |
235 } | 235 } |
236 } | 236 } |
237 } | 237 } |
238 | 238 |
239 /// A special library used only to test the shaker. The suite above will | 239 /// A special library used only to test the shaker. The suite above will |
240 /// tree-shake the contents of this library. | 240 /// tree-shake the contents of this library. |
241 const _specialLibraryPath = 'pkg/front_end/testcases/shaker/lib/lib.dart'; | 241 const _specialLibraryPath = 'pkg/front_end/testcases/shaker/lib/lib.dart'; |
OLD | NEW |