diff --git a/pkg/analysis_server/test/abstract_context.dart b/pkg/analysis_server/test/abstract_context.dart index 92d8bf21ee34c..b96340ea5f652 100644 --- a/pkg/analysis_server/test/abstract_context.dart +++ b/pkg/analysis_server/test/abstract_context.dart @@ -112,33 +112,6 @@ class _IsTestGroup { return source; } - /** - * Call a test that we think will fail. - * - * Ensure that we return any thrown exception correctly (avoiding the - * package:test zone error handler). - */ - Future callFailingTest(Future Function() expectedFailingTestFn) { - final Completer completer = new Completer(); - - try { - runZoned( - () async => await expectedFailingTestFn(), - onError: (error) { - completer.completeError(error); - }, - ).then((result) { - completer.complete(result); - }).catchError((error) { - completer.completeError(error); - }); - } catch (error) { - completer.completeError(error); - } - - return completer.future; - } - /** * Re-configure the driver. This is necessary, for example, after defining a * new package that test code will reference. diff --git a/pkg/analysis_server/test/analysis/notification_highlights_test.dart b/pkg/analysis_server/test/analysis/notification_highlights_test.dart index 970dc991290f2..c15d95f9ad204 100644 --- a/pkg/analysis_server/test/analysis/notification_highlights_test.dart +++ b/pkg/analysis_server/test/analysis/notification_highlights_test.dart @@ -12,6 +12,7 @@ import 'package:test/test.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; import '../analysis_abstract.dart'; +import '../test_utilities/utillities.dart'; main() { defineReflectiveSuite(() { diff --git a/pkg/analysis_server/test/analysis_abstract.dart b/pkg/analysis_server/test/analysis_abstract.dart index e4b0eb841af1d..c2370348c3b33 100644 --- a/pkg/analysis_server/test/analysis_abstract.dart +++ b/pkg/analysis_server/test/analysis_abstract.dart @@ -106,33 +106,6 @@ class AbstractAnalysisTest extends Object with ResourceProviderMixin { return testFile; } - /** - * Call a test that we think will fail. - * - * Ensure that we return any thrown exception correctly (avoiding the - * package:test zone error handler). - */ - Future callFailingTest(Future Function() expectedFailingTestFn) { - final Completer completer = new Completer(); - - try { - runZoned( - () async => await expectedFailingTestFn(), - onError: (error) { - completer.completeError(error); - }, - ).then((result) { - completer.complete(result); - }).catchError((error) { - completer.completeError(error); - }); - } catch (error) { - completer.completeError(error); - } - - return completer.future; - } - AnalysisServer createAnalysisServer() { // // Process plugins diff --git a/pkg/analysis_server/test/completion_test.dart b/pkg/analysis_server/test/completion_test.dart index 7664bc2e081d9..2b9adb9bf7563 100644 --- a/pkg/analysis_server/test/completion_test.dart +++ b/pkg/analysis_server/test/completion_test.dart @@ -2607,31 +2607,4 @@ class A { } } } - - /** - * Call a test that we think will fail. - * - * Ensure that we return any thrown exception correctly (avoiding the - * package:test zone error handler). - */ - Future callFailingTest(Future Function() expectedFailingTestFn) { - final Completer completer = new Completer(); - - try { - runZoned( - () async => await expectedFailingTestFn(), - onError: (error) { - completer.completeError(error); - }, - ).then((result) { - completer.complete(result); - }).catchError((error) { - completer.completeError(error); - }); - } catch (error) { - completer.completeError(error); - } - - return completer.future; - } } diff --git a/pkg/analysis_server/test/context_manager_test.dart b/pkg/analysis_server/test/context_manager_test.dart index 1351ca6dcfc71..e73977052e784 100644 --- a/pkg/analysis_server/test/context_manager_test.dart +++ b/pkg/analysis_server/test/context_manager_test.dart @@ -40,8 +40,11 @@ import 'src/plugin/plugin_manager_test.dart'; main() { defineReflectiveSuite(() { defineReflectiveTests(AbstractContextManagerTest); + defineReflectiveTests(AbstractContextManagerTest_UseCFE); defineReflectiveTests(ContextManagerWithNewOptionsTest); + defineReflectiveTests(ContextManagerWithNewOptionsTest_UseCFE); defineReflectiveTests(ContextManagerWithOldOptionsTest); + defineReflectiveTests(ContextManagerWithOldOptionsTest_UseCFE); }); } @@ -1644,6 +1647,12 @@ test_pack:lib/'''); } } +@reflectiveTest +class AbstractContextManagerTest_UseCFE extends AbstractContextManagerTest { + @override + bool get useCFE => true; +} + abstract class ContextManagerTest extends Object with ResourceProviderMixin { /** * The name of the 'bin' directory. @@ -1720,6 +1729,11 @@ abstract class ContextManagerTest extends Object with ResourceProviderMixin { SourceFactory get sourceFactory => callbacks.sourceFactory; + /** + * Return `true` to enable the Dart 2.0 Common Front End. + */ + bool get useCFE => false; + Map> get _currentPackageMap => _packageMap(projPath); /** @@ -1756,7 +1770,8 @@ abstract class ContextManagerTest extends Object with ResourceProviderMixin { PerformanceLog logger = new PerformanceLog(new NullStringSink()); AnalysisDriverScheduler scheduler = new AnalysisDriverScheduler(logger); callbacks = new TestContextManagerCallbacks( - resourceProvider, sdkManager, logger, scheduler); + resourceProvider, sdkManager, logger, scheduler, + useCFE: useCFE); manager.callbacks = callbacks; } @@ -1792,11 +1807,25 @@ class ContextManagerWithNewOptionsTest extends ContextManagerWithOptionsTest { } } +@reflectiveTest +class ContextManagerWithNewOptionsTest_UseCFE + extends ContextManagerWithNewOptionsTest { + @override + bool get useCFE => true; +} + @reflectiveTest class ContextManagerWithOldOptionsTest extends ContextManagerWithOptionsTest { String get optionsFileName => AnalysisEngine.ANALYSIS_OPTIONS_FILE; } +@reflectiveTest +class ContextManagerWithOldOptionsTest_UseCFE + extends ContextManagerWithOldOptionsTest { + @override + bool get useCFE => true; +} + abstract class ContextManagerWithOptionsTest extends ContextManagerTest { String get optionsFileName; @@ -2476,6 +2505,11 @@ class TestContextManagerCallbacks extends ContextManagerCallbacks { */ final AnalysisDriverScheduler scheduler; + /** + * A flag indicating whether to enable the Dart 2.0 Common Front End. + */ + final bool useCFE; + /** * The list of `flushedFiles` in the last [removeContext] invocation. */ @@ -2490,7 +2524,8 @@ class TestContextManagerCallbacks extends ContextManagerCallbacks { NotificationManager notificationManager = new TestNotificationManager(); TestContextManagerCallbacks( - this.resourceProvider, this.sdkManager, this.logger, this.scheduler); + this.resourceProvider, this.sdkManager, this.logger, this.scheduler, + {this.useCFE = false}); /** * Return the current set of analysis options. @@ -2543,7 +2578,8 @@ class TestContextManagerCallbacks extends ContextManagerCallbacks { new FileContentOverlay(), contextRoot, sourceFactory, - analysisOptions); + analysisOptions, + useCFE: useCFE); driverMap[path] = currentDriver; currentDriver.exceptions.listen((ExceptionResult result) { AnalysisEngine.instance.logger diff --git a/pkg/analysis_server/test/integration/search/find_element_references_test.dart b/pkg/analysis_server/test/integration/search/find_element_references_test.dart index 1b5f72b9d820a..59ca4f2f1495d 100644 --- a/pkg/analysis_server/test/integration/search/find_element_references_test.dart +++ b/pkg/analysis_server/test/integration/search/find_element_references_test.dart @@ -8,6 +8,7 @@ import 'package:analysis_server/protocol/protocol_generated.dart'; import 'package:test/test.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; +import '../../test_utilities/utillities.dart'; import '../support/integration_tests.dart'; main() { diff --git a/pkg/analysis_server/test/integration/search/find_member_references_test.dart b/pkg/analysis_server/test/integration/search/find_member_references_test.dart index 6f917693340bc..e8265fede0222 100644 --- a/pkg/analysis_server/test/integration/search/find_member_references_test.dart +++ b/pkg/analysis_server/test/integration/search/find_member_references_test.dart @@ -6,6 +6,7 @@ import 'package:analysis_server/protocol/protocol_generated.dart'; import 'package:test/test.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; +import '../../test_utilities/utillities.dart'; import '../support/integration_tests.dart'; main() { diff --git a/pkg/analysis_server/test/integration/support/integration_tests.dart b/pkg/analysis_server/test/integration/support/integration_tests.dart index 4f7ecb54a0ec3..bc9a1bec0cdd7 100644 --- a/pkg/analysis_server/test/integration/support/integration_tests.dart +++ b/pkg/analysis_server/test/integration/support/integration_tests.dart @@ -164,33 +164,6 @@ abstract class AbstractAnalysisServerIntegrationTest // TODO(devoncarew): Remove this when --use-cfe goes away. bool get useCFE => false; - /** - * Call a test that we think will fail. - * - * Ensure that we return any thrown exception correctly (avoiding the - * package:test zone error handler). - */ - Future callFailingTest(Future Function() expectedFailingTestFn) { - final Completer completer = new Completer(); - - try { - runZoned( - () async => await expectedFailingTestFn(), - onError: (error) { - completer.completeError(error); - }, - ).then((result) { - completer.complete(result); - }).catchError((error) { - completer.completeError(error); - }); - } catch (error) { - completer.completeError(error); - } - - return completer.future; - } - /** * Print out any messages exchanged with the server. If some messages have * already been exchanged with the server, they are printed out immediately. diff --git a/pkg/analysis_server/test/search/type_hierarchy_test.dart b/pkg/analysis_server/test/search/type_hierarchy_test.dart index 6c20bff9020f1..9da3393d2b0e2 100644 --- a/pkg/analysis_server/test/search/type_hierarchy_test.dart +++ b/pkg/analysis_server/test/search/type_hierarchy_test.dart @@ -12,6 +12,7 @@ import 'package:test/test.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; import '../analysis_abstract.dart'; +import '../test_utilities/utillities.dart'; main() { defineReflectiveSuite(() { diff --git a/pkg/analysis_server/test/services/correction/status_test.dart b/pkg/analysis_server/test/services/correction/status_test.dart index ca5e82b8267bf..b884f3dba3390 100644 --- a/pkg/analysis_server/test/services/correction/status_test.dart +++ b/pkg/analysis_server/test/services/correction/status_test.dart @@ -20,7 +20,6 @@ main() { defineReflectiveTests(RefactoringLocationTest); defineReflectiveTests(RefactoringLocationTest_UseCFE); defineReflectiveTests(RefactoringStatusTest); - defineReflectiveTests(RefactoringStatusTest_UseCFE); }); } @@ -241,9 +240,3 @@ class RefactoringStatusTest { expect(refactoringStatus.message, 'msg'); } } - -@reflectiveTest -class RefactoringStatusTest_UseCFE extends RefactoringStatusTest { - @override - bool get useCFE => true; -} diff --git a/pkg/analysis_server/test/services/refactoring/move_file_test.dart b/pkg/analysis_server/test/services/refactoring/move_file_test.dart index 0c68a70fb6af3..65c40fde068b6 100644 --- a/pkg/analysis_server/test/services/refactoring/move_file_test.dart +++ b/pkg/analysis_server/test/services/refactoring/move_file_test.dart @@ -8,6 +8,7 @@ import 'package:analysis_server/src/services/refactoring/refactoring.dart'; import 'package:test/test.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; +import '../../test_utilities/utillities.dart'; import 'abstract_refactoring.dart'; main() { diff --git a/pkg/analysis_server/test/services/refactoring/rename_unit_member_test.dart b/pkg/analysis_server/test/services/refactoring/rename_unit_member_test.dart index 96735ca4a4718..a504b439b446c 100644 --- a/pkg/analysis_server/test/services/refactoring/rename_unit_member_test.dart +++ b/pkg/analysis_server/test/services/refactoring/rename_unit_member_test.dart @@ -7,6 +7,7 @@ import 'package:analyzer_plugin/protocol/protocol_common.dart'; import 'package:test/test.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; +import '../../test_utilities/utillities.dart'; import 'abstract_rename.dart'; main() { diff --git a/pkg/analysis_server/test/services/search/search_engine_test.dart b/pkg/analysis_server/test/services/search/search_engine_test.dart index 9d0b654f3e33b..b28af8bf6f873 100644 --- a/pkg/analysis_server/test/services/search/search_engine_test.dart +++ b/pkg/analysis_server/test/services/search/search_engine_test.dart @@ -21,10 +21,12 @@ import 'package:test/test.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; import '../../mock_sdk.dart'; +import '../../test_utilities/utillities.dart'; main() { defineReflectiveSuite(() { defineReflectiveTests(SearchEngineImplTest); + defineReflectiveTests(SearchEngineImplTest_UseCFE); }); } @@ -39,6 +41,11 @@ class SearchEngineImplTest extends Object with ResourceProviderMixin { AnalysisDriverScheduler scheduler; + /** + * Return `true` to enable the Dart 2.0 Common Front End. + */ + bool get useCFE => false; + void setUp() { sdk = new MockSdk(resourceProvider: resourceProvider); logger = new PerformanceLog(logBuffer); @@ -468,6 +475,36 @@ class B extends A {} contentOverlay, null, new SourceFactory(resolvers, null, resourceProvider), - new AnalysisOptionsImpl()); + new AnalysisOptionsImpl(), + useCFE: useCFE); } } + +@reflectiveTest +class SearchEngineImplTest_UseCFE extends SearchEngineImplTest { + @override + bool get useCFE => true; + + @failingTest + @override + test_searchAllSubtypes() => super.test_searchAllSubtypes(); + + @failingTest + @override + test_searchAllSubtypes_acrossDrivers() => + super.test_searchAllSubtypes_acrossDrivers(); + + @failingTest + @override + test_searchMemberReferences() => + callFailingTest(super.test_searchMemberReferences()); + + @failingTest + @override + test_searchReferences() => super.test_searchReferences(); + + @failingTest + @override + test_searchReferences_discover_owned() => + super.test_searchReferences_discover_owned(); +} diff --git a/pkg/analysis_server/test/test_utilities/utillities.dart b/pkg/analysis_server/test/test_utilities/utillities.dart new file mode 100644 index 0000000000000..4b4dddd05c717 --- /dev/null +++ b/pkg/analysis_server/test/test_utilities/utillities.dart @@ -0,0 +1,32 @@ +// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:async'; + +/** + * Call a test that we think will fail. + * + * Ensure that we return any thrown exception correctly (avoiding the + * package:test zone error handler). + */ +Future callFailingTest(Future Function() expectedFailingTestFn) { + final Completer completer = new Completer(); + + try { + runZoned( + () async => await expectedFailingTestFn(), + onError: (error) { + completer.completeError(error); + }, + ).then((result) { + completer.complete(result); + }).catchError((error) { + completer.completeError(error); + }); + } catch (error) { + completer.completeError(error); + } + + return completer.future; +}