| 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 10 matching lines...) Expand all Loading... |
| 21 import 'package:analyzer/src/dart/analysis/top_level_declaration.dart'; | 21 import 'package:analyzer/src/dart/analysis/top_level_declaration.dart'; |
| 22 import 'package:analyzer/src/error/codes.dart'; | 22 import 'package:analyzer/src/error/codes.dart'; |
| 23 import 'package:analyzer/src/generated/engine.dart' show AnalysisOptionsImpl; | 23 import 'package:analyzer/src/generated/engine.dart' show AnalysisOptionsImpl; |
| 24 import 'package:analyzer/src/generated/source.dart'; | 24 import 'package:analyzer/src/generated/source.dart'; |
| 25 import 'package:analyzer/src/summary/idl.dart'; | 25 import 'package:analyzer/src/summary/idl.dart'; |
| 26 import 'package:convert/convert.dart'; | 26 import 'package:convert/convert.dart'; |
| 27 import 'package:crypto/crypto.dart'; | 27 import 'package:crypto/crypto.dart'; |
| 28 import 'package:test/test.dart'; | 28 import 'package:test/test.dart'; |
| 29 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 29 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 30 | 30 |
| 31 import '../../context/mock_sdk.dart'; | |
| 32 import 'base.dart'; | 31 import 'base.dart'; |
| 32 import 'physical_sdk.dart'; |
| 33 | 33 |
| 34 main() { | 34 main() { |
| 35 defineReflectiveSuite(() { | 35 defineReflectiveSuite(() { |
| 36 defineReflectiveTests(AnalysisDriverTest); | 36 defineReflectiveTests(AnalysisDriverTest); |
| 37 defineReflectiveTests(AnalysisDriverSchedulerTest); | 37 defineReflectiveTests(AnalysisDriverSchedulerTest); |
| 38 }); | 38 }); |
| 39 } | 39 } |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * Returns a [Future] that completes after pumping the event queue [times] | 42 * Returns a [Future] that completes after pumping the event queue [times] |
| 43 * times. By default, this should pump the event queue enough times to allow | 43 * times. By default, this should pump the event queue enough times to allow |
| 44 * any code to run, as long as it's not waiting on some external event. | 44 * any code to run, as long as it's not waiting on some external event. |
| 45 */ | 45 */ |
| 46 Future pumpEventQueue([int times = 5000]) { | 46 Future pumpEventQueue([int times = 5000]) { |
| 47 if (times == 0) return new Future.value(); | 47 if (times == 0) return new Future.value(); |
| 48 // We use a delayed future to allow microtask events to finish. The | 48 // We use a delayed future to allow microtask events to finish. The |
| 49 // Future.value or Future() constructors use scheduleMicrotask themselves and | 49 // Future.value or Future() constructors use scheduleMicrotask themselves and |
| 50 // would therefore not wait for microtask callbacks that are scheduled after | 50 // would therefore not wait for microtask callbacks that are scheduled after |
| 51 // invoking this method. | 51 // invoking this method. |
| 52 return new Future.delayed(Duration.ZERO, () => pumpEventQueue(times - 1)); | 52 return new Future.delayed(Duration.ZERO, () => pumpEventQueue(times - 1)); |
| 53 } | 53 } |
| 54 | 54 |
| 55 @reflectiveTest | 55 @reflectiveTest |
| 56 class AnalysisDriverSchedulerTest { | 56 class AnalysisDriverSchedulerTest { |
| 57 static final MockSdk sdk = new MockSdk(); | |
| 58 | |
| 59 final MemoryResourceProvider provider = new MemoryResourceProvider(); | 57 final MemoryResourceProvider provider = new MemoryResourceProvider(); |
| 60 final ByteStore byteStore = new MemoryByteStore(); | 58 final ByteStore byteStore = new MemoryByteStore(); |
| 61 final FileContentOverlay contentOverlay = new FileContentOverlay(); | 59 final FileContentOverlay contentOverlay = new FileContentOverlay(); |
| 62 | 60 |
| 63 final StringBuffer logBuffer = new StringBuffer(); | 61 final StringBuffer logBuffer = new StringBuffer(); |
| 64 PerformanceLog logger; | 62 PerformanceLog logger; |
| 65 | 63 |
| 66 AnalysisDriverScheduler scheduler; | 64 AnalysisDriverScheduler scheduler; |
| 67 | 65 |
| 68 List<AnalysisResult> allResults = []; | 66 List<AnalysisResult> allResults = []; |
| (...skipping 1730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1799 String _p(String path) => provider.convertPath(path); | 1797 String _p(String path) => provider.convertPath(path); |
| 1800 | 1798 |
| 1801 Future<Null> _waitForIdle() async { | 1799 Future<Null> _waitForIdle() async { |
| 1802 await idleStatusMonitor.signal; | 1800 await idleStatusMonitor.signal; |
| 1803 } | 1801 } |
| 1804 | 1802 |
| 1805 static String _md5(String content) { | 1803 static String _md5(String content) { |
| 1806 return hex.encode(md5.convert(UTF8.encode(content)).bytes); | 1804 return hex.encode(md5.convert(UTF8.encode(content)).bytes); |
| 1807 } | 1805 } |
| 1808 } | 1806 } |
| OLD | NEW |