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

Side by Side Diff: pkg/analyzer/test/src/dart/analysis/driver_test.dart

Issue 2653683004: Stop using SDK summary bundle. Analyze dart:xxx as any other libraries. (Closed)
Patch Set: Restore optional SDK bundle. Created 3 years, 11 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.driver; 5 library analyzer.test.driver;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 final FileContentOverlay contentOverlay = new FileContentOverlay(); 61 final FileContentOverlay contentOverlay = new FileContentOverlay();
62 62
63 final StringBuffer logBuffer = new StringBuffer(); 63 final StringBuffer logBuffer = new StringBuffer();
64 PerformanceLog logger; 64 PerformanceLog logger;
65 65
66 AnalysisDriverScheduler scheduler; 66 AnalysisDriverScheduler scheduler;
67 67
68 List<AnalysisResult> allResults = []; 68 List<AnalysisResult> allResults = [];
69 69
70 AnalysisDriver newDriver() { 70 AnalysisDriver newDriver() {
71 sdk = new MockSdk(resourceProvider: provider);
71 AnalysisDriver driver = new AnalysisDriver( 72 AnalysisDriver driver = new AnalysisDriver(
72 scheduler, 73 scheduler,
73 logger, 74 logger,
74 provider, 75 provider,
75 byteStore, 76 byteStore,
76 contentOverlay, 77 contentOverlay,
77 'test', 78 'test',
78 new SourceFactory( 79 new SourceFactory(
79 [new DartUriResolver(sdk), new ResourceUriResolver(provider)], 80 [new DartUriResolver(sdk), new ResourceUriResolver(provider)],
80 null, 81 null,
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 r''' 1239 r'''
1239 import 'b.dart'; 1240 import 'b.dart';
1240 '''); 1241 ''');
1241 provider.newFile(b, ''); 1242 provider.newFile(b, '');
1242 provider.newFile(c, ''); 1243 provider.newFile(c, '');
1243 1244
1244 driver.addFile(a); 1245 driver.addFile(a);
1245 driver.addFile(c); 1246 driver.addFile(c);
1246 await driver.waitForIdle(); 1247 await driver.waitForIdle();
1247 1248
1248 expect(driver.knownFiles, unorderedEquals([a, b, c])); 1249 expect(driver.knownFiles, contains(a));
1250 expect(driver.knownFiles, contains(b));
1251 expect(driver.knownFiles, contains(c));
1249 1252
1250 // Remove a.dart and analyze. 1253 // Remove a.dart and analyze.
1251 // Both a.dart and b.dart are not known now. 1254 // Both a.dart and b.dart are not known now.
1252 driver.removeFile(a); 1255 driver.removeFile(a);
1253 await driver.waitForIdle(); 1256 await driver.waitForIdle();
1254 expect(driver.knownFiles, unorderedEquals([c])); 1257 expect(driver.knownFiles, isNot(contains(a)));
1258 expect(driver.knownFiles, isNot(contains(b)));
1259 expect(driver.knownFiles, contains(c));
1255 } 1260 }
1256 1261
1257 test_knownFiles_beforeAnalysis() async { 1262 test_knownFiles_beforeAnalysis() async {
1258 var a = _p('/test/lib/a.dart'); 1263 var a = _p('/test/lib/a.dart');
1259 var b = _p('/test/lib/b.dart'); 1264 var b = _p('/test/lib/b.dart');
1260 1265
1261 provider.newFile(a, ''); 1266 provider.newFile(a, '');
1262 1267
1263 // 'a.dart' is added, but not processed yet. 1268 // 'a.dart' is added, but not processed yet.
1264 // So, the set of known files is empty yet. 1269 // So, the set of known files is empty yet.
1265 driver.addFile(a); 1270 driver.addFile(a);
1266 expect(driver.knownFiles, isEmpty); 1271 expect(driver.knownFiles, isEmpty);
1267 1272
1268 // Remove 'a.dart'. 1273 // Remove 'a.dart'.
1269 // It has been no analysis yet, so 'a.dart' is not in the file state, only 1274 // It has been no analysis yet, so 'a.dart' is not in the file state, only
1270 // in 'added' files. So, it disappears when removed. 1275 // in 'added' files. So, it disappears when removed.
1271 driver.removeFile(a); 1276 driver.removeFile(a);
1272 expect(driver.knownFiles, isNot(contains(a))); 1277 expect(driver.knownFiles, isNot(contains(a)));
1273 expect(driver.knownFiles, isNot(contains(b))); 1278 expect(driver.knownFiles, isNot(contains(b)));
1274 } 1279 }
1275 1280
1276 test_parseFile_notDart() async { 1281 test_parseFile_notDart() async {
1277 var p = _p('/test/bin/a.txt'); 1282 var p = _p('/test/bin/a.txt');
1278 provider.newFile(p, 'class A {}'); 1283 provider.newFile(p, 'class A {}');
1279 1284
1280 ParseResult parseResult = await driver.parseFile(p); 1285 ParseResult parseResult = await driver.parseFile(p);
1281 expect(parseResult, isNotNull); 1286 expect(parseResult, isNotNull);
1282 expect(driver.knownFiles, [p]); 1287 expect(driver.knownFiles, contains(p));
1283 } 1288 }
1284 1289
1285 test_parseFile_shouldRefresh() async { 1290 test_parseFile_shouldRefresh() async {
1286 var p = _p('/test/bin/a.dart'); 1291 var p = _p('/test/bin/a.dart');
1287 1292
1288 provider.newFile(p, 'class A {}'); 1293 provider.newFile(p, 'class A {}');
1289 driver.addFile(p); 1294 driver.addFile(p);
1290 1295
1291 // Get the result, so force the file reading. 1296 // Get the result, so force the file reading.
1292 await driver.getResult(p); 1297 await driver.getResult(p);
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 1829
1825 /** 1830 /**
1826 * Return the [provider] specific path for the given Posix [path]. 1831 * Return the [provider] specific path for the given Posix [path].
1827 */ 1832 */
1828 String _p(String path) => provider.convertPath(path); 1833 String _p(String path) => provider.convertPath(path);
1829 1834
1830 static String _md5(String content) { 1835 static String _md5(String content) {
1831 return hex.encode(md5.convert(UTF8.encode(content)).bytes); 1836 return hex.encode(md5.convert(UTF8.encode(content)).bytes);
1832 } 1837 }
1833 } 1838 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/file_state.dart ('k') | pkg/analyzer/test/src/dart/analysis/file_state_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698