mirror of
https://github.com/flutter/flutter.git
synced 2026-02-14 14:50:22 +08:00
Fixing local golden output flake (#44307)
This commit is contained in:
parent
3dd6741078
commit
dfbbfcd390
@ -506,10 +506,11 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC
|
||||
}
|
||||
failureDiffs[expectation] = result;
|
||||
}
|
||||
failureDiffs.forEach((String expectation, ComparisonResult result) async {
|
||||
if (await skiaClient.isValidDigestForExpectation(expectation, golden.path))
|
||||
generateFailureOutput(result, golden, basedir, key: expectation);
|
||||
});
|
||||
|
||||
for (MapEntry<String, ComparisonResult> entry in failureDiffs.entries) {
|
||||
if (await skiaClient.isValidDigestForExpectation(entry.key, golden.path))
|
||||
generateFailureOutput(entry.value, golden, basedir, key: entry.key);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -741,6 +741,27 @@ void main() {
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
|
||||
test('compare properly awaits validation & output before failing.', () async {
|
||||
final Completer<bool> completer = Completer<bool>();
|
||||
when(mockSkiaClient.isValidDigestForExpectation(
|
||||
'55109a4bed52acc780530f7a9aeff6c0',
|
||||
'library.flutter.golden_test.1.png',
|
||||
))
|
||||
.thenAnswer((_) => completer.future);
|
||||
final Future<bool> result = comparator.compare(
|
||||
Uint8List.fromList(_kFailPngBytes),
|
||||
Uri.parse('flutter.golden_test.1.png'),
|
||||
);
|
||||
bool shouldThrow = true;
|
||||
result.then((_) {
|
||||
if (shouldThrow)
|
||||
fail('Compare completed before validation completed!');
|
||||
});
|
||||
await Future<void>.value();
|
||||
shouldThrow = false;
|
||||
completer.complete(Future<bool>.value(false));
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user