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

Unified Diff: pkg/front_end/test/incremental_kernel_generator_test.dart

Issue 2885743002: Include only changed or affected libraries into delta. (Closed)
Patch Set: Created 3 years, 7 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
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 ca97c3ebdeb03c8624b757499ad939668f736a58..fa0067b07886faf82e37529c4a509deb654002df 100644
--- a/pkg/front_end/test/incremental_kernel_generator_test.dart
+++ b/pkg/front_end/test/incremental_kernel_generator_test.dart
@@ -54,7 +54,7 @@ class IncrementalKernelGeneratorTest {
String aPath = '/test/lib/a.dart';
String bPath = '/test/lib/b.dart';
String cPath = '/test/lib/c.dart';
- writeFile(aPath, 'var a = 1;');
+ Uri aUri = writeFile(aPath, 'var a = 1;');
Uri bUri = writeFile(
bPath,
r'''
@@ -72,6 +72,8 @@ var c2 = b;
{
Program program = await getInitialState(cUri);
+ _assertLibraryUris(program,
+ includes: [aUri, bUri, cUri, Uri.parse('dart:core')]);
Library library = _getLibrary(program, cUri);
expect(
_getLibraryText(library),
@@ -85,7 +87,6 @@ import "./b.dart" as b;
static field core::int c1 = a::a;
static field core::int c2 = b::b;
''');
- // TODO(scheglov) Check that the program contains all libraries.
}
// Update b.dart and recompile c.dart
@@ -98,7 +99,9 @@ var b = 1.2;
incrementalKernelGenerator.invalidate(bUri);
{
DeltaProgram delta = await incrementalKernelGenerator.computeDelta();
- var program = delta.newProgram;
+ Program program = delta.newProgram;
+ _assertLibraryUris(program,
+ includes: [bUri, cUri], excludes: [aUri, Uri.parse('dart:core')]);
var library = _getLibrary(program, cUri);
expect(
_getLibraryText(library),
@@ -112,14 +115,34 @@ import "./b.dart" as b;
static field core::int c1 = a::a;
static field core::double c2 = b::b;
''');
- // TODO(scheglov) Check that the delta contains b.dart and c.dart,
- // but not a.dart or SDK.
-// print(_getLibraryText(_getLibrary(program, aUri)));
-// print(_getLibraryText(_getLibrary(program, bUri)));
-// print(_getLibraryText(_getLibrary(program, cUri)));
}
}
+ test_compile_typedef() async {
+ writeFile('/test/.packages', 'test:lib/');
+ String aPath = '/test/lib/a.dart';
+ String bPath = '/test/lib/b.dart';
+ writeFile(aPath, 'typedef int F<T>(T x);');
+ Uri bUri = writeFile(
+ bPath,
+ r'''
+import 'a.dart';
+F<String> f;
+''');
+
+ Program program = await getInitialState(bUri);
+ Library library = _getLibrary(program, bUri);
+ expect(
+ _getLibraryText(library),
+ r'''
+library;
+import self as self;
+import "dart:core" as core;
+
+static field (core::String) → core::int f;
+''');
+ }
+
test_updateEntryPoint() async {
writeFile('/test/.packages', 'test:lib/');
String path = '/test/lib/test.dart';
@@ -157,19 +180,19 @@ main() {
}
''');
- // Because we have not invalidated the file, we get the same library.
- // TODO(scheglov) Eventually we should get an empty Program.
+ // We have not invalidated the file, so the delta is empty.
{
DeltaProgram delta = await incrementalKernelGenerator.computeDelta();
- Library library = _getLibrary(delta.newProgram, uri);
- expect(_getLibraryText(library), initialText);
+ expect(delta.newProgram.libraries, isEmpty);
}
// Invalidate the file, so get the new text.
incrementalKernelGenerator.invalidate(uri);
{
DeltaProgram delta = await incrementalKernelGenerator.computeDelta();
- Library library = _getLibrary(delta.newProgram, uri);
+ Program program = delta.newProgram;
+ _assertLibraryUris(program, includes: [uri]);
+ Library library = _getLibrary(program, uri);
expect(
_getLibraryText(library),
r'''
@@ -184,31 +207,6 @@ static method main() → dynamic {
}
}
- test_compile_typedef() async {
- writeFile('/test/.packages', 'test:lib/');
- String aPath = '/test/lib/a.dart';
- String bPath = '/test/lib/b.dart';
- writeFile(aPath, 'typedef int F<T>(T x);');
- Uri bUri = writeFile(
- bPath,
- r'''
-import 'a.dart';
-F<String> f;
-''');
-
- Program program = await getInitialState(bUri);
- Library library = _getLibrary(program, bUri);
- expect(
- _getLibraryText(library),
- r'''
-library;
-import self as self;
-import "dart:core" as core;
-
-static field (core::String) → core::int f;
-''');
- }
-
test_updatePart() async {
writeFile('/test/.packages', 'test:lib/');
String libPath = '/test/lib/test.dart';
@@ -317,6 +315,18 @@ static method main() → void {}
contents.forEach(writeFile);
}
+ void _assertLibraryUris(Program program,
+ {List<Uri> includes: const [], List<Uri> excludes: const []}) {
+ List<Uri> libraryUris =
+ program.libraries.map((library) => library.importUri).toList();
+ for (var shouldInclude in includes) {
+ expect(libraryUris, contains(shouldInclude));
+ }
+ for (var shouldExclude in excludes) {
+ expect(libraryUris, isNot(contains(shouldExclude)));
+ }
+ }
+
Library _getLibrary(Program program, Uri uri) {
for (var library in program.libraries) {
if (library.importUri == uri) return library;

Powered by Google App Engine
This is Rietveld 408576698