Chromium Code Reviews| Index: pkg/front_end/test/incremental_kernel_generator_test.dart |
| diff --git a/pkg/front_end/test/incremental_kernel_generator_test.dart b/pkg/front_end/test/incremental_kernel_generator_test.dart |
| index c3bbeb91f4b5ef9bd6c0c8ae50cc321c2ce976aa..28f15faba62ba48d6e29a0ef26c19aaac57c314e 100644 |
| --- a/pkg/front_end/test/incremental_kernel_generator_test.dart |
| +++ b/pkg/front_end/test/incremental_kernel_generator_test.dart |
| @@ -9,6 +9,7 @@ import 'package:front_end/incremental_kernel_generator.dart'; |
| import 'package:front_end/memory_file_system.dart'; |
| import 'package:front_end/src/incremental/byte_store.dart'; |
| import 'package:front_end/src/incremental_kernel_generator_impl.dart'; |
| +import 'package:front_end/summary_generator.dart'; |
| import 'package:kernel/ast.dart'; |
| import 'package:kernel/text/ast_to_text.dart'; |
| import 'package:test/test.dart'; |
| @@ -35,7 +36,7 @@ class IncrementalKernelGeneratorTest { |
| /// Compute the initial [Program] for the given [entryPoint]. |
| Future<Program> getInitialState(Uri entryPoint, |
| - {bool setPackages: true}) async { |
| + {Uri sdkOutlineUri, bool setPackages: true}) async { |
| createSdkFiles(fileSystem); |
| // TODO(scheglov) Builder the SDK kernel and set it into the options. |
| @@ -45,7 +46,8 @@ class IncrementalKernelGeneratorTest { |
| // ..logger = new PerformanceLog(stdout) |
| ..strongMode = true |
| ..chaseDependencies = true |
| - ..librariesSpecificationUri = Uri.parse('file:///sdk/lib/libraries.json'); |
| + ..librariesSpecificationUri = Uri.parse('file:///sdk/lib/libraries.json') |
| + ..sdkSummary = sdkOutlineUri; |
| if (setPackages) { |
| compilerOptions.packagesFileUri = Uri.parse('file:///test/.packages'); |
| @@ -174,6 +176,60 @@ b() { |
| } |
| } |
| + solo_test_compile_useSdkOutline() async { |
|
Paul Berry
2017/08/07 18:37:13
Remove "solo_"
scheglov
2017/08/07 20:47:51
Done.
|
| + createSdkFiles(fileSystem); |
| + List<int> sdkOutlineBytes = await _computeSdkOutlineBytes(); |
| + |
| + Uri sdkOutlineUri = Uri.parse('file:///sdk/outline.dill'); |
| + fileSystem.entityForUri(sdkOutlineUri).writeAsBytesSync(sdkOutlineBytes); |
| + |
| + writeFile('/test/.packages', 'test:lib/'); |
| + String path = '/test/lib/test.dart'; |
| + Uri uri = writeFile(path, r''' |
| +import 'dart:async'; |
| +var a = 1; |
| +Future<String> b; |
| +'''); |
| + |
| + Program program = await getInitialState(uri, sdkOutlineUri: sdkOutlineUri); |
| + _assertLibraryUris(program, |
| + includes: [uri], excludes: [Uri.parse('dart:core')]); |
| + |
| + Library library = _getLibrary(program, uri); |
| + expect(_getLibraryText(library), r'''library; |
| +import self as self; |
| +import "dart:core" as core; |
| +import "dart:async" as asy; |
| + |
| +static field core::int a = 1; |
| +static field asy::Future<core::String> b; |
| +'''); |
| + } |
|
Siggi Cherem (dart-lang)
2017/08/07 19:12:52
consider adding a test that we don't use the summa
scheglov
2017/08/07 20:47:51
Hm...
We could do this, but it seems a bit stretch
|
| + |
| + test_inferPackagesFile() async { |
| + writeFile('/test/.packages', 'test:lib/'); |
| + String aPath = '/test/lib/a.dart'; |
| + String bPath = '/test/lib/b.dart'; |
| + writeFile(aPath, 'var a = 1;'); |
| + Uri bUri = writeFile(bPath, r''' |
| +import "package:test/a.dart"; |
| +var b = a; |
| +'''); |
| + |
| + // Ensures that the `.packages` file can be discovered automatically |
| + // from the entry point file. |
| + Program program = await getInitialState(bUri, setPackages: false); |
| + Library library = _getLibrary(program, bUri); |
| + expect(_getLibraryText(library), r''' |
| +library; |
| +import self as self; |
| +import "dart:core" as core; |
| +import "package:test/a.dart" as a; |
| + |
| +static field core::int b = a::a; |
| +'''); |
| + } |
| + |
| test_updateEntryPoint() async { |
| writeFile('/test/.packages', 'test:lib/'); |
| String path = '/test/lib/test.dart'; |
| @@ -232,30 +288,6 @@ static method main() → dynamic { |
| } |
| } |
| - test_inferPackagesFile() async { |
| - writeFile('/test/.packages', 'test:lib/'); |
| - String aPath = '/test/lib/a.dart'; |
| - String bPath = '/test/lib/b.dart'; |
| - writeFile(aPath, 'var a = 1;'); |
| - Uri bUri = writeFile(bPath, r''' |
| -import "package:test/a.dart"; |
| -var b = a; |
| -'''); |
| - |
| - // Ensures that the `.packages` file can be discovered automatically |
| - // from the entry point file. |
| - Program program = await getInitialState(bUri, setPackages: false); |
| - Library library = _getLibrary(program, bUri); |
| - expect(_getLibraryText(library), r''' |
| -library; |
| -import self as self; |
| -import "dart:core" as core; |
| -import "package:test/a.dart" as a; |
| - |
| -static field core::int b = a::a; |
| -'''); |
| - } |
| - |
| test_watch() async { |
| writeFile('/test/.packages', 'test:lib/'); |
| String aPath = '/test/lib/a.dart'; |
| @@ -371,6 +403,17 @@ import 'a.dart'; |
| } |
| } |
| + Future<List<int>> _computeSdkOutlineBytes() async { |
| + var options = new CompilerOptions() |
| + ..fileSystem = fileSystem |
| + ..sdkRoot = Uri.parse('file:///sdk/') |
| + ..compileSdk = true |
| + ..chaseDependencies = true |
| + ..strongMode = true; |
| + var inputs = [Uri.parse('dart:core')]; |
| + return summaryFor(inputs, options); |
| + } |
| + |
| Library _getLibrary(Program program, Uri uri) { |
| for (var library in program.libraries) { |
| if (library.importUri == uri) return library; |