Unverified Commit c7df2619 authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

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
parent 10cf0ced
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment