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

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

Issue 1807673006: Initial LibraryBundleCache implementation. (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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'package:analyzer/file_system/file_system.dart';
6 import 'package:analyzer/src/summary/idl.dart';
7 import 'package:analyzer/src/summary/incremental_cache.dart';
8 import 'package:unittest/unittest.dart';
9
10 import '../../reflective_tests.dart';
11 import '../abstract_single_unit.dart';
12
13 main() {
14 groupSep = ' | ';
15 runReflectiveTests(LibraryBundleCacheTest);
16 }
17
18 /**
19 * TODO(scheglov) write more tests for invalidation.
20 */
21 @reflectiveTest
22 class LibraryBundleCacheTest extends AbstractSingleUnitTest {
23 Folder cacheFolder;
24 LibraryBundleCache cache;
25
26 @override
27 void setUp() {
28 super.setUp();
29 cacheFolder = resourceProvider.newFolder('/cache');
30 cache = new LibraryBundleCache(cacheFolder, context, <int>[]);
31 }
32
33 void test_readBundle_emptyCache() {
34 resolveTestUnit('main() {}');
35 // the cache is empty, no bundle
36 PackageBundle bundle = cache.readBundle(testSource);
37 expect(bundle, isNull);
38 }
39
40 void test_readBundle_importSdk() {
41 resolveTestUnit(r'''
42 import 'dart:async';
43 main() {}
44 ''');
45 cache.putLibrary(testLibraryElement);
46 // has bundle
47 PackageBundle bundle = cache.readBundle(testSource);
48 expect(bundle, isNotNull);
49 }
50
51 void test_readBundle_importLib() {
52 addSource('/a.dart', '// 1');
53 resolveTestUnit(r'''
54 import 'a.dart';
55 main() {}
56 ''');
57 cache.putLibrary(testLibraryElement);
58 // has bundle
59 expect(cache.readBundle(testSource), isNotNull);
60 // update a.dart, no bundle
61 cache.clearInternalCaches();
62 resourceProvider.updateFile('/a.dart', '// 2');
63 expect(cache.readBundle(testSource), isNull);
64 }
65
66 void test_readBundle_withoutDependencies() {
67 resolveTestUnit('main() {}');
68 cache.putLibrary(testLibraryElement);
69 // has bundle
70 PackageBundle bundle = cache.readBundle(testSource);
71 expect(bundle, isNotNull);
72 }
73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698