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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:io'; | 6 import 'dart:io'; |
7 | 7 |
8 import 'package:analyzer/analyzer.dart' hide Configuration; | 8 import 'package:analyzer/analyzer.dart' hide Configuration; |
9 import 'package:async/async.dart'; | 9 import 'package:async/async.dart'; |
10 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 /// Registers a [PlatformPlugin] for [platforms]. | 69 /// Registers a [PlatformPlugin] for [platforms]. |
70 /// | 70 /// |
71 /// When the runner first requests that a suite be loaded for one of the given | 71 /// When the runner first requests that a suite be loaded for one of the given |
72 /// platforms, this will call [getPlugin] to load the platform plugin. It may | 72 /// platforms, this will call [getPlugin] to load the platform plugin. It may |
73 /// return either a [PlatformPlugin] or a [Future<PlatformPlugin>]. That | 73 /// return either a [PlatformPlugin] or a [Future<PlatformPlugin>]. That |
74 /// plugin is then preserved and used to load all suites for all matching | 74 /// plugin is then preserved and used to load all suites for all matching |
75 /// platforms. | 75 /// platforms. |
76 /// | 76 /// |
77 /// This overwrites previous plugins for those platforms. | 77 /// This overwrites previous plugins for those platforms. |
78 void registerPlatformPlugin(Iterable<TestPlatform> platforms, getPlugin()) { | 78 void registerPlatformPlugin(Iterable<TestPlatform> platforms, getPlugin()) { |
79 var memoizer = new AsyncMemoizer(); | 79 var memoizer = new AsyncMemoizer<PlatformPlugin>(); |
80 for (var platform in platforms) { | 80 for (var platform in platforms) { |
81 _platformPlugins[platform] = memoizer; | 81 _platformPlugins[platform] = memoizer; |
82 _platformCallbacks[platform] = getPlugin; | 82 _platformCallbacks[platform] = getPlugin; |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 /// Loads all test suites in [dir]. | 86 /// Loads all test suites in [dir]. |
87 /// | 87 /// |
88 /// This will load tests from files that match the configuration's filename | 88 /// This will load tests from files that match the configuration's filename |
89 /// glob. Any tests that fail to load will be emitted as [LoadException]s. | 89 /// glob. Any tests that fail to load will be emitted as [LoadException]s. |
90 /// | 90 /// |
91 /// This emits [LoadSuite]s that must then be run to emit the actual | 91 /// This emits [LoadSuite]s that must then be run to emit the actual |
92 /// [RunnerSuite]s defined in the file. | 92 /// [RunnerSuite]s defined in the file. |
93 Stream<LoadSuite> loadDir(String dir) { | 93 Stream<LoadSuite> loadDir(String dir) { |
94 return mergeStreams(new Directory(dir).listSync(recursive: true) | 94 return StreamGroup.merge(new Directory(dir).listSync(recursive: true) |
95 .map((entry) { | 95 .map((entry) { |
96 if (entry is! File) return new Stream.fromIterable([]); | 96 if (entry is! File) return new Stream.fromIterable([]); |
97 | 97 |
98 if (!_config.filename.matches(p.basename(entry.path))) { | 98 if (!_config.filename.matches(p.basename(entry.path))) { |
99 return new Stream.fromIterable([]); | 99 return new Stream.fromIterable([]); |
100 } | 100 } |
101 | 101 |
102 if (p.split(entry.path).contains('packages')) { | 102 if (p.split(entry.path).contains('packages')) { |
103 return new Stream.fromIterable([]); | 103 return new Stream.fromIterable([]); |
104 } | 104 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 })), | 181 })), |
182 Future.wait(_suites.map((suite) => suite.close())) | 182 Future.wait(_suites.map((suite) => suite.close())) |
183 ]); | 183 ]); |
184 | 184 |
185 _platformPlugins.clear(); | 185 _platformPlugins.clear(); |
186 _platformCallbacks.clear(); | 186 _platformCallbacks.clear(); |
187 _suites.clear(); | 187 _suites.clear(); |
188 }); | 188 }); |
189 final _closeMemo = new AsyncMemoizer(); | 189 final _closeMemo = new AsyncMemoizer(); |
190 } | 190 } |
OLD | NEW |