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

Side by Side Diff: pkg/analyzer/test/src/summary/in_summary_source_test.dart

Issue 1826353002: Add a fallback mode for building summaries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 analyzer.test.src.summary.in_summary_source_test; 5 library analyzer.test.src.summary.in_summary_source_test;
6 6
7 import 'package:analyzer/src/generated/source_io.dart'; 7 import 'package:analyzer/src/generated/source_io.dart';
8 import 'package:analyzer/src/summary/format.dart';
8 import 'package:analyzer/src/summary/idl.dart'; 9 import 'package:analyzer/src/summary/idl.dart';
9 import 'package:analyzer/src/summary/package_bundle_reader.dart'; 10 import 'package:analyzer/src/summary/package_bundle_reader.dart';
10 import 'package:unittest/unittest.dart'; 11 import 'package:unittest/unittest.dart';
11 12
12 import '../../reflective_tests.dart'; 13 import '../../reflective_tests.dart';
13 14
14 main() { 15 main() {
15 groupSep = ' | '; 16 groupSep = ' | ';
16 runReflectiveTests(InSummarySourceTest); 17 runReflectiveTests(InSummarySourceTest);
17 } 18 }
18 19
19 @reflectiveTest 20 @reflectiveTest
20 class InSummarySourceTest extends ReflectiveTest { 21 class InSummarySourceTest extends ReflectiveTest {
22 test_fallbackPath() {
23 var sourceFactory = new SourceFactory([
24 new InSummaryPackageUriResolver(new MockSummaryDataStore.fake(
25 {'package:foo/foo.dart': 'foo.sum',},
26 uriToFallbackModePath: {'package:foo/foo.dart': '/path/to/foo.dart'}))
27 ]);
28
29 InSummarySource source = sourceFactory.forUri('package:foo/foo.dart');
30 expect(source, new isInstanceOf<FileBasedSource>());
31 expect(source.fullName, '/path/to/foo.dart');
32 }
33
21 test_InSummarySource() { 34 test_InSummarySource() {
22 var sourceFactory = new SourceFactory([ 35 var sourceFactory = new SourceFactory([
23 new InSummaryPackageUriResolver(new MockSummaryDataStore.fake({ 36 new InSummaryPackageUriResolver(new MockSummaryDataStore.fake({
24 'package:foo/foo.dart': 'foo.sum', 37 'package:foo/foo.dart': 'foo.sum',
25 'package:foo/src/foo_impl.dart': 'foo.sum', 38 'package:foo/src/foo_impl.dart': 'foo.sum',
26 'package:bar/baz.dart': 'bar.sum', 39 'package:bar/baz.dart': 'bar.sum',
27 })) 40 }))
28 ]); 41 ]);
29 42
30 InSummarySource source = sourceFactory.forUri('package:foo/foo.dart'); 43 InSummarySource source = sourceFactory.forUri('package:foo/foo.dart');
44 expect(source, isNot(new isInstanceOf<FileBasedSource>()));
31 expect(source.summaryPath, 'foo.sum'); 45 expect(source.summaryPath, 'foo.sum');
32 46
33 source = sourceFactory.forUri('package:foo/src/foo_impl.dart'); 47 source = sourceFactory.forUri('package:foo/src/foo_impl.dart');
48 expect(source, isNot(new isInstanceOf<FileBasedSource>()));
34 expect(source.summaryPath, 'foo.sum'); 49 expect(source.summaryPath, 'foo.sum');
35 50
36 source = sourceFactory.forUri('package:bar/baz.dart'); 51 source = sourceFactory.forUri('package:bar/baz.dart');
52 expect(source, isNot(new isInstanceOf<FileBasedSource>()));
37 expect(source.summaryPath, 'bar.sum'); 53 expect(source.summaryPath, 'bar.sum');
38 } 54 }
39 } 55 }
40 56
41 class MockSummaryDataStore implements SummaryDataStore { 57 class MockSummaryDataStore implements SummaryDataStore {
42 final Map<String, LinkedLibrary> linkedMap; 58 final Map<String, LinkedLibrary> linkedMap;
43 final Map<String, UnlinkedUnit> unlinkedMap; 59 final Map<String, UnlinkedUnit> unlinkedMap;
44 final Map<String, String> uriToSummaryPath; 60 final Map<String, String> uriToSummaryPath;
45 61
46 MockSummaryDataStore(this.linkedMap, this.unlinkedMap, this.uriToSummaryPath); 62 MockSummaryDataStore(this.linkedMap, this.unlinkedMap, this.uriToSummaryPath);
47 63
48 factory MockSummaryDataStore.fake(Map<String, String> uriToSummary) { 64 factory MockSummaryDataStore.fake(Map<String, String> uriToSummary,
65 {Map<String, String> uriToFallbackModePath: const {}}) {
49 // Create fake unlinked map. 66 // Create fake unlinked map.
50 // We don't populate the values as it is not needed for the test. 67 // We don't populate the values as it is not needed for the test.
51 var unlinkedMap = new Map<String, UnlinkedUnit>.fromIterable( 68 var unlinkedMap = new Map<String, UnlinkedUnit>.fromIterable(
52 uriToSummary.keys, 69 uriToSummary.keys,
53 value: (k) => null); 70 value: (uri) => new UnlinkedUnitBuilder(
71 fallbackModePath: uriToFallbackModePath[uri]));
54 return new MockSummaryDataStore(null, unlinkedMap, uriToSummary); 72 return new MockSummaryDataStore(null, unlinkedMap, uriToSummary);
55 } 73 }
56 } 74 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_elements.dart ('k') | pkg/analyzer_cli/lib/src/build_mode.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698