Chromium Code Reviews| Index: pkg/analyzer/test/src/summary/resynthesize_test.dart |
| diff --git a/pkg/analyzer/test/src/summary/resynthesize_test.dart b/pkg/analyzer/test/src/summary/resynthesize_test.dart |
| index 679741df4d764db3bace0143f962ec7f7f31167e..f7fe01c801808142c60c18a2e53747dd4927c6f0 100644 |
| --- a/pkg/analyzer/test/src/summary/resynthesize_test.dart |
| +++ b/pkg/analyzer/test/src/summary/resynthesize_test.dart |
| @@ -49,6 +49,12 @@ abstract class AbstractResynthesizeTest extends AbstractSingleUnitTest { |
| */ |
| Set<String> variablesWithNotConstInitializers = new Set<String>(); |
| + /** |
| + * Tests may set this to `true` to indicate that a missing file at the time of |
|
Brian Wilkerson
2016/08/11 23:49:35
Seems odd to talk about setting a getter to `true`
Paul Berry
2016/08/12 20:56:51
Resolved in an offline discussion. There was a sl
|
| + * summary resynthesis shouldn't trigger an error. |
| + */ |
| + bool get allowMissingFiles; |
| + |
| bool get checkPropagatedTypes => true; |
| void addLibrary(String uri) { |
| @@ -1184,7 +1190,7 @@ abstract class AbstractResynthesizeTest extends AbstractSingleUnitTest { |
| }); |
| } |
| return new TestSummaryResynthesizer( |
| - null, context, unlinkedSummaries, linkedSummaries); |
| + null, context, unlinkedSummaries, linkedSummaries, allowMissingFiles); |
| } |
| ElementImpl getActualElement(Element element, String desc) { |
| @@ -1331,13 +1337,6 @@ abstract class AbstractResynthesizeTest extends AbstractSingleUnitTest { |
| return false; |
| } else if (modifier == Modifier.SYNTHETIC) { |
| return element.isSynthetic; |
| - } else if (modifier == Modifier.URI_EXISTS) { |
| - if (element is ExportElement) { |
| - return element.uriExists; |
| - } else if (element is ImportElement) { |
| - return element.uriExists; |
| - } |
| - return false; |
| } |
| throw new UnimplementedError( |
| 'Modifier $modifier for ${element?.runtimeType}'); |
| @@ -1347,6 +1346,9 @@ abstract class AbstractResynthesizeTest extends AbstractSingleUnitTest { |
| @reflectiveTest |
| class ResynthesizeElementTest extends ResynthesizeTest { |
| @override |
| + bool allowMissingFiles = false; |
| + |
| + @override |
| LibraryElementImpl checkLibrary(String text, |
| {bool allowErrors: false, bool dumpSummaries: false}) { |
| Source source = addTestSource(text); |
| @@ -1422,7 +1424,7 @@ class ResynthesizeElementTest extends ResynthesizeTest { |
| }); |
| } |
| return new TestSummaryResynthesizer( |
| - null, context, unlinkedSummaries, linkedSummaries); |
| + null, context, unlinkedSummaries, linkedSummaries, allowMissingFiles); |
| } |
| /** |
| @@ -1454,6 +1456,12 @@ class ResynthesizeElementTest extends ResynthesizeTest { |
| @reflectiveTest |
| abstract class ResynthesizeTest extends AbstractResynthesizeTest { |
| + /** |
| + * Tests may set this to `true` to indicate that a missing file at the time of |
| + * summary resynthesis shouldn't trigger an error. |
| + */ |
| + void set allowMissingFiles(bool value); |
| + |
| LibraryElementImpl checkLibrary(String text, |
| {bool allowErrors: false, bool dumpSummaries: false}); |
| @@ -4476,6 +4484,21 @@ typedef F();'''); |
| checkLibrary('f() {} g() {}'); |
| } |
| + test_unresolved_export() { |
| + allowMissingFiles = true; |
| + checkLibrary("export 'foo.dart';", allowErrors: true); |
| + } |
| + |
| + test_unresolved_import() { |
| + allowMissingFiles = true; |
| + checkLibrary("import 'foo.dart';", allowErrors: true); |
| + } |
| + |
| + test_unresolved_part() { |
| + allowMissingFiles = true; |
| + checkLibrary("part 'foo.dart';", allowErrors: true); |
| + } |
| + |
| test_unused_type_parameter() { |
| checkLibrary(''' |
| class C<T> { |
| @@ -4588,6 +4611,7 @@ var x;'''); |
| class TestSummaryResynthesizer extends SummaryResynthesizer { |
| final Map<String, UnlinkedUnit> unlinkedSummaries; |
| final Map<String, LinkedLibrary> linkedSummaries; |
| + final bool allowMissingFiles; |
| /** |
| * The set of uris for which unlinked summaries have been requested using |
| @@ -4602,7 +4626,7 @@ class TestSummaryResynthesizer extends SummaryResynthesizer { |
| final Set<String> linkedSummariesRequested = new Set<String>(); |
| TestSummaryResynthesizer(SummaryResynthesizer parent, AnalysisContext context, |
| - this.unlinkedSummaries, this.linkedSummaries) |
| + this.unlinkedSummaries, this.linkedSummaries, this.allowMissingFiles) |
| : super(parent, context, context.typeProvider, context.sourceFactory, |
| context.analysisOptions.strongMode); |
| @@ -4610,7 +4634,7 @@ class TestSummaryResynthesizer extends SummaryResynthesizer { |
| LinkedLibrary getLinkedSummary(String uri) { |
| linkedSummariesRequested.add(uri); |
| LinkedLibrary serializedLibrary = linkedSummaries[uri]; |
| - if (serializedLibrary == null) { |
| + if (serializedLibrary == null && !allowMissingFiles) { |
| fail('Unexpectedly tried to get linked summary for $uri'); |
| } |
| return serializedLibrary; |
| @@ -4620,7 +4644,7 @@ class TestSummaryResynthesizer extends SummaryResynthesizer { |
| UnlinkedUnit getUnlinkedSummary(String uri) { |
| unlinkedSummariesRequested.add(uri); |
| UnlinkedUnit serializedUnit = unlinkedSummaries[uri]; |
| - if (serializedUnit == null) { |
| + if (serializedUnit == null && !allowMissingFiles) { |
| fail('Unexpectedly tried to get unlinked summary for $uri'); |
| } |
| return serializedUnit; |