Run test harness finalizers in reverse order. (#16664)

Finalizers handle the restoration of state. In order to restore
the state correctly, they shouyld be run in LIFO order.

Fixes #16657
This commit is contained in:
Todd Volkert 2018-04-17 07:38:30 -07:00 committed by GitHub
parent 10cf0cedad
commit c7df2619d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -275,7 +275,7 @@ class _FlutterPlatform extends PlatformPlugin {
dynamic outOfBandError; // error that we couldn't send to the harness that we need to send via our future
final List<_Finalizer> finalizers = <_Finalizer>[];
final List<_Finalizer> finalizers = <_Finalizer>[]; // Will be run in reverse order.
bool subprocessActive = false;
bool controllerSinkClosed = false;
try {
@ -511,7 +511,8 @@ class _FlutterPlatform extends PlatformPlugin {
}
} finally {
printTrace('test $ourTestCount: cleaning up...');
for (_Finalizer finalizer in finalizers) {
// Finalizers are treated like a stack; run them in reverse order.
for (_Finalizer finalizer in finalizers.reversed) {
try {
await finalizer();
} catch (error, stack) {