mirror of
https://github.com/flutter/flutter.git
synced 2026-02-04 19:00:09 +08:00
Switching to Gold Status Check (#51968)
This commit is contained in:
parent
dbe91c96bd
commit
aa622fbb26
@ -371,6 +371,22 @@ void main() {
|
||||
expect(properties.properties.first.value, colorToPaint);
|
||||
});
|
||||
});
|
||||
testWidgets('Inconsequential golden test', (WidgetTester tester) async {
|
||||
// The test validates the Flutter Gold integration. Any changes to the
|
||||
// golden file can be approved at any time.
|
||||
await tester.pumpWidget(RepaintBoundary(
|
||||
child: Container(
|
||||
color: const Color(0xFF42A5F5),
|
||||
),
|
||||
));
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
await expectLater(
|
||||
find.byType(RepaintBoundary),
|
||||
matchesGoldenFile('inconsequential_golden_file.png'),
|
||||
);
|
||||
// TODO(Piinks): Remove skip once web goldens are supported, https://github.com/flutter/flutter/issues/40297
|
||||
}, skip: isBrowser);
|
||||
}
|
||||
|
||||
HitsRenderBox hits(RenderBox renderBox) => HitsRenderBox(renderBox);
|
||||
|
||||
@ -385,7 +385,11 @@ class _AuthorizedFlutterPreSubmitComparator extends FlutterPreSubmitFileComparat
|
||||
await update(golden, imageBytes);
|
||||
final File goldenFile = getGoldenFile(golden);
|
||||
|
||||
return skiaClient.tryjobAdd(golden.path, goldenFile);
|
||||
await skiaClient.tryjobAdd(golden.path, goldenFile);
|
||||
|
||||
// This will always return true since golden file test failures are managed
|
||||
// in pre-submit checks by the flutter-gold status check.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -325,7 +325,7 @@ class SkiaGoldClient {
|
||||
///
|
||||
/// The [testName] and [goldenFile] parameters reference the current
|
||||
/// comparison being evaluated by the [_AuthorizedFlutterPreSubmitComparator].
|
||||
Future<bool> tryjobAdd(String testName, File goldenFile) async {
|
||||
Future<void> tryjobAdd(String testName, File goldenFile) async {
|
||||
assert(testName != null);
|
||||
assert(goldenFile != null);
|
||||
|
||||
@ -343,36 +343,20 @@ class SkiaGoldClient {
|
||||
imgtestArguments,
|
||||
);
|
||||
|
||||
if (result.exitCode != 0) {
|
||||
final String resultStdout = result.stdout.toString();
|
||||
if (resultStdout.contains('Untriaged') || resultStdout.contains('negative image')) {
|
||||
final List<String> failureLinks = await workDirectory.childFile('failures.json').readAsLines();
|
||||
|
||||
final StringBuffer buf = StringBuffer()
|
||||
..writeln('The golden file "$testName" ')
|
||||
..writeln('did not match the expected image.')
|
||||
..writeln('To view the closest matching image, the actual image generated, ')
|
||||
..writeln('and the visual difference, visit: ')
|
||||
..writeln(failureLinks.last)
|
||||
..writeln('There you can also triage this image (e.g. because this ')
|
||||
..writeln('is an intentional change).')
|
||||
..writeln();
|
||||
throw Exception(buf.toString());
|
||||
} else {
|
||||
final StringBuffer buf = StringBuffer()
|
||||
..writeln('Unexpected Gold tryjobAdd failure.')
|
||||
..writeln('Tryjob execution for golden file test $testName failed for')
|
||||
..writeln('a reason unrelated to pixel comparison.')
|
||||
..writeln()
|
||||
..writeln('Debug information for Gold:')
|
||||
..writeln('stdout: ${result.stdout}')
|
||||
..writeln('stderr: ${result.stderr}')
|
||||
..writeln();
|
||||
throw Exception(buf.toString());
|
||||
}
|
||||
final String resultStdout = result.stdout.toString();
|
||||
if (result.exitCode != 0 &&
|
||||
!(resultStdout.contains('Untriaged') || resultStdout.contains('negative image'))) {
|
||||
final StringBuffer buf = StringBuffer()
|
||||
..writeln('Unexpected Gold tryjobAdd failure.')
|
||||
..writeln('Tryjob execution for golden file test $testName failed for')
|
||||
..writeln('a reason unrelated to pixel comparison.')
|
||||
..writeln()
|
||||
..writeln('Debug information for Gold:')
|
||||
..writeln('stdout: ${result.stdout}')
|
||||
..writeln('stderr: ${result.stderr}')
|
||||
..writeln();
|
||||
throw Exception(buf.toString());
|
||||
}
|
||||
|
||||
return result.exitCode == 0;
|
||||
}
|
||||
|
||||
/// Executes the `imgtest check` command in the goldctl tool for unauthorized
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user