| 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 analyzer.test.src.task.driver_test; | 5 library analyzer.test.src.task.driver_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/context/cache.dart'; | 7 import 'package:analyzer/src/context/cache.dart'; |
| 8 import 'package:analyzer/src/generated/engine.dart'; | 8 import 'package:analyzer/src/generated/engine.dart'; |
| 9 import 'package:analyzer/src/generated/java_engine.dart'; | 9 import 'package:analyzer/src/generated/java_engine.dart'; |
| 10 import 'package:analyzer/src/task/driver.dart'; | 10 import 'package:analyzer/src/task/driver.dart'; |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 when(workManager1.getNextResult()) | 234 when(workManager1.getNextResult()) |
| 235 .thenReturn(new TargetedResult(target1, result1)); | 235 .thenReturn(new TargetedResult(target1, result1)); |
| 236 | 236 |
| 237 expect(analysisDriver.performAnalysisTask(), true); | 237 expect(analysisDriver.performAnalysisTask(), true); |
| 238 expect(analysisDriver.performAnalysisTask(), true); | 238 expect(analysisDriver.performAnalysisTask(), true); |
| 239 expect(analysisDriver.performAnalysisTask(), false); | 239 expect(analysisDriver.performAnalysisTask(), false); |
| 240 } | 240 } |
| 241 | 241 |
| 242 test_performAnalysisTask_infiniteLoop_handled() { | 242 test_performAnalysisTask_infiniteLoop_handled() { |
| 243 AnalysisTarget target = new TestSource(); | 243 AnalysisTarget target = new TestSource(); |
| 244 ResultDescriptor resultA = new ResultDescriptor('resultA', -1); | 244 ResultDescriptor<int> resultA = new ResultDescriptor<int>('resultA', -1); |
| 245 ResultDescriptor resultB = new ResultDescriptor('resultB', -2); | 245 ResultDescriptor<int> resultB = new ResultDescriptor<int>('resultB', -2); |
| 246 // configure tasks | 246 // configure tasks |
| 247 TestAnalysisTask task1; | 247 TestAnalysisTask task1; |
| 248 TestAnalysisTask task2; | 248 TestAnalysisTask task2; |
| 249 TaskDescriptor descriptor1 = new TaskDescriptor( | 249 TaskDescriptor descriptor1 = new TaskDescriptor( |
| 250 'task1', | 250 'task1', |
| 251 (context, target) => task1, | 251 (context, target) => task1, |
| 252 (target) => {'inputB': new SimpleTaskInput<int>(target, resultB)}, | 252 (target) => {'inputB': new SimpleTaskInput<int>(target, resultB)}, |
| 253 [resultA]); | 253 [resultA]); |
| 254 TaskDescriptor descriptor2 = new TaskDescriptor( | 254 TaskDescriptor descriptor2 = new TaskDescriptor( |
| 255 'task2', | 255 'task2', |
| (...skipping 27 matching lines...) Expand all Loading... |
| 283 expect(task2.dependencyCycle.map((workItem) => workItem.descriptor).toSet(), | 283 expect(task2.dependencyCycle.map((workItem) => workItem.descriptor).toSet(), |
| 284 expectedCycle); | 284 expectedCycle); |
| 285 CaughtException exception = context.getCacheEntry(target).exception; | 285 CaughtException exception = context.getCacheEntry(target).exception; |
| 286 expect(exception, isNull); | 286 expect(exception, isNull); |
| 287 expect(context.getCacheEntry(target).getValue(resultA), 10); | 287 expect(context.getCacheEntry(target).getValue(resultA), 10); |
| 288 expect(context.getCacheEntry(target).getValue(resultB), 20); | 288 expect(context.getCacheEntry(target).getValue(resultB), 20); |
| 289 } | 289 } |
| 290 | 290 |
| 291 test_performAnalysisTask_infiniteLoop_unhandled() { | 291 test_performAnalysisTask_infiniteLoop_unhandled() { |
| 292 AnalysisTarget target = new TestSource(); | 292 AnalysisTarget target = new TestSource(); |
| 293 ResultDescriptor resultA = new ResultDescriptor('resultA', -1); | 293 ResultDescriptor<int> resultA = new ResultDescriptor<int>('resultA', -1); |
| 294 ResultDescriptor resultB = new ResultDescriptor('resultB', -2); | 294 ResultDescriptor<int> resultB = new ResultDescriptor<int>('resultB', -2); |
| 295 // configure tasks | 295 // configure tasks |
| 296 TestAnalysisTask task1; | 296 TestAnalysisTask task1; |
| 297 TestAnalysisTask task2; | 297 TestAnalysisTask task2; |
| 298 TaskDescriptor descriptor1 = new TaskDescriptor( | 298 TaskDescriptor descriptor1 = new TaskDescriptor( |
| 299 'task1', | 299 'task1', |
| 300 (context, target) => task1, | 300 (context, target) => task1, |
| 301 (target) => {'inputB': new SimpleTaskInput<int>(target, resultB)}, | 301 (target) => {'inputB': new SimpleTaskInput<int>(target, resultB)}, |
| 302 [resultA]); | 302 [resultA]); |
| 303 TaskDescriptor descriptor2 = new TaskDescriptor( | 303 TaskDescriptor descriptor2 = new TaskDescriptor( |
| 304 'task2', | 304 'task2', |
| (...skipping 12 matching lines...) Expand all Loading... |
| 317 // prepare work order | 317 // prepare work order |
| 318 expect(analysisDriver.performAnalysisTask(), true); | 318 expect(analysisDriver.performAnalysisTask(), true); |
| 319 expect(analysisDriver.performAnalysisTask(), true); | 319 expect(analysisDriver.performAnalysisTask(), true); |
| 320 CaughtException exception = context.getCacheEntry(target).exception; | 320 CaughtException exception = context.getCacheEntry(target).exception; |
| 321 expect(exception, isNotNull); | 321 expect(exception, isNotNull); |
| 322 expect(exception.exception, new isInstanceOf<InfiniteTaskLoopException>()); | 322 expect(exception.exception, new isInstanceOf<InfiniteTaskLoopException>()); |
| 323 } | 323 } |
| 324 | 324 |
| 325 test_performAnalysisTask_inputsFirst() { | 325 test_performAnalysisTask_inputsFirst() { |
| 326 AnalysisTarget target = new TestSource(); | 326 AnalysisTarget target = new TestSource(); |
| 327 ResultDescriptor resultA = new ResultDescriptor('resultA', -1); | 327 ResultDescriptor<int> resultA = new ResultDescriptor<int>('resultA', -1); |
| 328 ResultDescriptor resultB = new ResultDescriptor('resultB', -2); | 328 ResultDescriptor<int> resultB = new ResultDescriptor<int>('resultB', -2); |
| 329 // configure tasks | 329 // configure tasks |
| 330 TestAnalysisTask task1; | 330 TestAnalysisTask task1; |
| 331 TestAnalysisTask task2; | 331 TestAnalysisTask task2; |
| 332 TaskDescriptor descriptor1 = new TaskDescriptor( | 332 TaskDescriptor descriptor1 = new TaskDescriptor( |
| 333 'task1', (context, target) => task1, (target) => {}, [resultA]); | 333 'task1', (context, target) => task1, (target) => {}, [resultA]); |
| 334 TaskDescriptor descriptor2 = new TaskDescriptor( | 334 TaskDescriptor descriptor2 = new TaskDescriptor( |
| 335 'task2', | 335 'task2', |
| 336 (context, target) => task2, | 336 (context, target) => task2, |
| 337 (target) => {'inputA': new SimpleTaskInput<int>(target, resultA)}, | 337 (target) => {'inputA': new SimpleTaskInput<int>(target, resultA)}, |
| 338 [resultB]); | 338 [resultB]); |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 if (!skipInputs.contains(dependency) && | 856 if (!skipInputs.contains(dependency) && |
| 857 !evaluatedNodes.contains(dependency)) { | 857 !evaluatedNodes.contains(dependency)) { |
| 858 return dependency; | 858 return dependency; |
| 859 } | 859 } |
| 860 } | 860 } |
| 861 return null; | 861 return null; |
| 862 } | 862 } |
| 863 } | 863 } |
| 864 | 864 |
| 865 class _WorkManagerMock extends TypedMock implements WorkManager {} | 865 class _WorkManagerMock extends TypedMock implements WorkManager {} |
| OLD | NEW |