| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 test.src.task.driver_test; | 5 library test.src.task.driver_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analyzer/src/cancelable_future.dart'; | 10 import 'package:analyzer/src/cancelable_future.dart'; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 WorkOrder workOrder = driver.createNextWorkOrder(); | 133 WorkOrder workOrder = driver.createNextWorkOrder(); |
| 134 expect(workOrder, isNotNull); | 134 expect(workOrder, isNotNull); |
| 135 expect(workOrder.moveNext(), true); | 135 expect(workOrder.moveNext(), true); |
| 136 expect(workOrder.currentItem.target, priorityTarget); | 136 expect(workOrder.currentItem.target, priorityTarget); |
| 137 } | 137 } |
| 138 | 138 |
| 139 test_createWorkOrderForResult_error() { | 139 test_createWorkOrderForResult_error() { |
| 140 AnalysisTarget target = new TestSource(); | 140 AnalysisTarget target = new TestSource(); |
| 141 ResultDescriptor result = new ResultDescriptor('result', null); | 141 ResultDescriptor result = new ResultDescriptor('result', null); |
| 142 CaughtException exception = new CaughtException(null, null); | 142 CaughtException exception = new CaughtException(null, null); |
| 143 context | 143 context.getCacheEntry(target).setErrorState( |
| 144 .getCacheEntry(target) | 144 exception, <ResultDescriptor>[result]); |
| 145 .setErrorState(exception, <ResultDescriptor>[result]); | |
| 146 | 145 |
| 147 expect(driver.createWorkOrderForResult(target, result), isNull); | 146 expect(driver.createWorkOrderForResult(target, result), isNull); |
| 148 } | 147 } |
| 149 | 148 |
| 150 test_createWorkOrderForResult_inProcess() { | 149 test_createWorkOrderForResult_inProcess() { |
| 151 AnalysisTarget target = new TestSource(); | 150 AnalysisTarget target = new TestSource(); |
| 152 ResultDescriptor result = new ResultDescriptor('result', null); | 151 ResultDescriptor result = new ResultDescriptor('result', null); |
| 153 context.getCacheEntry(target).setState(result, CacheState.IN_PROCESS); | 152 context.getCacheEntry(target).setState(result, CacheState.IN_PROCESS); |
| 154 | 153 |
| 155 expect(driver.createWorkOrderForResult(target, result), isNull); | 154 expect(driver.createWorkOrderForResult(target, result), isNull); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 test_performAnalysisTask_inputsFirst() { | 226 test_performAnalysisTask_inputsFirst() { |
| 228 AnalysisTarget target = new TestSource(); | 227 AnalysisTarget target = new TestSource(); |
| 229 ResultDescriptor resultA = new ResultDescriptor('resultA', -1); | 228 ResultDescriptor resultA = new ResultDescriptor('resultA', -1); |
| 230 ResultDescriptor resultB = new ResultDescriptor('resultB', -2); | 229 ResultDescriptor resultB = new ResultDescriptor('resultB', -2); |
| 231 // configure tasks | 230 // configure tasks |
| 232 TestAnalysisTask task1; | 231 TestAnalysisTask task1; |
| 233 TestAnalysisTask task2; | 232 TestAnalysisTask task2; |
| 234 TaskDescriptor descriptor1 = new TaskDescriptor( | 233 TaskDescriptor descriptor1 = new TaskDescriptor( |
| 235 'task1', (context, target) => task1, (target) => {}, [resultA]); | 234 'task1', (context, target) => task1, (target) => {}, [resultA]); |
| 236 TaskDescriptor descriptor2 = new TaskDescriptor('task2', | 235 TaskDescriptor descriptor2 = new TaskDescriptor('task2', |
| 237 (context, target) => task2, | 236 (context, target) => task2, (target) => { |
| 238 (target) => {'inputA': new SimpleTaskInput<int>(target, resultA)}, [ | 237 'inputA': new SimpleTaskInput<int>(target, resultA) |
| 239 resultB | 238 }, [resultB]); |
| 240 ]); | |
| 241 task1 = new TestAnalysisTask(context, target, | 239 task1 = new TestAnalysisTask(context, target, |
| 242 descriptor: descriptor1, results: [resultA], value: 10); | 240 descriptor: descriptor1, results: [resultA], value: 10); |
| 243 task2 = new TestAnalysisTask(context, target, | 241 task2 = new TestAnalysisTask(context, target, |
| 244 descriptor: descriptor2, value: 20); | 242 descriptor: descriptor2, value: 20); |
| 245 manager.addTaskDescriptor(descriptor1); | 243 manager.addTaskDescriptor(descriptor1); |
| 246 manager.addTaskDescriptor(descriptor2); | 244 manager.addTaskDescriptor(descriptor2); |
| 247 context.explicitTargets.add(target); | 245 context.explicitTargets.add(target); |
| 248 manager.addGeneralResult(resultB); | 246 manager.addGeneralResult(resultB); |
| 249 // prepare work order | 247 // prepare work order |
| 250 expect(driver.performAnalysisTask(), true); | 248 expect(driver.performAnalysisTask(), true); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 driver.performWorkItem(item); | 307 driver.performWorkItem(item); |
| 310 CacheEntry targetEntry = context.getCacheEntry(item.target); | 308 CacheEntry targetEntry = context.getCacheEntry(item.target); |
| 311 expect(targetEntry.exception, exception); | 309 expect(targetEntry.exception, exception); |
| 312 expect(targetEntry.getState(result), CacheState.ERROR); | 310 expect(targetEntry.getState(result), CacheState.ERROR); |
| 313 } | 311 } |
| 314 | 312 |
| 315 test_reset() { | 313 test_reset() { |
| 316 ResultDescriptor inputResult = new ResultDescriptor('input', null); | 314 ResultDescriptor inputResult = new ResultDescriptor('input', null); |
| 317 TaskDescriptor descriptor = new TaskDescriptor('task', | 315 TaskDescriptor descriptor = new TaskDescriptor('task', |
| 318 (context, target) => new TestAnalysisTask(context, target), | 316 (context, target) => new TestAnalysisTask(context, target), |
| 319 (target) => {'one': inputResult.inputFor(target)}, [ | 317 (target) => {'one': inputResult.inputFor(target)}, |
| 320 new ResultDescriptor('output', null) | 318 [new ResultDescriptor('output', null)]); |
| 321 ]); | |
| 322 driver.currentWorkOrder = | 319 driver.currentWorkOrder = |
| 323 new WorkOrder(manager, new WorkItem(null, null, descriptor)); | 320 new WorkOrder(manager, new WorkItem(null, null, descriptor)); |
| 324 | 321 |
| 325 driver.reset(); | 322 driver.reset(); |
| 326 expect(driver.currentWorkOrder, isNull); | 323 expect(driver.currentWorkOrder, isNull); |
| 327 } | 324 } |
| 328 | 325 |
| 329 /** | 326 /** |
| 330 * [complete] is `true` if the value of the result has already been computed. | 327 * [complete] is `true` if the value of the result has already been computed. |
| 331 * [priorityTarget] is `true` if the target is in the list of priority | 328 * [priorityTarget] is `true` if the target is in the list of priority |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 (target) => {}, [new ResultDescriptor('output', null)]); | 376 (target) => {}, [new ResultDescriptor('output', null)]); |
| 380 WorkItem item = new WorkItem(context, target, descriptor); | 377 WorkItem item = new WorkItem(context, target, descriptor); |
| 381 AnalysisTask task = item.buildTask(); | 378 AnalysisTask task = item.buildTask(); |
| 382 expect(task, isNotNull); | 379 expect(task, isNotNull); |
| 383 } | 380 } |
| 384 | 381 |
| 385 test_buildTask_incomplete() { | 382 test_buildTask_incomplete() { |
| 386 AnalysisContext context = new _TestContext(); | 383 AnalysisContext context = new _TestContext(); |
| 387 AnalysisTarget target = new TestSource(); | 384 AnalysisTarget target = new TestSource(); |
| 388 ResultDescriptor inputResult = new ResultDescriptor('input', null); | 385 ResultDescriptor inputResult = new ResultDescriptor('input', null); |
| 389 List<ResultDescriptor> outputResults = <ResultDescriptor>[ | 386 List<ResultDescriptor> outputResults = |
| 390 new ResultDescriptor('output', null) | 387 <ResultDescriptor>[new ResultDescriptor('output', null)]; |
| 391 ]; | |
| 392 TaskDescriptor descriptor = new TaskDescriptor('task', (context, target) => | 388 TaskDescriptor descriptor = new TaskDescriptor('task', (context, target) => |
| 393 new TestAnalysisTask(context, target, results: outputResults), | 389 new TestAnalysisTask(context, target, results: outputResults), |
| 394 (target) => {'one': inputResult.inputFor(target)}, outputResults); | 390 (target) => {'one': inputResult.inputFor(target)}, outputResults); |
| 395 WorkItem item = new WorkItem(context, target, descriptor); | 391 WorkItem item = new WorkItem(context, target, descriptor); |
| 396 expect(() => item.buildTask(), throwsStateError); | 392 expect(() => item.buildTask(), throwsStateError); |
| 397 } | 393 } |
| 398 | 394 |
| 399 test_create() { | 395 test_create() { |
| 400 AnalysisContext context = new _TestContext(); | 396 AnalysisContext context = new _TestContext(); |
| 401 AnalysisTarget target = new TestSource(); | 397 AnalysisTarget target = new TestSource(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 expect(item.gatherInputs(manager), isNotNull); | 435 expect(item.gatherInputs(manager), isNotNull); |
| 440 } | 436 } |
| 441 | 437 |
| 442 test_gatherInputs_invalid() { | 438 test_gatherInputs_invalid() { |
| 443 TaskManager manager = new TaskManager(); | 439 TaskManager manager = new TaskManager(); |
| 444 AnalysisContext context = new _TestContext(); | 440 AnalysisContext context = new _TestContext(); |
| 445 AnalysisTarget target = new TestSource(); | 441 AnalysisTarget target = new TestSource(); |
| 446 ResultDescriptor inputResult = new ResultDescriptor('input', null); | 442 ResultDescriptor inputResult = new ResultDescriptor('input', null); |
| 447 TaskDescriptor descriptor = new TaskDescriptor('task', | 443 TaskDescriptor descriptor = new TaskDescriptor('task', |
| 448 (context, target) => new TestAnalysisTask(context, target), | 444 (context, target) => new TestAnalysisTask(context, target), |
| 449 (target) => {'one': inputResult.inputFor(target)}, [ | 445 (target) => {'one': inputResult.inputFor(target)}, |
| 450 new ResultDescriptor('output', null) | 446 [new ResultDescriptor('output', null)]); |
| 451 ]); | |
| 452 WorkItem item = new WorkItem(context, target, descriptor); | 447 WorkItem item = new WorkItem(context, target, descriptor); |
| 453 WorkItem result = item.gatherInputs(manager); | 448 WorkItem result = item.gatherInputs(manager); |
| 454 expect(result, isNull); | 449 expect(result, isNull); |
| 455 expect(item.exception, isNotNull); | 450 expect(item.exception, isNotNull); |
| 456 } | 451 } |
| 457 } | 452 } |
| 458 | 453 |
| 459 @reflectiveTest | 454 @reflectiveTest |
| 460 class WorkOrderTest extends EngineTestCase { | 455 class WorkOrderTest extends EngineTestCase { |
| 461 test_create() { | 456 test_create() { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 @override | 557 @override |
| 563 List<Source> get sources => baseContext.sources; | 558 List<Source> get sources => baseContext.sources; |
| 564 | 559 |
| 565 @override | 560 @override |
| 566 AnalysisContextStatistics get statistics => baseContext.statistics; | 561 AnalysisContextStatistics get statistics => baseContext.statistics; |
| 567 | 562 |
| 568 @override | 563 @override |
| 569 TypeProvider get typeProvider => baseContext.typeProvider; | 564 TypeProvider get typeProvider => baseContext.typeProvider; |
| 570 | 565 |
| 571 @override | 566 @override |
| 567 void set typeProvider(TypeProvider typeProvider) { |
| 568 baseContext.typeProvider = typeProvider; |
| 569 } |
| 570 |
| 571 @override |
| 572 TypeResolverVisitorFactory get typeResolverVisitorFactory => | 572 TypeResolverVisitorFactory get typeResolverVisitorFactory => |
| 573 baseContext.typeResolverVisitorFactory; | 573 baseContext.typeResolverVisitorFactory; |
| 574 | 574 |
| 575 @override | 575 @override |
| 576 void addListener(AnalysisListener listener) { | 576 void addListener(AnalysisListener listener) { |
| 577 baseContext.addListener(listener); | 577 baseContext.addListener(listener); |
| 578 } | 578 } |
| 579 | 579 |
| 580 @override | 580 @override |
| 581 void addSourceInfo(Source source, SourceEntry info) { | 581 void addSourceInfo(Source source, SourceEntry info) { |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 void setContents(Source source, String contents) { | 832 void setContents(Source source, String contents) { |
| 833 baseContext.setContents(source, contents); | 833 baseContext.setContents(source, contents); |
| 834 } | 834 } |
| 835 | 835 |
| 836 @override | 836 @override |
| 837 void visitCacheItems(void callback(Source source, SourceEntry dartEntry, | 837 void visitCacheItems(void callback(Source source, SourceEntry dartEntry, |
| 838 DataDescriptor rowDesc, CacheState state)) { | 838 DataDescriptor rowDesc, CacheState state)) { |
| 839 baseContext.visitCacheItems(callback); | 839 baseContext.visitCacheItems(callback); |
| 840 } | 840 } |
| 841 } | 841 } |
| OLD | NEW |