Chromium Code Reviews| 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<RunnerSuite>.error( |
| 168 new LoadException(path, error), stackTrace); | |
|
nweiz
2017/03/10 21:24:34
I think it would be cleaner to just add "return nu
keertip
2017/03/10 21:30:37
Done.
| |
| 168 } | 169 } |
| 169 }, path: path, platform: platform); | 170 }, path: path, platform: platform); |
| 170 } | 171 } |
| 171 } | 172 } |
| 172 | 173 |
| 173 Future closeEphemeral() async { | 174 Future closeEphemeral() async { |
| 174 await Future.wait(_platformPlugins.values.map((memo) async { | 175 await Future.wait(_platformPlugins.values.map((memo) async { |
| 175 if (!memo.hasRun) return; | 176 if (!memo.hasRun) return; |
| 176 await (await memo.future).closeEphemeral(); | 177 await (await memo.future).closeEphemeral(); |
| 177 })); | 178 })); |
| 178 } | 179 } |
| 179 | 180 |
| 180 /// Closes the loader and releases all resources allocated by it. | 181 /// Closes the loader and releases all resources allocated by it. |
| 181 Future close() => _closeMemo.runOnce(() async { | 182 Future close() => _closeMemo.runOnce(() async { |
| 182 await Future.wait([ | 183 await Future.wait([ |
| 183 Future.wait(_platformPlugins.values.map((memo) async { | 184 Future.wait(_platformPlugins.values.map((memo) async { |
| 184 if (!memo.hasRun) return; | 185 if (!memo.hasRun) return; |
| 185 await (await memo.future).close(); | 186 await (await memo.future).close(); |
| 186 })), | 187 })), |
| 187 Future.wait(_suites.map((suite) => suite.close())) | 188 Future.wait(_suites.map((suite) => suite.close())) |
| 188 ]); | 189 ]); |
| 189 | 190 |
| 190 _platformPlugins.clear(); | 191 _platformPlugins.clear(); |
| 191 _platformCallbacks.clear(); | 192 _platformCallbacks.clear(); |
| 192 _suites.clear(); | 193 _suites.clear(); |
| 193 }); | 194 }); |
| 194 final _closeMemo = new AsyncMemoizer(); | 195 final _closeMemo = new AsyncMemoizer(); |
| 195 } | 196 } |
| OLD | NEW |