Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Unified Diff: pkg/front_end/test/src/incremental/kernel_driver_test.dart

Issue 2993093003: Add support for SDK outline in KernelDriver. (Closed)
Patch Set: Merge and tweaks. Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/front_end/test/memory_file_system_test.dart ('k') | pkg/front_end/test/src/incremental/mock_sdk.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/test/src/incremental/kernel_driver_test.dart
diff --git a/pkg/front_end/test/src/incremental/kernel_driver_test.dart b/pkg/front_end/test/src/incremental/kernel_driver_test.dart
index 67f3e088c9970a056c3b2aae7ee501fd66266f0e..6dccd9e8192a6358eda14cd55c5a5ec28e244969 100644
--- a/pkg/front_end/test/src/incremental/kernel_driver_test.dart
+++ b/pkg/front_end/test/src/incremental/kernel_driver_test.dart
@@ -12,6 +12,7 @@ import 'package:front_end/src/fasta/kernel/utils.dart';
import 'package:front_end/src/fasta/uri_translator_impl.dart';
import 'package:front_end/src/incremental/byte_store.dart';
import 'package:front_end/src/incremental/kernel_driver.dart';
+import 'package:front_end/summary_generator.dart';
import 'package:kernel/ast.dart';
import 'package:kernel/binary/ast_from_binary.dart';
import 'package:kernel/target/targets.dart';
@@ -286,6 +287,34 @@ static field (core::String) → core::int f;
expect(result.types.hierarchy, isNotNull);
}
+ test_compile_useSdkOutline() async {
+ List<int> sdkOutlineBytes = await _computeSdkOutlineBytes();
+
+ // Configure the driver to use the SDK outline.
+ _createDriver(sdkOutlineBytes: sdkOutlineBytes);
+
+ writeFile('/test/.packages', 'test:lib/');
+ String aPath = '/test/lib/a.dart';
+ Uri aUri = writeFile(aPath, r'''
+import 'dart:async';
+var a = 1;
+Future<String> b;
+''');
+
+ KernelResult result = await driver.getKernel(aUri);
+
+ // The result does not include SDK libraries.
+ _assertLibraryUris(result,
+ includes: [aUri],
+ excludes: [Uri.parse('dart:core'), Uri.parse('dart:core')]);
+
+ // The types of top-level variables are resolved.
+ var library = _getLibrary(result, aUri);
+ expect(library.fields[0].type.toString(), 'dart.core::int');
+ expect(library.fields[1].type.toString(),
+ 'dart.async::Future<dart.core::String>');
+ }
+
test_limitedStore_exportDependencies() async {
writeFile('/test/.packages', 'test:lib/');
String aPath = '/test/lib/a.dart';
@@ -647,20 +676,35 @@ import 'b.dart';
}
}
+ Future<List<int>> _computeSdkOutlineBytes() async {
+ var options = new CompilerOptions()
+ ..fileSystem = fileSystem
+ ..sdkRoot = Uri.parse('file:///sdk/')
+ ..compileSdk = true
+ ..chaseDependencies = true
+ ..strongMode = true
+ ..target = new NoneTarget(new TargetFlags(strongMode: true));
+ var inputs = [Uri.parse('dart:core')];
+ return summaryFor(inputs, options);
+ }
+
/// Create new [KernelDriver] instance and put it into the [driver] field.
void _createDriver(
- {Map<String, Uri> packages, KernelDriverFileAddedFn fileAddedFn}) {
+ {List<int> sdkOutlineBytes,
+ Map<String, Uri> packages,
+ KernelDriverFileAddedFn fileAddedFn}) {
var uriTranslator = new UriTranslatorImpl(
createSdkFiles(fileSystem), new MapPackages(packages));
- driver = new KernelDriver(
- new ProcessedOptions(new CompilerOptions()
- ..logger = new PerformanceLog(null)
- ..fileSystem = fileSystem
- ..byteStore = new MemoryByteStore()
- ..strongMode = true
- ..target = new NoneTarget(new TargetFlags(strongMode: true))),
- uriTranslator,
- fileAddedFn: fileAddedFn);
+
+ var options = new CompilerOptions()
+ ..logger = new PerformanceLog(null)
+ ..fileSystem = fileSystem
+ ..byteStore = new MemoryByteStore()
+ ..strongMode = true
+ ..target = new NoneTarget(new TargetFlags(strongMode: true));
+
+ driver = new KernelDriver(new ProcessedOptions(options), uriTranslator,
+ sdkOutlineBytes: sdkOutlineBytes, fileAddedFn: fileAddedFn);
}
Library _getLibrary(KernelResult result, Uri uri) {
« no previous file with comments | « pkg/front_end/test/memory_file_system_test.dart ('k') | pkg/front_end/test/src/incremental/mock_sdk.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698