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

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

Issue 2624563003: Switch AnalysisDriver tests to using the physical SDK. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | pkg/analyzer/test/src/dart/analysis/driver_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/dart/element/visitor.dart'; 8 import 'package:analyzer/dart/element/visitor.dart';
9 import 'package:analyzer/file_system/file_system.dart'; 9 import 'package:analyzer/file_system/file_system.dart';
10 import 'package:analyzer/file_system/memory_file_system.dart'; 10 import 'package:analyzer/file_system/memory_file_system.dart';
11 import 'package:analyzer/source/package_map_resolver.dart'; 11 import 'package:analyzer/source/package_map_resolver.dart';
12 import 'package:analyzer/src/dart/analysis/byte_store.dart'; 12 import 'package:analyzer/src/dart/analysis/byte_store.dart';
13 import 'package:analyzer/src/dart/analysis/driver.dart'; 13 import 'package:analyzer/src/dart/analysis/driver.dart';
14 import 'package:analyzer/src/dart/analysis/file_state.dart'; 14 import 'package:analyzer/src/dart/analysis/file_state.dart';
15 import 'package:analyzer/src/dart/analysis/status.dart'; 15 import 'package:analyzer/src/dart/analysis/status.dart';
16 import 'package:analyzer/src/generated/engine.dart' show AnalysisOptionsImpl; 16 import 'package:analyzer/src/generated/engine.dart' show AnalysisOptionsImpl;
17 import 'package:analyzer/src/generated/source.dart'; 17 import 'package:analyzer/src/generated/source.dart';
18 import 'package:test/test.dart'; 18 import 'package:test/test.dart';
19 19
20 import '../../context/mock_sdk.dart'; 20 import 'physical_sdk.dart';
21 21
22 /** 22 /**
23 * Finds an [Element] with the given [name]. 23 * Finds an [Element] with the given [name].
24 */ 24 */
25 Element findChildElement(Element root, String name, [ElementKind kind]) { 25 Element findChildElement(Element root, String name, [ElementKind kind]) {
26 Element result = null; 26 Element result = null;
27 root.accept(new _ElementVisitorFunctionWrapper((Element element) { 27 root.accept(new _ElementVisitorFunctionWrapper((Element element) {
28 if (element.name != name) { 28 if (element.name != name) {
29 return; 29 return;
30 } 30 }
31 if (kind != null && element.kind != kind) { 31 if (kind != null && element.kind != kind) {
32 return; 32 return;
33 } 33 }
34 result = element; 34 result = element;
35 })); 35 }));
36 return result; 36 return result;
37 } 37 }
38 38
39 typedef bool Predicate<E>(E argument); 39 typedef bool Predicate<E>(E argument);
40 40
41 /** 41 /**
42 * A function to be called for every [Element]. 42 * A function to be called for every [Element].
43 */ 43 */
44 typedef void _ElementVisitorFunction(Element element); 44 typedef void _ElementVisitorFunction(Element element);
45 45
46 class BaseAnalysisDriverTest { 46 class BaseAnalysisDriverTest {
47 static final MockSdk sdk = new MockSdk();
48
49 final MemoryResourceProvider provider = new MemoryResourceProvider(); 47 final MemoryResourceProvider provider = new MemoryResourceProvider();
50 final ByteStore byteStore = new MemoryByteStore(); 48 final ByteStore byteStore = new MemoryByteStore();
51 final FileContentOverlay contentOverlay = new FileContentOverlay(); 49 final FileContentOverlay contentOverlay = new FileContentOverlay();
52 50
53 final StringBuffer logBuffer = new StringBuffer(); 51 final StringBuffer logBuffer = new StringBuffer();
54 PerformanceLog logger; 52 PerformanceLog logger;
55 53
56 AnalysisDriverScheduler scheduler; 54 AnalysisDriverScheduler scheduler;
57 AnalysisDriver driver; 55 AnalysisDriver driver;
58 final _Monitor idleStatusMonitor = new _Monitor(); 56 final _Monitor idleStatusMonitor = new _Monitor();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 if (c >= '0'.codeUnitAt(0) && c <= '9'.codeUnitAt(0)) { 93 if (c >= '0'.codeUnitAt(0) && c <= '9'.codeUnitAt(0)) {
96 length++; 94 length++;
97 continue; 95 continue;
98 } 96 }
99 break; 97 break;
100 } 98 }
101 return length; 99 return length;
102 } 100 }
103 101
104 void setUp() { 102 void setUp() {
105 new MockSdk();
106 testProject = _p('/test/lib'); 103 testProject = _p('/test/lib');
107 testFile = _p('/test/lib/test.dart'); 104 testFile = _p('/test/lib/test.dart');
108 logger = new PerformanceLog(logBuffer); 105 logger = new PerformanceLog(logBuffer);
109 scheduler = new AnalysisDriverScheduler(logger); 106 scheduler = new AnalysisDriverScheduler(logger);
110 driver = new AnalysisDriver( 107 driver = new AnalysisDriver(
111 scheduler, 108 scheduler,
112 logger, 109 logger,
113 provider, 110 provider,
114 byteStore, 111 byteStore,
115 contentOverlay, 112 contentOverlay,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 await _completer.future; 152 await _completer.future;
156 _completer = new Completer<Null>(); 153 _completer = new Completer<Null>();
157 } 154 }
158 155
159 void notify() { 156 void notify() {
160 if (!_completer.isCompleted) { 157 if (!_completer.isCompleted) {
161 _completer.complete(null); 158 _completer.complete(null);
162 } 159 }
163 } 160 }
164 } 161 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/dart/analysis/driver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698