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

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

Issue 1061803002: Detect and recover from infinite task loops (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/task/driver.dart ('k') | no next file » | 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) 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 expect(context.getCacheEntry(target).getValue(resultA), 10); 253 expect(context.getCacheEntry(target).getValue(resultA), 10);
254 expect(context.getCacheEntry(target).getValue(resultB), -2); 254 expect(context.getCacheEntry(target).getValue(resultB), -2);
255 // compute resultB 255 // compute resultB
256 expect(driver.performAnalysisTask(), true); 256 expect(driver.performAnalysisTask(), true);
257 expect(context.getCacheEntry(target).getValue(resultA), 10); 257 expect(context.getCacheEntry(target).getValue(resultA), 10);
258 expect(context.getCacheEntry(target).getValue(resultB), 20); 258 expect(context.getCacheEntry(target).getValue(resultB), 20);
259 // done 259 // done
260 expect(driver.performAnalysisTask(), false); 260 expect(driver.performAnalysisTask(), false);
261 } 261 }
262 262
263 test_performAnalysisTask_infiniteLoop() {
264 AnalysisTarget target = new TestSource();
265 ResultDescriptor resultA = new ResultDescriptor('resultA', -1);
266 ResultDescriptor resultB = new ResultDescriptor('resultB', -2);
267 // configure tasks
268 TestAnalysisTask task1;
269 TestAnalysisTask task2;
270 TaskDescriptor descriptor1 = new TaskDescriptor(
271 'task1', (context, target) => task1, (target) => {
272 'inputB': new SimpleTaskInput<int>(target, resultB)
273 }, [resultA]);
274 TaskDescriptor descriptor2 = new TaskDescriptor('task2',
275 (context, target) => task2, (target) => {
276 'inputA': new SimpleTaskInput<int>(target, resultA)
277 }, [resultB]);
278 task1 = new TestAnalysisTask(context, target, descriptor: descriptor1);
279 task2 = new TestAnalysisTask(context, target, descriptor: descriptor2);
280 manager.addTaskDescriptor(descriptor1);
281 manager.addTaskDescriptor(descriptor2);
282 context.explicitTargets.add(target);
283 manager.addGeneralResult(resultB);
284 // prepare work order
285 expect(driver.performAnalysisTask(), true);
286 expect(driver.performAnalysisTask(), true);
287 CaughtException exception = context.getCacheEntry(target).exception;
288 expect(exception, isNotNull);
289 expect(exception.exception, new isInstanceOf<InfiniteTaskLoopException>());
290 }
291
263 test_performWorkItem_exceptionInTask() { 292 test_performWorkItem_exceptionInTask() {
264 AnalysisTarget target = new TestSource(); 293 AnalysisTarget target = new TestSource();
265 ResultDescriptor result = new ResultDescriptor('result', null); 294 ResultDescriptor result = new ResultDescriptor('result', null);
266 CaughtException exception = 295 CaughtException exception =
267 new CaughtException(new AnalysisException(), null); 296 new CaughtException(new AnalysisException(), null);
268 TestAnalysisTask task; 297 TestAnalysisTask task;
269 TaskDescriptor descriptor = new TaskDescriptor( 298 TaskDescriptor descriptor = new TaskDescriptor(
270 'task', (context, target) => task, (target) => {}, [result]); 299 'task', (context, target) => task, (target) => {}, [result]);
271 task = new TestAnalysisTask(context, target, 300 task = new TestAnalysisTask(context, target,
272 descriptor: descriptor, exception: exception); 301 descriptor: descriptor, exception: exception);
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 void setContents(Source source, String contents) { 861 void setContents(Source source, String contents) {
833 baseContext.setContents(source, contents); 862 baseContext.setContents(source, contents);
834 } 863 }
835 864
836 @override 865 @override
837 void visitCacheItems(void callback(Source source, SourceEntry dartEntry, 866 void visitCacheItems(void callback(Source source, SourceEntry dartEntry,
838 DataDescriptor rowDesc, CacheState state)) { 867 DataDescriptor rowDesc, CacheState state)) {
839 baseContext.visitCacheItems(callback); 868 baseContext.visitCacheItems(callback);
840 } 869 }
841 } 870 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/driver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698