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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 yield new LoadSuite(name, platformConfig, () async { | 157 yield new LoadSuite(name, platformConfig, () async { |
158 var memo = _platformPlugins[platform]; | 158 var memo = _platformPlugins[platform]; |
159 | 159 |
160 try { | 160 try { |
161 var plugin = await memo.runOnce(_platformCallbacks[platform]); | 161 var plugin = await memo.runOnce(_platformCallbacks[platform]); |
162 var suite = await plugin.load(path, platform, platformConfig); | 162 var suite = await plugin.load(path, platform, platformConfig); |
163 _suites.add(suite); | 163 _suites.add(suite); |
164 return suite; | 164 return suite; |
165 } catch (error, stackTrace) { | 165 } catch (error, stackTrace) { |
166 if (error is LoadException) rethrow; | 166 if (error is LoadException) rethrow; |
167 await new Future.error(new LoadException(path, error), stackTrace); | 167 await new Future.error( |
| 168 new LoadException(path, error), stackTrace); |
| 169 return null; |
168 } | 170 } |
169 }, path: path, platform: platform); | 171 }, path: path, platform: platform); |
170 } | 172 } |
171 } | 173 } |
172 | 174 |
173 Future closeEphemeral() async { | 175 Future closeEphemeral() async { |
174 await Future.wait(_platformPlugins.values.map((memo) async { | 176 await Future.wait(_platformPlugins.values.map((memo) async { |
175 if (!memo.hasRun) return; | 177 if (!memo.hasRun) return; |
176 await (await memo.future).closeEphemeral(); | 178 await (await memo.future).closeEphemeral(); |
177 })); | 179 })); |
178 } | 180 } |
179 | 181 |
180 /// Closes the loader and releases all resources allocated by it. | 182 /// Closes the loader and releases all resources allocated by it. |
181 Future close() => _closeMemo.runOnce(() async { | 183 Future close() => _closeMemo.runOnce(() async { |
182 await Future.wait([ | 184 await Future.wait([ |
183 Future.wait(_platformPlugins.values.map((memo) async { | 185 Future.wait(_platformPlugins.values.map((memo) async { |
184 if (!memo.hasRun) return; | 186 if (!memo.hasRun) return; |
185 await (await memo.future).close(); | 187 await (await memo.future).close(); |
186 })), | 188 })), |
187 Future.wait(_suites.map((suite) => suite.close())) | 189 Future.wait(_suites.map((suite) => suite.close())) |
188 ]); | 190 ]); |
189 | 191 |
190 _platformPlugins.clear(); | 192 _platformPlugins.clear(); |
191 _platformCallbacks.clear(); | 193 _platformCallbacks.clear(); |
192 _suites.clear(); | 194 _suites.clear(); |
193 }); | 195 }); |
194 final _closeMemo = new AsyncMemoizer(); | 196 final _closeMemo = new AsyncMemoizer(); |
195 } | 197 } |
OLD | NEW |