OLD | NEW |
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 2161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2172 allResults.clear(); | 2172 allResults.clear(); |
2173 | 2173 |
2174 // Remove a.dart, now b.dart should be reanalyzed and has an error. | 2174 // Remove a.dart, now b.dart should be reanalyzed and has an error. |
2175 provider.deleteFile(a); | 2175 provider.deleteFile(a); |
2176 driver.removeFile(a); | 2176 driver.removeFile(a); |
2177 await scheduler.waitForIdle(); | 2177 await scheduler.waitForIdle(); |
2178 expect(allResults.singleWhere((r) => r.path == b).errors, hasLength(2)); | 2178 expect(allResults.singleWhere((r) => r.path == b).errors, hasLength(2)); |
2179 allResults.clear(); | 2179 allResults.clear(); |
2180 } | 2180 } |
2181 | 2181 |
| 2182 test_results_order() async { |
| 2183 var a = _p('/test/lib/a.dart'); |
| 2184 var b = _p('/test/lib/b.dart'); |
| 2185 var c = _p('/test/lib/c.dart'); |
| 2186 var d = _p('/test/lib/d.dart'); |
| 2187 var e = _p('/test/lib/e.dart'); |
| 2188 var f = _p('/test/lib/f.dart'); |
| 2189 provider.newFile( |
| 2190 a, |
| 2191 r''' |
| 2192 import 'd.dart'; |
| 2193 '''); |
| 2194 provider.newFile(b, ''); |
| 2195 provider.newFile( |
| 2196 c, |
| 2197 r''' |
| 2198 import 'd.dart'; |
| 2199 '''); |
| 2200 provider.newFile( |
| 2201 d, |
| 2202 r''' |
| 2203 import 'b.dart'; |
| 2204 '''); |
| 2205 provider.newFile( |
| 2206 e, |
| 2207 r''' |
| 2208 export 'b.dart'; |
| 2209 '''); |
| 2210 provider.newFile( |
| 2211 f, |
| 2212 r''' |
| 2213 import 'e.dart'; |
| 2214 class F extends X {} |
| 2215 '''); |
| 2216 |
| 2217 driver.addFile(a); |
| 2218 driver.addFile(b); |
| 2219 driver.addFile(c); |
| 2220 driver.addFile(d); |
| 2221 driver.addFile(e); |
| 2222 driver.addFile(f); |
| 2223 await scheduler.waitForIdle(); |
| 2224 |
| 2225 // The file f.dart has an error or warning. |
| 2226 // So, its analysis will have higher priority. |
| 2227 expect(driver.fsState.getFileForPath(f).hasErrorOrWarning, isTrue); |
| 2228 |
| 2229 allResults.clear(); |
| 2230 |
| 2231 // Update a.dart with changing its API signature. |
| 2232 provider.updateFile(b, 'class A {}'); |
| 2233 driver.changeFile(b); |
| 2234 await scheduler.waitForIdle(); |
| 2235 |
| 2236 List<String> analyzedPaths = allResults.map((r) => r.path).toList(); |
| 2237 |
| 2238 // The changed file must be the first. |
| 2239 expect(analyzedPaths[0], b); |
| 2240 |
| 2241 // Then the file that imports the changed file. |
| 2242 expect(analyzedPaths[1], d); |
| 2243 |
| 2244 // Then the file that has an error (even if it is unrelated). |
| 2245 expect(analyzedPaths[2], f); |
| 2246 } |
| 2247 |
2182 test_results_priority() async { | 2248 test_results_priority() async { |
2183 String content = 'int f() => 42;'; | 2249 String content = 'int f() => 42;'; |
2184 addTestFile(content, priority: true); | 2250 addTestFile(content, priority: true); |
2185 | 2251 |
2186 await scheduler.waitForIdle(); | 2252 await scheduler.waitForIdle(); |
2187 | 2253 |
2188 expect(allResults, hasLength(1)); | 2254 expect(allResults, hasLength(1)); |
2189 AnalysisResult result = allResults.single; | 2255 AnalysisResult result = allResults.single; |
2190 expect(result.path, testFile); | 2256 expect(result.path, testFile); |
2191 expect(result.uri.toString(), 'package:test/test.dart'); | 2257 expect(result.uri.toString(), 'package:test/test.dart'); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2400 * Return the [provider] specific path for the given Posix [path]. | 2466 * Return the [provider] specific path for the given Posix [path]. |
2401 */ | 2467 */ |
2402 String _p(String path) => provider.convertPath(path); | 2468 String _p(String path) => provider.convertPath(path); |
2403 | 2469 |
2404 static String _md5(String content) { | 2470 static String _md5(String content) { |
2405 return hex.encode(md5.convert(UTF8.encode(content)).bytes); | 2471 return hex.encode(md5.convert(UTF8.encode(content)).bytes); |
2406 } | 2472 } |
2407 } | 2473 } |
2408 | 2474 |
2409 class _SourceMock extends TypedMock implements Source {} | 2475 class _SourceMock extends TypedMock implements Source {} |
OLD | NEW |