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

Side by Side Diff: pkg/analysis_server/test/context_manager_test.dart

Issue 2570623002: Fix bug when packages file changes in new driver (Closed)
Patch Set: clear file state Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.context.directory.manager; 5 library test.context.directory.manager;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analysis_server/src/context_manager.dart'; 9 import 'package:analysis_server/src/context_manager.dart';
10 import 'package:analysis_server/src/utilities/null_string_sink.dart'; 10 import 'package:analysis_server/src/utilities/null_string_sink.dart';
(...skipping 1795 matching lines...) Expand 10 before | Expand all | Expand 10 after
1806 1806
1807 UriResolver providePackageResolver(Folder folder) => packageResolver; 1807 UriResolver providePackageResolver(Folder folder) => packageResolver;
1808 1808
1809 void setUp() { 1809 void setUp() {
1810 processRequiredPlugins(); 1810 processRequiredPlugins();
1811 resourceProvider = new MemoryResourceProvider(); 1811 resourceProvider = new MemoryResourceProvider();
1812 resourceProvider.newFolder(projPath); 1812 resourceProvider.newFolder(projPath);
1813 packageMapProvider = new MockPackageMapProvider(); 1813 packageMapProvider = new MockPackageMapProvider();
1814 // Create an SDK in the mock file system. 1814 // Create an SDK in the mock file system.
1815 new MockSdk(generateSummaryFiles: true, resourceProvider: resourceProvider); 1815 new MockSdk(generateSummaryFiles: true, resourceProvider: resourceProvider);
1816 DartSdkManager sdkManager = new DartSdkManager('/', false); 1816 DartSdkManager sdkManager = new DartSdkManager('/', true);
1817 manager = new ContextManagerImpl( 1817 manager = new ContextManagerImpl(
1818 resourceProvider, 1818 resourceProvider,
1819 sdkManager, 1819 sdkManager,
1820 providePackageResolver, 1820 providePackageResolver,
1821 packageMapProvider, 1821 packageMapProvider,
1822 analysisFilesGlobs, 1822 analysisFilesGlobs,
1823 InstrumentationService.NULL_SERVICE, 1823 InstrumentationService.NULL_SERVICE,
1824 new AnalysisOptionsImpl(), 1824 new AnalysisOptionsImpl(),
1825 enableAnalysisDriver); 1825 enableAnalysisDriver);
1826 PerformanceLog logger = new PerformanceLog(new NullStringSink()); 1826 PerformanceLog logger = new PerformanceLog(new NullStringSink());
1827 AnalysisDriverScheduler scheduler = new AnalysisDriverScheduler(logger); 1827 AnalysisDriverScheduler scheduler = new AnalysisDriverScheduler(logger);
1828 callbacks = 1828 callbacks = new TestContextManagerCallbacks(
1829 new TestContextManagerCallbacks(resourceProvider, logger, scheduler); 1829 resourceProvider, sdkManager, logger, scheduler);
1830 manager.callbacks = callbacks; 1830 manager.callbacks = callbacks;
1831 } 1831 }
1832 1832
1833 /** 1833 /**
1834 * Verify that package URI's for source files in [path] will be resolved 1834 * Verify that package URI's for source files in [path] will be resolved
1835 * using a package root matching [expectation]. 1835 * using a package root matching [expectation].
1836 */ 1836 */
1837 void _checkPackageRoot(String path, expectation) { 1837 void _checkPackageRoot(String path, expectation) {
1838 // TODO(brianwilkerson) Figure out how to test this. Possibly by comparing 1838 // TODO(brianwilkerson) Figure out how to test this. Possibly by comparing
1839 // the contents of the package map (although that approach doesn't work at 1839 // the contents of the package map (although that approach doesn't work at
(...skipping 14 matching lines...) Expand all
1854 class ContextManagerWithNewOptionsTest extends ContextManagerWithOptionsTest { 1854 class ContextManagerWithNewOptionsTest extends ContextManagerWithOptionsTest {
1855 String get optionsFileName => AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE; 1855 String get optionsFileName => AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE;
1856 } 1856 }
1857 1857
1858 @reflectiveTest 1858 @reflectiveTest
1859 class ContextManagerWithNewOptionsTest_Driver 1859 class ContextManagerWithNewOptionsTest_Driver
1860 extends ContextManagerWithNewOptionsTest { 1860 extends ContextManagerWithNewOptionsTest {
1861 bool get enableAnalysisDriver => true; 1861 bool get enableAnalysisDriver => true;
1862 1862
1863 @failingTest 1863 @failingTest
1864 test_analysis_options_file_delete() async {
1865 // It appears that this fails because we are not correctly updating the
1866 // analysis options in the driver when the file is removed.
1867 return super.test_analysis_options_file_delete();
1868 }
1869
1870 @failingTest
1871 test_analysis_options_file_delete_with_embedder() async { 1864 test_analysis_options_file_delete_with_embedder() async {
1872 // This fails because the ContextBuilder doesn't pick up the strongMode 1865 // This fails because the ContextBuilder doesn't pick up the strongMode
1873 // flag from the embedder.yaml file. 1866 // flag from the embedder.yaml file.
1874 return super.test_analysis_options_file_delete_with_embedder(); 1867 return super.test_analysis_options_file_delete_with_embedder();
1875 } 1868 }
1876 1869
1877 @failingTest 1870 @failingTest
1878 test_embedder_options() async { 1871 test_embedder_options() async {
1879 // This fails because the ContextBuilder doesn't pick up the strongMode 1872 // This fails because the ContextBuilder doesn't pick up the strongMode
1880 // flag from the embedder.yaml file. 1873 // flag from the embedder.yaml file.
(...skipping 21 matching lines...) Expand all
1902 class ContextManagerWithOldOptionsTest extends ContextManagerWithOptionsTest { 1895 class ContextManagerWithOldOptionsTest extends ContextManagerWithOptionsTest {
1903 String get optionsFileName => AnalysisEngine.ANALYSIS_OPTIONS_FILE; 1896 String get optionsFileName => AnalysisEngine.ANALYSIS_OPTIONS_FILE;
1904 } 1897 }
1905 1898
1906 @reflectiveTest 1899 @reflectiveTest
1907 class ContextManagerWithOldOptionsTest_Driver 1900 class ContextManagerWithOldOptionsTest_Driver
1908 extends ContextManagerWithOldOptionsTest { 1901 extends ContextManagerWithOldOptionsTest {
1909 bool get enableAnalysisDriver => true; 1902 bool get enableAnalysisDriver => true;
1910 1903
1911 @failingTest 1904 @failingTest
1912 test_analysis_options_file_delete() async {
1913 // It appears that this fails because we are not correctly updating the
1914 // analysis options in the driver when the file is removed.
1915 return super.test_analysis_options_file_delete();
1916 }
1917
1918 @failingTest
1919 test_analysis_options_file_delete_with_embedder() async { 1905 test_analysis_options_file_delete_with_embedder() async {
1920 // This fails because the ContextBuilder doesn't pick up the strongMode 1906 // This fails because the ContextBuilder doesn't pick up the strongMode
1921 // flag from the embedder.yaml file. 1907 // flag from the embedder.yaml file.
1922 return super.test_analysis_options_file_delete_with_embedder(); 1908 return super.test_analysis_options_file_delete_with_embedder();
1923 } 1909 }
1924 1910
1925 @failingTest 1911 @failingTest
1926 test_embedder_options() async { 1912 test_embedder_options() async {
1927 // This fails because the ContextBuilder doesn't pick up the strongMode 1913 // This fails because the ContextBuilder doesn't pick up the strongMode
1928 // flag from the embedder.yaml file. 1914 // flag from the embedder.yaml file.
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
2321 expect(sdkContext.analysisOptions.strongMode, isTrue); 2307 expect(sdkContext.analysisOptions.strongMode, isTrue);
2322 // The code is strong-mode clean. 2308 // The code is strong-mode clean.
2323 // Verify that TypeSystem was reset. 2309 // Verify that TypeSystem was reset.
2324 expect(result.errors, isEmpty); 2310 expect(result.errors, isEmpty);
2325 } else { 2311 } else {
2326 AnalysisContext context = manager.getContextFor(projPath); 2312 AnalysisContext context = manager.getContextFor(projPath);
2327 Source testSource = context.getSourcesWithFullName(file.path).single; 2313 Source testSource = context.getSourcesWithFullName(file.path).single;
2328 AnalysisContext sdkContext = sourceFactory.dartSdk.context; 2314 AnalysisContext sdkContext = sourceFactory.dartSdk.context;
2329 expect(analysisOptions.strongMode, isTrue); 2315 expect(analysisOptions.strongMode, isTrue);
2330 expect(sdkContext.analysisOptions.strongMode, isTrue); 2316 expect(sdkContext.analysisOptions.strongMode, isTrue);
2331 // The code is strong-mode clean. 2317 // The code is strong-mode clean, but we're using a Mock SDK that isn't
2318 // configured correctly for strong mode so we get an error.
2332 // Verify that TypeSystem was reset. 2319 // Verify that TypeSystem was reset.
2333 expect(context.computeErrors(testSource), isEmpty); 2320 expect(context.computeErrors(testSource), hasLength(1));
2334 } 2321 }
2335 } 2322 }
2336 2323
2337 test_path_filter_analysis_option() async { 2324 test_path_filter_analysis_option() async {
2338 // Create files. 2325 // Create files.
2339 String libPath = newFolder([projPath, ContextManagerTest.LIB_NAME]); 2326 String libPath = newFolder([projPath, ContextManagerTest.LIB_NAME]);
2340 newFile([libPath, 'main.dart']); 2327 newFile([libPath, 'main.dart']);
2341 newFile([libPath, 'nope.dart']); 2328 newFile([libPath, 'nope.dart']);
2342 String sdkExtPath = newFolder([projPath, 'sdk_ext']); 2329 String sdkExtPath = newFolder([projPath, 'sdk_ext']);
2343 newFile([sdkExtPath, 'entry.dart']); 2330 newFile([sdkExtPath, 'entry.dart']);
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
2630 */ 2617 */
2631 final Map<String, Set<Source>> currentContextSources = 2618 final Map<String, Set<Source>> currentContextSources =
2632 <String, Set<Source>>{}; 2619 <String, Set<Source>>{};
2633 2620
2634 /** 2621 /**
2635 * Resource provider used for this test. 2622 * Resource provider used for this test.
2636 */ 2623 */
2637 final ResourceProvider resourceProvider; 2624 final ResourceProvider resourceProvider;
2638 2625
2639 /** 2626 /**
2627 * The manager managing the SDKs.
2628 */
2629 final DartSdkManager sdkManager;
2630
2631 /**
2640 * The logger used by the scheduler and the driver. 2632 * The logger used by the scheduler and the driver.
2641 */ 2633 */
2642 final PerformanceLog logger; 2634 final PerformanceLog logger;
2643 2635
2644 /** 2636 /**
2645 * The scheduler used by the driver. 2637 * The scheduler used by the driver.
2646 */ 2638 */
2647 final AnalysisDriverScheduler scheduler; 2639 final AnalysisDriverScheduler scheduler;
2648 2640
2649 /** 2641 /**
2650 * The list of `flushedFiles` in the last [removeContext] invocation. 2642 * The list of `flushedFiles` in the last [removeContext] invocation.
2651 */ 2643 */
2652 List<String> lastFlushedFiles; 2644 List<String> lastFlushedFiles;
2653 2645
2654 TestContextManagerCallbacks( 2646 TestContextManagerCallbacks(
2655 this.resourceProvider, this.logger, this.scheduler); 2647 this.resourceProvider, this.sdkManager, this.logger, this.scheduler);
2656 2648
2657 /** 2649 /**
2658 * Return the current set of analysis options. 2650 * Return the current set of analysis options.
2659 */ 2651 */
2660 AnalysisOptions get analysisOptions => currentDriver == null 2652 AnalysisOptions get analysisOptions => currentDriver == null
2661 ? currentContext.analysisOptions 2653 ? currentContext.analysisOptions
2662 : currentDriver.analysisOptions; 2654 : currentDriver.analysisOptions;
2663 2655
2664 /** 2656 /**
2665 * Iterable of the paths to contexts that currently exist. 2657 * Iterable of the paths to contexts that currently exist.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
2765 } 2757 }
2766 2758
2767 @override 2759 @override
2768 void computingPackageMap(bool computing) { 2760 void computingPackageMap(bool computing) {
2769 // Do nothing. 2761 // Do nothing.
2770 } 2762 }
2771 2763
2772 @override 2764 @override
2773 ContextBuilder createContextBuilder(Folder folder, AnalysisOptions options, 2765 ContextBuilder createContextBuilder(Folder folder, AnalysisOptions options,
2774 {bool useSummaries = false}) { 2766 {bool useSummaries = false}) {
2775 DartSdkManager sdkManager = new DartSdkManager('/', useSummaries);
2776 ContextBuilderOptions builderOptions = new ContextBuilderOptions(); 2767 ContextBuilderOptions builderOptions = new ContextBuilderOptions();
2777 builderOptions.defaultOptions = options; 2768 builderOptions.defaultOptions = options;
2778 ContextBuilder builder = new ContextBuilder( 2769 ContextBuilder builder = new ContextBuilder(
2779 resourceProvider, sdkManager, new ContentCache(), 2770 resourceProvider, sdkManager, new ContentCache(),
2780 options: builderOptions); 2771 options: builderOptions);
2781 return builder; 2772 return builder;
2782 } 2773 }
2783 2774
2784 @override 2775 @override
2785 void moveContext(Folder from, Folder to) { 2776 void moveContext(Folder from, Folder to) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2825 class TestUriResolver extends UriResolver { 2816 class TestUriResolver extends UriResolver {
2826 Map<Uri, Source> uriMap; 2817 Map<Uri, Source> uriMap;
2827 2818
2828 TestUriResolver(this.uriMap); 2819 TestUriResolver(this.uriMap);
2829 2820
2830 @override 2821 @override
2831 Source resolveAbsolute(Uri uri, [Uri actualUri]) { 2822 Source resolveAbsolute(Uri uri, [Uri actualUri]) {
2832 return uriMap[uri]; 2823 return uriMap[uri];
2833 } 2824 }
2834 } 2825 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698