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

Unified Diff: pkg/analyzer/test/src/context/context_test.dart

Issue 2050573003: Issue 26629. Detect cache inconsistency in GetContentTask. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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
« pkg/analyzer/lib/task/model.dart ('K') | « pkg/analyzer/lib/task/model.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/context/context_test.dart
diff --git a/pkg/analyzer/test/src/context/context_test.dart b/pkg/analyzer/test/src/context/context_test.dart
index ea41470e1737046d26d206d8d77cc36484d646f6..7f73e3d2ba8229ea92025189b49f2fc855f8fe4b 100644
--- a/pkg/analyzer/test/src/context/context_test.dart
+++ b/pkg/analyzer/test/src/context/context_test.dart
@@ -856,6 +856,57 @@ part of lib;
isTrue);
}
+ void test_flushResolvedUnit_updateFile_dontNotify() {
+ String oldCode = '';
+ String newCode = r'''
+import 'dart:async';
+''';
+ String path = '/test.dart';
+ Source source = resourceProvider.newFile(path, oldCode).createSource();
+ context.applyChanges(new ChangeSet()..addedSource(source));
+ context.resolveCompilationUnit2(source, source);
+ // Flush all results units.
+ context.analysisCache.flush((target, result) {
+ if (target.source == source) {
+ return RESOLVED_UNIT_RESULTS.contains(result);
+ }
+ return false;
+ });
+ // Update the file, but don't notify the context.
+ resourceProvider.updateFile(path, newCode);
+ // Driver must detect that the file was changed and recover.
+ CompilationUnit unit = context.resolveCompilationUnit2(source, source);
+ expect(unit, isNotNull);
+ }
+
+ void test_flushResolvedUnit_updateFile_dontNotify2() {
+ String oldCode = r'''
+main() {}
+''';
+ String newCode = r'''
+import 'dart:async';
+main() {}
+''';
+ String path = '/test.dart';
+ Source source = resourceProvider.newFile(path, oldCode).createSource();
+ context.applyChanges(new ChangeSet()..addedSource(source));
+ context.resolveCompilationUnit2(source, source);
+ // Flush all results units.
+ context.analysisCache.flush((target, result) {
+ if (target.source == source) {
+ if (target.source == source) {
+ return RESOLVED_UNIT_RESULTS.contains(result);
+ }
+ }
+ return false;
+ });
+ // Update the file, but don't notify the context.
+ resourceProvider.updateFile(path, newCode);
+ // Driver must detect that the file was changed and recover.
+ CompilationUnit unit = context.resolveCompilationUnit2(source, source);
+ expect(unit, isNotNull);
+ }
+
void test_getAnalysisOptions() {
expect(context.analysisOptions, isNotNull);
}
@@ -1956,7 +2007,7 @@ library expectedToFindSemicolon
if (AnalysisEngine.instance.limitInvalidationInTaskModel) {
expect(source.readCount, 7);
} else {
- expect(source.readCount, 5);
+ expect(source.readCount, 4);
}
}
@@ -2171,6 +2222,17 @@ class ClassTwo {
["dart.core", "dart.async", "dart.math", "libA", "libB"]);
}
+// void test_resolveCompilationUnit_sourceChangeDuringResolution() {
+// _context = new _AnalysisContext_sourceChangeDuringResolution();
+// AnalysisContextFactory.initContextWithCore(_context);
+// _sourceFactory = _context.sourceFactory;
+// Source source = _addSource("/lib.dart", "library lib;");
+// CompilationUnit compilationUnit =
+// _context.resolveCompilationUnit2(source, source);
+// expect(compilationUnit, isNotNull);
+// expect(_context.getLineInfo(source), isNotNull);
+// }
+
void test_resolveCompilationUnit_library() {
Source source = addSource("/lib.dart", "library lib;");
LibraryElement library = context.computeLibraryElement(source);
@@ -2187,17 +2249,6 @@ class ClassTwo {
expect(compilationUnit, isNotNull);
}
-// void test_resolveCompilationUnit_sourceChangeDuringResolution() {
-// _context = new _AnalysisContext_sourceChangeDuringResolution();
-// AnalysisContextFactory.initContextWithCore(_context);
-// _sourceFactory = _context.sourceFactory;
-// Source source = _addSource("/lib.dart", "library lib;");
-// CompilationUnit compilationUnit =
-// _context.resolveCompilationUnit2(source, source);
-// expect(compilationUnit, isNotNull);
-// expect(_context.getLineInfo(source), isNotNull);
-// }
-
void test_setAnalysisOptions() {
AnalysisOptionsImpl options = new AnalysisOptionsImpl();
options.cacheSize = 42;
« pkg/analyzer/lib/task/model.dart ('K') | « pkg/analyzer/lib/task/model.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698